From fd3ee16ef7a9e0c4e6d8189a475f8722013d388b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 15 Aug 2018 18:33:17 -0700 Subject: [PATCH] figgy-pudding@3.4.1 Credit: @zkat --- node_modules/figgy-pudding/CHANGELOG.md | 40 ++++++++++++ node_modules/figgy-pudding/index.js | 85 ++++++++++++++++++++++--- node_modules/figgy-pudding/package.json | 24 +++---- package-lock.json | 6 +- package.json | 2 +- 5 files changed, 132 insertions(+), 25 deletions(-) diff --git a/node_modules/figgy-pudding/CHANGELOG.md b/node_modules/figgy-pudding/CHANGELOG.md index 3109e51c52a7d..b3bf92d1509e8 100644 --- a/node_modules/figgy-pudding/CHANGELOG.md +++ b/node_modules/figgy-pudding/CHANGELOG.md @@ -2,6 +2,46 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [3.4.1](https://github.com/zkat/figgy-pudding/compare/v3.4.0...v3.4.1) (2018-08-16) + + +### Bug Fixes + +* **forEach:** get forEach to behave like a normal forEach ([c064755](https://github.com/zkat/figgy-pudding/commit/c064755)) +* **has:** get `in` keyword working right ([fafc5a8](https://github.com/zkat/figgy-pudding/commit/fafc5a8)) +* **iteration:** fix and test iteration of opts.other keys ([7a76217](https://github.com/zkat/figgy-pudding/commit/7a76217)) +* **iteration:** use proper args for forEach/toJSON ([974e879](https://github.com/zkat/figgy-pudding/commit/974e879)) +* **proxy:** make sure proxy corner-cases work ok ([8c66e45](https://github.com/zkat/figgy-pudding/commit/8c66e45)) +* **set:** fix and test the exceptions to writing ([206793b](https://github.com/zkat/figgy-pudding/commit/206793b)) + + + + +# [3.4.0](https://github.com/zkat/figgy-pudding/compare/v3.3.0...v3.4.0) (2018-08-16) + + +### Features + +* **iterator:** allow iteration over "other" keys ([3c53323](https://github.com/zkat/figgy-pudding/commit/3c53323)) + + + + +# [3.3.0](https://github.com/zkat/figgy-pudding/compare/v3.2.1...v3.3.0) (2018-08-16) + + +### Bug Fixes + +* **props:** allow symbols to pass through ([97b3464](https://github.com/zkat/figgy-pudding/commit/97b3464)) + + +### Features + +* **pudding:** iteration and serialization support ([0aaa50d](https://github.com/zkat/figgy-pudding/commit/0aaa50d)) + + + ## [3.2.1](https://github.com/zkat/figgy-pudding/compare/v3.2.0...v3.2.1) (2018-08-15) diff --git a/node_modules/figgy-pudding/index.js b/node_modules/figgy-pudding/index.js index 5747e91d4fd6b..7991e69fc832f 100644 --- a/node_modules/figgy-pudding/index.js +++ b/node_modules/figgy-pudding/index.js @@ -17,8 +17,8 @@ class FiggyPudding { } } }) - this.__opts = opts || (() => false) - this.__providers = reverse((providers || []).filter( + this.__opts = opts || {} + this.__providers = reverse((providers).filter( x => x != null && typeof x === 'object' )) this.__isFiggyPudding = true @@ -26,6 +26,52 @@ class FiggyPudding { get (key) { return pudGet(this, key, true) } + get [Symbol.toStringTag] () { return 'FiggyPudding' } + forEach (fn, thisArg = this) { + for (let [key, value] of this.entries()) { + fn.call(thisArg, value, key, this) + } + } + toJSON () { + const obj = {} + this.forEach((val, key) => { + obj[key] = val + }) + return obj + } + * entries (_matcher) { + for (let key of Object.keys(this.__specs)) { + yield [key, this.get(key)] + } + const matcher = _matcher || this.__opts.other + if (matcher) { + const seen = new Set() + for (let p of this.__providers) { + const iter = p.entries ? p.entries(matcher) : Object.entries(p) + for (let [key, val] of iter) { + if (matcher(key) && !seen.has(key)) { + seen.add(key) + yield [key, val] + } + } + } + } + } + * [Symbol.iterator] () { + for (let [key, value] of this.entries()) { + yield [key, value] + } + } + * keys () { + for (let [key] of this.entries()) { + yield key + } + } + * values () { + for (let [, value] of this.entries()) { + yield value + } + } concat (...moreConfig) { return new Proxy(new FiggyPudding( this.__specs, @@ -34,11 +80,25 @@ class FiggyPudding { ), proxyHandler) } } +try { + const util = require('util') + FiggyPudding.prototype[util.inspect.custom] = function (depth, opts) { + return ( + this[Symbol.toStringTag] + ' ' + ) + util.inspect(this.toJSON(), opts) + } +} catch (e) {} + +function BadKeyError (key) { + throw Object.assign(new Error( + `invalid config key requested: ${key}` + ), {code: 'EBADKEY'}) +} function pudGet (pud, key, validate) { let spec = pud.__specs[key] if (validate && !spec && (!pud.__opts.other || !pud.__opts.other(key))) { - throw new Error(`invalid config key requested: ${key}`) + BadKeyError(key) } else { if (!spec) { spec = {} } let ret @@ -83,26 +143,33 @@ function tryGet (key, p) { const proxyHandler = { has (obj, prop) { - return pudGet(obj, prop, false) !== undefined + return prop in obj.__specs && pudGet(obj, prop, false) !== undefined + }, + ownKeys (obj) { + return Object.keys(obj.__specs) }, get (obj, prop) { if ( - prop === 'concat' || - prop === 'get' || - prop.slice(0, 2) === '__' + typeof prop === 'symbol' || + prop.slice(0, 2) === '__' || + prop in FiggyPudding.prototype ) { return obj[prop] } return obj.get(prop) }, set (obj, prop, value) { - if (prop.slice(0, 2) === '__') { + if ( + typeof prop === 'symbol' || + prop.slice(0, 2) === '__' + ) { obj[prop] = value + return true } else { throw new Error('figgyPudding options cannot be modified. Use .concat() instead.') } }, - delete () { + deleteProperty () { throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.') } } diff --git a/node_modules/figgy-pudding/package.json b/node_modules/figgy-pudding/package.json index 0ec652582ee89..81e03eff7d7ac 100644 --- a/node_modules/figgy-pudding/package.json +++ b/node_modules/figgy-pudding/package.json @@ -1,19 +1,19 @@ { - "_from": "figgy-pudding@3.2.1", - "_id": "figgy-pudding@3.2.1", + "_from": "figgy-pudding@latest", + "_id": "figgy-pudding@3.4.1", "_inBundle": false, - "_integrity": "sha512-1kWvzhClfNh9NhhUaT9D9H7knbQ4kW+SOa7TRYHZshd0YsBWQpffjx9T++Psx5XpXJV6utRSP70sm2Ivb7If3w==", + "_integrity": "sha512-j1SAT641cerGuOvoSBoaE9LbSzh1N/E5ufk9oMpOKuyK8MyW3sGg4rh+4qhLmVTEAzipO5XTHYT4gjb6JYLE8g==", "_location": "/figgy-pudding", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "tag", "registry": true, - "raw": "figgy-pudding@3.2.1", + "raw": "figgy-pudding@latest", "name": "figgy-pudding", "escapedName": "figgy-pudding", - "rawSpec": "3.2.1", + "rawSpec": "latest", "saveSpec": null, - "fetchSpec": "3.2.1" + "fetchSpec": "latest" }, "_requiredBy": [ "#USER", @@ -22,9 +22,9 @@ "/libnpmhook", "/libnpmhook/npm-registry-fetch" ], - "_resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.2.1.tgz", - "_shasum": "946bdc2515abad5190027113778595462b668eb3", - "_spec": "figgy-pudding@3.2.1", + "_resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.4.1.tgz", + "_shasum": "af66da1991fa2f94ff7f33b545a38ea4b3869696", + "_spec": "figgy-pudding@latest", "_where": "/Users/zkat/Documents/code/work/npm", "author": { "name": "Kat Marchán", @@ -66,9 +66,9 @@ "prerelease": "npm t", "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --coverage test/*.js", + "test": "tap -J --100 --coverage test/*.js", "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "3.2.1" + "version": "3.4.1" } diff --git a/package-lock.json b/package-lock.json index e982a567f1c92..21b74bd4ca6f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1479,9 +1479,9 @@ } }, "figgy-pudding": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.2.1.tgz", - "integrity": "sha512-1kWvzhClfNh9NhhUaT9D9H7knbQ4kW+SOa7TRYHZshd0YsBWQpffjx9T++Psx5XpXJV6utRSP70sm2Ivb7If3w==" + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.4.1.tgz", + "integrity": "sha512-j1SAT641cerGuOvoSBoaE9LbSzh1N/E5ufk9oMpOKuyK8MyW3sGg4rh+4qhLmVTEAzipO5XTHYT4gjb6JYLE8g==" }, "figures": { "version": "2.0.0", diff --git a/package.json b/package.json index 6dfac0e8cdf21..a2e97e7a60802 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "detect-newline": "^2.1.0", "dezalgo": "~1.0.3", "editor": "~1.0.0", - "figgy-pudding": "^3.2.1", + "figgy-pudding": "^3.4.1", "find-npm-prefix": "^1.0.2", "fs-vacuum": "~1.2.10", "fs-write-stream-atomic": "~1.0.10",