adapt-schemas 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/Schema.js +8 -8
  2. package/package.json +1 -1
package/lib/Schema.js CHANGED
@@ -379,22 +379,22 @@ class Schema extends EventEmitter {
379
379
  * @param {Function} predicate - `(schemaField) => boolean`
380
380
  * @param {Object} [schema] - Internal: schema properties to walk (defaults to built.properties)
381
381
  * @param {string} [parentPath=''] - Internal: the slash-delimited path accumulated so far
382
- * @returns {Array<Object>} Array of `{ path, key, data, value }` matches
382
+ * @returns {Array<Object>} Array of `{ path, key, data, value, schemaField }` matches
383
383
  */
384
384
  walk (data, predicate, schema, parentPath = '') {
385
385
  schema = schema ?? this.built.properties
386
386
  const matches = []
387
- for (const [key, val] of Object.entries(schema)) {
387
+ for (const [key, schemaField] of Object.entries(schema)) {
388
388
  if (data[key] === undefined) continue
389
389
  const currentPath = parentPath ? `${parentPath}/${key}` : key
390
- if (val.properties) {
391
- matches.push(...this.walk(data[key], predicate, val.properties, currentPath))
392
- } else if (val?.items?.properties) {
390
+ if (schemaField.properties) {
391
+ matches.push(...this.walk(data[key], predicate, schemaField.properties, currentPath))
392
+ } else if (schemaField?.items?.properties) {
393
393
  data[key].forEach((item, i) => {
394
- matches.push(...this.walk(item, predicate, val.items.properties, `${currentPath}/${i}`))
394
+ matches.push(...this.walk(item, predicate, schemaField.items.properties, `${currentPath}/${i}`))
395
395
  })
396
- } else if (predicate(val)) {
397
- matches.push({ path: currentPath, key, data, value: data[key] })
396
+ } else if (predicate(schemaField)) {
397
+ matches.push({ path: currentPath, key, data, value: data[key], schemaField })
398
398
  }
399
399
  }
400
400
  return matches
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/cgkineo/adapt-schemas"
6
6
  },
7
- "version": "2.0.1",
7
+ "version": "2.1.0",
8
8
  "description": "Standalone JSON Schema library for the Adapt framework",
9
9
  "type": "module",
10
10
  "main": "index.js",