diff options
author | 2020-11-16 00:10:28 +0100 | |
---|---|---|
committer | 2020-11-16 00:10:28 +0100 | |
commit | e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch) | |
tree | 55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/figgy-pudding | |
download | website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2 website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip |
api, login, auth
Diffstat (limited to 'node_modules/figgy-pudding')
-rw-r--r-- | node_modules/figgy-pudding/CHANGELOG.md | 156 | ||||
-rw-r--r-- | node_modules/figgy-pudding/LICENSE.md | 16 | ||||
-rw-r--r-- | node_modules/figgy-pudding/README.md | 268 | ||||
-rw-r--r-- | node_modules/figgy-pudding/index.js | 197 | ||||
-rw-r--r-- | node_modules/figgy-pudding/package.json | 67 |
5 files changed, 704 insertions, 0 deletions
diff --git a/node_modules/figgy-pudding/CHANGELOG.md b/node_modules/figgy-pudding/CHANGELOG.md new file mode 100644 index 0000000..d702fa3 --- /dev/null +++ b/node_modules/figgy-pudding/CHANGELOG.md @@ -0,0 +1,156 @@ +# Change Log + +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. + +<a name="3.5.2"></a> +## [3.5.2](https://github.com/npm/figgy-pudding/compare/v3.5.1...v3.5.2) (2020-03-24) + + + +<a name="3.5.1"></a> +## [3.5.1](https://github.com/npm/figgy-pudding/compare/v3.5.0...v3.5.1) (2018-08-25) + + + +<a name="3.5.0"></a> +# [3.5.0](https://github.com/npm/figgy-pudding/compare/v3.4.1...v3.5.0) (2018-08-25) + + +### Bug Fixes + +* **node:** get rid of Object.entries to add node6 support back ([074f779](https://github.com/npm/figgy-pudding/commit/074f779)) + + +### Features + +* **node:** add node@10 to CI config ([78b8937](https://github.com/npm/figgy-pudding/commit/78b8937)) + + + +<a name="3.4.1"></a> +## [3.4.1](https://github.com/npm/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/npm/figgy-pudding/commit/c064755)) +* **has:** get `in` keyword working right ([fafc5a8](https://github.com/npm/figgy-pudding/commit/fafc5a8)) +* **iteration:** fix and test iteration of opts.other keys ([7a76217](https://github.com/npm/figgy-pudding/commit/7a76217)) +* **iteration:** use proper args for forEach/toJSON ([974e879](https://github.com/npm/figgy-pudding/commit/974e879)) +* **proxy:** make sure proxy corner-cases work ok ([8c66e45](https://github.com/npm/figgy-pudding/commit/8c66e45)) +* **set:** fix and test the exceptions to writing ([206793b](https://github.com/npm/figgy-pudding/commit/206793b)) + + + +<a name="3.4.0"></a> +# [3.4.0](https://github.com/npm/figgy-pudding/compare/v3.3.0...v3.4.0) (2018-08-16) + + +### Features + +* **iterator:** allow iteration over "other" keys ([3c53323](https://github.com/npm/figgy-pudding/commit/3c53323)) + + + +<a name="3.3.0"></a> +# [3.3.0](https://github.com/npm/figgy-pudding/compare/v3.2.1...v3.3.0) (2018-08-16) + + +### Bug Fixes + +* **props:** allow symbols to pass through ([97b3464](https://github.com/npm/figgy-pudding/commit/97b3464)) + + +### Features + +* **pudding:** iteration and serialization support ([0aaa50d](https://github.com/npm/figgy-pudding/commit/0aaa50d)) + + + +<a name="3.2.1"></a> +## [3.2.1](https://github.com/npm/figgy-pudding/compare/v3.2.0...v3.2.1) (2018-08-15) + + +### Bug Fixes + +* **aliases:** make reverse aliases work correctly ([76a255e](https://github.com/npm/figgy-pudding/commit/76a255e)) + + + +<a name="3.2.0"></a> +# [3.2.0](https://github.com/npm/figgy-pudding/compare/v3.1.0...v3.2.0) (2018-07-26) + + +### Bug Fixes + +* **concat:** have concat spit out a proxy, too ([64e3495](https://github.com/npm/figgy-pudding/commit/64e3495)) + + +### Features + +* **default:** pass the pudding itself to default fns ([d9d9e09](https://github.com/npm/figgy-pudding/commit/d9d9e09)) + + + +<a name="3.1.0"></a> +# [3.1.0](https://github.com/npm/figgy-pudding/compare/v3.0.0...v3.1.0) (2018-04-08) + + +### Features + +* **opts:** allow direct option fetching without .get() ([ca77aad](https://github.com/npm/figgy-pudding/commit/ca77aad)) + + + +<a name="3.0.0"></a> +# [3.0.0](https://github.com/npm/figgy-pudding/compare/v2.0.1...v3.0.0) (2018-04-06) + + +### Bug Fixes + +* **ci:** oops -- forgot to update CI config ([7a40563](https://github.com/npm/figgy-pudding/commit/7a40563)) +* **get:** make provider lookup order like Object.assign ([33ff89b](https://github.com/npm/figgy-pudding/commit/33ff89b)) + + +### Features + +* **concat:** add .concat() method to opts ([d310fce](https://github.com/npm/figgy-pudding/commit/d310fce)) + + +### meta + +* drop support for node@4 and node@7 ([9f8a61c](https://github.com/npm/figgy-pudding/commit/9f8a61c)) + + +### BREAKING CHANGES + +* node@4 and node@7 are no longer supported +* **get:** shadow order for properties in providers is reversed + + + +<a name="2.0.1"></a> +## [2.0.1](https://github.com/npm/figgy-pudding/compare/v2.0.0...v2.0.1) (2018-03-16) + + +### Bug Fixes + +* **opts:** ignore non-object providers ([7b9c0f8](https://github.com/npm/figgy-pudding/commit/7b9c0f8)) + + + +<a name="2.0.0"></a> +# [2.0.0](https://github.com/npm/figgy-pudding/compare/v1.0.0...v2.0.0) (2018-03-16) + + +### Features + +* **api:** overhauled API with new opt handling concept ([e6cc929](https://github.com/npm/figgy-pudding/commit/e6cc929)) +* **license:** relicense to ISC ([87479aa](https://github.com/npm/figgy-pudding/commit/87479aa)) + + +### BREAKING CHANGES + +* **license:** the license has been changed from CC0-1.0 to ISC. +* **api:** this is a completely different approach than previously +used by this library. See the readme for the new API and an explanation. diff --git a/node_modules/figgy-pudding/LICENSE.md b/node_modules/figgy-pudding/LICENSE.md new file mode 100644 index 0000000..8d28acf --- /dev/null +++ b/node_modules/figgy-pudding/LICENSE.md @@ -0,0 +1,16 @@ +ISC License + +Copyright (c) npm, Inc. + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE COPYRIGHT HOLDER DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE +USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/figgy-pudding/README.md b/node_modules/figgy-pudding/README.md new file mode 100644 index 0000000..425a837 --- /dev/null +++ b/node_modules/figgy-pudding/README.md @@ -0,0 +1,268 @@ +# Note: pending imminent deprecation + +**This module will be deprecated once npm v7 is released. Please do not rely +on it more than absolutely necessary (ie, only if you are depending on +it for use with npm v6 internal dependencies).** + +---- + +# figgy-pudding [](https://npm.im/figgy-pudding) [](https://npm.im/figgy-pudding) [](https://travis-ci.org/npm/figgy-pudding) [](https://coveralls.io/github/npm/figgy-pudding?branch=latest) + +[`figgy-pudding`](https://github.com/npm/figgy-pudding) is a small JavaScript +library for managing and composing cascading options objects -- hiding what +needs to be hidden from each layer, without having to do a lot of manual munging +and passing of options. + +### The God Object is Dead! +### Now Bring Us Some Figgy Pudding! + +## Install + +`$ npm install figgy-pudding` + +## Table of Contents + +* [Example](#example) +* [Features](#features) +* [API](#api) + * [`figgyPudding(spec)`](#figgy-pudding) + * [`PuddingFactory(values)`](#pudding-factory) + * [`opts.get()`](#opts-get) + * [`opts.concat()`](#opts-concat) + * [`opts.toJSON()`](#opts-to-json) + * [`opts.forEach()`](#opts-for-each) + * [`opts[Symbol.iterator]()`](#opts-symbol-iterator) + * [`opts.entries()`](#opts-entries) + * [`opts.keys()`](#opts-keys) + * [`opts.value()`](#opts-values) + +### Example + +```javascript +// print-package.js +const fetch = require('./fetch.js') +const puddin = require('figgy-pudding') + +const PrintOpts = puddin({ + json: { default: false } +}) + +async function printPkg (name, opts) { + // Expected pattern is to call this in every interface function. If `opts` is + // not passed in, it will automatically create an (empty) object for it. + opts = PrintOpts(opts) + const uri = `https://registry.npmjs.com/${name}` + const res = await fetch(uri, opts.concat({ + // Add or override any passed-in configs and pass them down. + log: customLogger + })) + // The following would throw an error, because it's not in PrintOpts: + // console.log(opts.log) + if (opts.json) { + return res.json() + } else { + return res.text() + } +} + +console.log(await printPkg('figgy', { + // Pass in *all* configs at the toplevel, as a regular object. + json: true, + cache: './tmp-cache' +})) +``` + +```javascript +// fetch.js +const puddin = require('figgy-pudding') + +const FetchOpts = puddin({ + log: { default: require('npmlog') }, + cache: {} +}) + +module.exports = async function (..., opts) { + opts = FetchOpts(opts) +} +``` + +### Features + +* hide options from layer that didn't ask for it +* shared multi-layer options +* make sure `opts` argument is available +* transparent key access like normal keys, through a Proxy. No need for`.get()`! +* default values +* key aliases +* arbitrary key filter functions +* key/value iteration +* serialization +* 100% test coverage using `tap --100` + +### API + +#### <a name="figgy-pudding"></a> `> figgyPudding({ key: { default: val } | String }, [opts]) -> PuddingFactory` + +Defines an Options constructor that can be used to collect only the needed +options. + +An optional `default` property for specs can be used to specify default values +if nothing was passed in. + +If the value for a spec is a string, it will be treated as an alias to that +other key. + +##### Example + +```javascript +const MyAppOpts = figgyPudding({ + lg: 'log', + log: { + default: () => require('npmlog') + }, + cache: {} +}) +``` + +#### <a name="pudding-factory"></a> `> PuddingFactory(...providers) -> FiggyPudding{}` + +Instantiates an options object defined by `figgyPudding()`, which uses +`providers`, in order, to find requested properties. + +Each provider can be either a plain object, a `Map`-like object (that is, one +with a `.get()` method) or another figgyPudding `Opts` object. + +When nesting `Opts` objects, their properties will not become available to the +new object, but any further nested `Opts` that reference that property _will_ be +able to read from their grandparent, as long as they define that key. Default +values for nested `Opts` parents will be used, if found. + +##### Example + +```javascript +const ReqOpts = figgyPudding({ + follow: {} +}) + +const opts = ReqOpts({ + follow: true, + log: require('npmlog') +}) + +opts.follow // => true +opts.log // => Error: ReqOpts does not define `log` + +const MoreOpts = figgyPudding({ + log: {} +}) +MoreOpts(opts).log // => npmlog object (passed in from original plain obj) +MoreOpts(opts).follow // => Error: MoreOpts does not define `follow` +``` + +#### <a name="opts-get"></a> `> opts.get(key) -> Value` + +Gets a value from the options object. + +##### Example + +```js +const opts = MyOpts(config) +opts.get('foo') // value of `foo` +opts.foo // Proxy-based access through `.get()` +``` + +#### <a name="opts-concat"></a> `> opts.concat(...moreProviders) -> FiggyPudding{}` + +Creates a new opts object of the same type as `opts` with additional providers. +Providers further to the right shadow providers to the left, with properties in +the original `opts` being shadows by the new providers. + +##### Example + +```js +const opts = MyOpts({x: 1}) +opts.get('x') // 1 +opts.concat({x: 2}).get('x') // 2 +opts.get('x') // 1 (original opts object left intact) +``` + +#### <a name="opts-to-json"></a> `> opts.toJSON() -> Value` + +Converts `opts` to a plain, JSON-stringifiable JavaScript value. Used internally +by JavaScript to get `JSON.stringify()` working. + +Only keys that are readable by the current pudding type will be serialized. + +##### Example + +```js +const opts = MyOpts({x: 1}) +opts.toJSON() // {x: 1} +JSON.stringify(opts) // '{"x":1}' +``` + +#### <a name="opts-for-each"></a> `> opts.forEach((value, key, opts) => {}, thisArg) -> undefined` + +Iterates over the values of `opts`, limited to the keys readable by the current +pudding type. `thisArg` will be used to set the `this` argument when calling the +`fn`. + +##### Example + +```js +const opts = MyOpts({x: 1, y: 2}) +opts.forEach((value, key) => console.log(key, '=', value)) +``` + +#### <a name="opts-entries"></a> `> opts.entries() -> Iterator<[[key, value], ...]>` + +Returns an iterator that iterates over the keys and values in `opts`, limited to +the keys readable by the current pudding type. Each iteration returns an array +of `[key, value]`. + +##### Example + +```js +const opts = MyOpts({x: 1, y: 2}) +[...opts({x: 1, y: 2}).entries()] // [['x', 1], ['y', 2]] +``` + +#### <a name="opts-symbol-iterator"></a> `> opts[Symbol.iterator]() -> Iterator<[[key, value], ...]>` + +Returns an iterator that iterates over the keys and values in `opts`, limited to +the keys readable by the current pudding type. Each iteration returns an array +of `[key, value]`. Makes puddings work natively with JS iteration mechanisms. + +##### Example + +```js +const opts = MyOpts({x: 1, y: 2}) +[...opts({x: 1, y: 2})] // [['x', 1], ['y', 2]] +for (let [key, value] of opts({x: 1, y: 2})) { + console.log(key, '=', value) +} +``` + +#### <a name="opts-keys"></a> `> opts.keys() -> Iterator<[key, ...]>` + +Returns an iterator that iterates over the keys in `opts`, limited to the keys +readable by the current pudding type. + +##### Example + +```js +const opts = MyOpts({x: 1, y: 2}) +[...opts({x: 1, y: 2}).keys()] // ['x', 'y'] +``` + +#### <a name="opts-values"></a> `> opts.values() -> Iterator<[value, ...]>` + +Returns an iterator that iterates over the values in `opts`, limited to the keys +readable by the current pudding type. + +##### Example +' +```js +const opts = MyOpts({x: 1, y: 2}) +[...opts({x: 1, y: 2}).values()] // [1, 2] +``` diff --git a/node_modules/figgy-pudding/index.js b/node_modules/figgy-pudding/index.js new file mode 100644 index 0000000..bb7d571 --- /dev/null +++ b/node_modules/figgy-pudding/index.js @@ -0,0 +1,197 @@ +'use strict' + +class FiggyPudding { + constructor (specs, opts, providers) { + this.__specs = specs || {} + Object.keys(this.__specs).forEach(alias => { + if (typeof this.__specs[alias] === 'string') { + const key = this.__specs[alias] + const realSpec = this.__specs[key] + if (realSpec) { + const aliasArr = realSpec.aliases || [] + aliasArr.push(alias, key) + realSpec.aliases = [...(new Set(aliasArr))] + this.__specs[alias] = realSpec + } else { + throw new Error(`Alias refers to invalid key: ${key} -> ${alias}`) + } + } + }) + this.__opts = opts || {} + this.__providers = reverse((providers).filter( + x => x != null && typeof x === 'object' + )) + this.__isFiggyPudding = true + } + 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) : 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, + this.__opts, + reverse(this.__providers).concat(moreConfig) + ), 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))) { + BadKeyError(key) + } else { + if (!spec) { spec = {} } + let ret + for (let p of pud.__providers) { + ret = tryGet(key, p) + if (ret === undefined && spec.aliases && spec.aliases.length) { + for (let alias of spec.aliases) { + if (alias === key) { continue } + ret = tryGet(alias, p) + if (ret !== undefined) { + break + } + } + } + if (ret !== undefined) { + break + } + } + if (ret === undefined && spec.default !== undefined) { + if (typeof spec.default === 'function') { + return spec.default(pud) + } else { + return spec.default + } + } else { + return ret + } + } +} + +function tryGet (key, p) { + let ret + if (p.__isFiggyPudding) { + ret = pudGet(p, key, false) + } else if (typeof p.get === 'function') { + ret = p.get(key) + } else { + ret = p[key] + } + return ret +} + +const proxyHandler = { + has (obj, prop) { + return prop in obj.__specs && pudGet(obj, prop, false) !== undefined + }, + ownKeys (obj) { + return Object.keys(obj.__specs) + }, + get (obj, prop) { + if ( + typeof prop === 'symbol' || + prop.slice(0, 2) === '__' || + prop in FiggyPudding.prototype + ) { + return obj[prop] + } + return obj.get(prop) + }, + set (obj, prop, value) { + 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.') + } + }, + deleteProperty () { + throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.') + } +} + +module.exports = figgyPudding +function figgyPudding (specs, opts) { + function factory (...providers) { + return new Proxy(new FiggyPudding( + specs, + opts, + providers + ), proxyHandler) + } + return factory +} + +function reverse (arr) { + const ret = [] + arr.forEach(x => ret.unshift(x)) + return ret +} + +function entries (obj) { + return Object.keys(obj).map(k => [k, obj[k]]) +} diff --git a/node_modules/figgy-pudding/package.json b/node_modules/figgy-pudding/package.json new file mode 100644 index 0000000..f7d1ff7 --- /dev/null +++ b/node_modules/figgy-pudding/package.json @@ -0,0 +1,67 @@ +{ + "_from": "figgy-pudding@^3.5.1", + "_id": "figgy-pudding@3.5.2", + "_inBundle": false, + "_integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw==", + "_location": "/figgy-pudding", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "figgy-pudding@^3.5.1", + "name": "figgy-pudding", + "escapedName": "figgy-pudding", + "rawSpec": "^3.5.1", + "saveSpec": null, + "fetchSpec": "^3.5.1" + }, + "_requiredBy": [ + "/terser-webpack-plugin/cacache", + "/terser-webpack-plugin/ssri" + ], + "_resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", + "_shasum": "b4eee8148abb01dcf1d1ac34367d59e12fa61d6e", + "_spec": "figgy-pudding@^3.5.1", + "_where": "/home/pruss/Dev/3-minute-website/node_modules/terser-webpack-plugin/node_modules/cacache", + "author": { + "name": "Kat Marchán", + "email": "kzm@sykosomatic.org" + }, + "bugs": { + "url": "https://github.com/npm/figgy-pudding/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Delicious, festive, cascading config/opts definitions", + "devDependencies": { + "standard": "^11.0.1", + "standard-version": "^4.4.0", + "tap": "^12.0.1" + }, + "files": [ + "*.js", + "lib" + ], + "homepage": "https://github.com/npm/figgy-pudding#readme", + "keywords": [ + "config", + "options", + "yummy" + ], + "license": "ISC", + "main": "index.js", + "name": "figgy-pudding", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/figgy-pudding.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 --coverage test/*.js" + }, + "version": "3.5.2" +} |