From 6eaa070e5c036ba8cd45f79c16dc2732b40ea480 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Sep 2023 09:14:29 -0300 Subject: data, util: hsmusic.sugar.index -> hsmusic.decorate.indexInSourceArray --- src/data/things/validators.js | 3 ++- src/util/sugar.js | 2 +- test/unit/data/composite/common-utilities/withPropertiesFromObject.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/data/things/validators.js b/src/data/things/validators.js index ba62fb8..bdb2205 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -174,7 +174,8 @@ function validateArrayItemsHelper(itemValidator) { throw new Error(`Expected validator to return true`); } } catch (error) { - error.message = `(index: ${colors.yellow(`#${index}`)}, item: ${inspect(item)}) ${error.message}`; + error.message = `(index: ${colors.yellow(`${index}`)}, item: ${inspect(item)}) ${error.message}`; + error[Symbol.for('hsmusic.decorate.indexInSourceArray')] = index; throw error; } }; diff --git a/src/util/sugar.js b/src/util/sugar.js index 0522b59..2e724ba 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -624,7 +624,7 @@ export function decorateErrorWithIndex(fn) { return fn(x, index, array); } catch (error) { error.message = `(${colors.yellow(`#${index + 1}`)}) ${error.message}`; - error[Symbol.for('hsmusic.sugar.index')] = 1; + error[Symbol.for('hsmusic.decorate.indexInSourceArray')] = index; throw error; } }; diff --git a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js index 6b4e10c..b1b8be7 100644 --- a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js +++ b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js @@ -216,7 +216,7 @@ t.test(`withPropertiesFromObject: validate static inputs`, t => { {message: 'object: Expected an object, got array'}, {message: 'properties: Errors validating array items', errors: [ { - [Symbol.for('hsmusic.sugar.index')]: 2, + [Symbol.for('hsmusic.decorate.indexInSourceArray')]: 2, message: /Expected a string, got number/, }, ]}, -- cgit 1.3.0-6-gf8a5