From 0c9e7b47cd7ebab885c417b22e57f1e53a34a631 Mon Sep 17 00:00:00 2001 From: Oleg Galaburda Date: Fri, 20 Jul 2018 13:02:19 +0300 Subject: [PATCH 1/5] add descendants() augmentation, fixes --- .gitignore | 1 + .vscode/settings.json | 2 + bower.json | 44 - dist/tree-walker.js | 118 +- dist/tree-walker.js.map | 2 +- dist/tree-walker.min.js | 2 +- dist/tree-walker.min.js.map | 2 +- example/index.html | 110 +- example/onode-adapter.js | 24 + example/onode.js | 32 + example/tree-walker.min.js | 2 + example/tree-walker.min.js.map | 1 + fixtures/test-adapter.js | 26 + fixtures/tree.js | 55 + package-lock.json | 3066 ++++++++++++------------ package.json | 2 +- source/__tests__/prefixes.js | 0 source/__tests__/utils.js | 0 source/__tests__/wrapper.js | 0 source/augmentations/__tests__/core.js | 0 source/augmentations/__tests__/list.js | 0 source/augmentations/__tests__/node.js | 0 source/augmentations/list.js | 78 +- source/augmentations/node.js | 52 +- source/prefixes.js | 20 +- source/stub-adapter.js | 3 +- 26 files changed, 1959 insertions(+), 1683 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 bower.json create mode 100644 example/onode-adapter.js create mode 100644 example/onode.js create mode 100644 example/tree-walker.min.js create mode 100644 example/tree-walker.min.js.map create mode 100644 fixtures/test-adapter.js create mode 100644 fixtures/tree.js create mode 100644 source/__tests__/prefixes.js create mode 100644 source/__tests__/utils.js create mode 100644 source/__tests__/wrapper.js create mode 100644 source/augmentations/__tests__/core.js create mode 100644 source/augmentations/__tests__/list.js create mode 100644 source/augmentations/__tests__/node.js diff --git a/.gitignore b/.gitignore index d7fdf3e..4591a01 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Thumbs.db ehthumbs.db .idea/ +.history/ bower_components/ node_modules/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index b026c2e..0000000 --- a/bower.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "js-lib-environment", - "description": "", - "version": "0.0.0", - "main": [ - "dist/lib.direct.js" - ], - "moduleType": [ - "globals" - ], - "license": "MIT", - "authors": [ - "Oleg Galaburda (http://actualwave.com/)" - ], - "ignore": [ - "**/.*", - "tests", - "karma.conf.js", - "package.json", - "server.js", - "node_modules", - "bower_components", - "webpack.config.js", - "webpack.config.main.js", - "webpack.helpers.js" - ], - "keywords": [ - "events", - "object", - "fire", - "handle", - "listener", - "dispatcher" - ], - "homepage": "https://github.com/burdiuz/js-event-dispatcher", - "repository": { - "type": "git", - "url": "git://github.com/burdiuz/js-event-dispatcher.git" - }, - "dependencies": { - }, - "devDependencies": { - } -} diff --git a/dist/tree-walker.js b/dist/tree-walker.js index 7d6a204..6de4727 100644 --- a/dist/tree-walker.js +++ b/dist/tree-walker.js @@ -169,6 +169,7 @@ var coreAugmentations = { [Symbol.toPrimitive]: node => node }; +/* eslint-disable prefer-spread */ const children = (node, adapter, [childName], utils) => { let list; @@ -181,6 +182,53 @@ const children = (node, adapter, [childName], utils) => { return utils.wrap(list, adapter); }; +/** + * @internal + */ +const descendantsAll = (node, adapter, args, utils) => { + const result = []; + const list = adapter.getChildren(node); + const length = adapter.getLength(list, adapter); + + for (let index = 0; index < length; index += 1) { + const child = list[index]; + result.push(child); + result.push.apply(result, descendantsAll(child, adapter, args, utils)); + } + + return result; +}; + +/** + * @internal + */ +const descendantsByName = (node, adapter, args, utils) => { + const [childName] = args; + const result = []; + const list = adapter.getChildren(node); + const length = adapter.getLength(list, adapter); + + for (let index = 0; index < length; index += 1) { + const child = list[index]; + if (adapter.getName(child) === childName) { + result.push(child); + } + result.push.apply(result, descendantsByName(child, adapter, args, utils)); + } + + return result; +}; + +const descendants = (node, adapter, args, utils) => { + const [childName] = args; + + if (childName) { + return utils.wrap(descendantsByName(node, adapter, args, utils), adapter); + } + + return utils.wrap(descendantsAll(node, adapter, args, utils), adapter); +}; + const childAt = (node, adapter, [index = 0], utils) => utils.wrap(adapter.getChildAt(node, index), adapter); const root = (node, adapter, args, utils) => utils.wrap(adapter.getNodeRoot(node), adapter); @@ -189,6 +237,7 @@ const parent = (node, adapter, args, utils) => utils.wrap(adapter.getNodeParent( var node = { children, + descendants, childAt, root, parent @@ -200,38 +249,45 @@ const length = (node, adapter) => { } else if (adapter.isNode(node)) { return 1; } + return 0; }; -const first = (node, adapter, args, utils) => { - let result = node; +const at = (node, adapter, args, utils) => { + const [index] = args; + // return empty array, which will create empty wrapper for chained calls, + // this will make next calls errorless. + let result = []; if (adapter.isList(node)) { - if (node.length) { - [result] = node; - } else { - result = []; + const child = adapter.getNodeAt(node, index); + + if (child) { + result = child; } } return utils.wrap(result, adapter); }; +const first = (node, adapter, args, utils) => at(node, adapter, [0], utils); + const filter = (node, adapter, [callback], utils) => { // apply filter on element collection // always return wrapped list - node = adapter.toList(node); - const list = []; + const list = adapter.toList(node); + const listLength = adapter.getLength(node); + const result = []; - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); if (callback(utils.wrap(child, adapter), index, wrappedNode)) { - list.push(child); + result.push(child); } } - return utils.wrap(list, adapter); + return utils.wrap(result, adapter); }; const map = (node, adapter, [callback, wrapNodes = true], utils) => { @@ -239,36 +295,40 @@ const map = (node, adapter, [callback, wrapNodes = true], utils) => { // if wrapNodes in FALSE, will generate normal Array with RAW results in it // if wrapNodes in TRUE and all elements of resulting list are nodes, will // generate wrapped list and put all result into it - node = adapter.toList(node); - const list = []; + const list = adapter.toList(node); + const listLength = adapter.getLength(list); + const result = []; let areNodes = true; - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; - const result = callback(utils.wrap(child, adapter), index, wrappedNode); - areNodes = areNodes && adapter.isNode(result); - list.push(result); + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); + const childResult = callback(utils.wrap(child, adapter), index, wrappedNode); + areNodes = areNodes && adapter.isNode(childResult); + result.push(childResult); } - return wrapNodes && areNodes ? utils.wrap(list, adapter) : list; + return wrapNodes && areNodes ? utils.wrap(result, adapter) : result; }; const reduce = (node, adapter, [callback, result], utils) => { // apply reduce on element collection - node = adapter.toList(node); - - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; - result = callback(result, utils.wrap(child, adapter), index, wrappedNode); + const list = adapter.toList(node); + const listLength = adapter.getLength(node); + let lastResult = result; + + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); + lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode); } - return result; + return lastResult; }; var list = { length, + at, first, filter, map, diff --git a/dist/tree-walker.js.map b/dist/tree-walker.js.map index a5639de..28f6d04 100644 --- a/dist/tree-walker.js.map +++ b/dist/tree-walker.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof(key) === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","const children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\n\r\nexport default {\r\n children,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n return 0;\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => {\r\n let result = node;\r\n\r\n if (adapter.isList(node)) {\r\n if (node.length) {\r\n ([result] = node);\r\n } else {\r\n result = [];\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n node = adapter.toList(node);\r\n const list = [];\r\n\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n list.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n node = adapter.toList(node);\r\n const list = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n const result = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(result);\r\n list.push(result);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(list, adapter) : list;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n node = adapter.toList(node);\r\n\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n result = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nexport default {\r\n length,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","getValue","node","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","createWalkerNode","TreeWalker","wrap","isNode","Proxy","get","substr","has","hasChild","apply","thisArg","argumentsList","toString","valueOf","Symbol","toPrimitive","children","list","getChildren","childAt","index","getChildAt","root","getNodeRoot","parent","getNodeParent","getLength","first","result","filter","callback","wrappedNode","child","push","map","wrapNodes","areNodes","reduce","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,iBAAiB,IAArB;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC,oBAAoB,MAAMH,cAAhC;;ACLP,MAAMI,eAAe,EAArB;;AAEA,MAAaC,gBAAiBC,MAAD,IAC3B,OAAOA,MAAP,KAAkB,QAAlB,IACGA,OAAOC,MAAP,KAAkB,CADrB,IAEGH,aAAaI,cAAb,CAA4BF,MAA5B,CAHE;;AAMP,AAAO,MAAMG,gBAAiBC,GAAD,IAC3BA,OACG,OAAOA,GAAP,KAAgB,QADnB,IAEGA,IAAIH,MAAJ,GAAa,CAFhB,IAGGH,aAAaI,cAAb,CAA4BE,IAAIC,MAAJ,EAA5B,CAJE;;AAOP,AAAO,MAAMC,mBAAoBF,GAAD,IAASN,aAAaM,IAAIC,MAAJ,EAAb,CAAlC;;AAEP,MAAaE,gBAAgB,CAACP,MAAD,EAASQ,OAAT,KAAqB;MAC5C,OAAOR,MAAP,KAAkB,QAAlB,IAA8BA,OAAOC,MAAP,KAAkB,CAApD,EAAuD;UAC/C,IAAIQ,KAAJ,CAAU,2CAAV,CAAN;;;eAGWT,MAAb,IAAuBQ,OAAvB;CALK;;ACjBA,MAAME,WAAYN,GAAD,IAAW,GAAEO,SAASP,GAAT,EA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We,IAAX,EAAiBrD,OAAjB,CAAxB,GAAoDqD,IAA3D;CAjBF;;AAoBA,MAAMoB,SAAS,CAACxD,IAAD,EAAOjB,OAAP,EAAgB,CAACkE,QAAD,EAAWF,MAAX,CAAhB,EAAoC7B,KAApC,KAA8C;;SAEpDnC,QAAQ0B,MAAR,CAAeT,IAAf,CAAP;;QAEMkD,cAAchC,MAAMG,IAAN,CAAWrB,IAAX,EAAiBjB,OAAjB,CAApB;OACK,IAAIwD,QAAQ,CAAjB,EAAoBA,QAAQvC,KAAKZ,MAAjC,EAAyCmD,SAAS,CAAlD,EAAqD;UAC7CY,QAAQnD,KAAKuC,KAAL,CAAd;aACSU,SAASF,MAAT,EAAiB7B,MAAMG,IAAN,CAAW8B,KAAX,EAAkBpE,OAAlB,CAAjB,EAA6CwD,KAA7C,EAAoDW,WAApD,CAAT;;;SAGKH,MAAP;CAVF;;AAaA,WAAe;QAAA;OAAA;QAAA;KAAA;;CAAf;;ACjEAlC,iBAAiB4C,iBAAjB;;AAEA,MAAMC,SAAS,CAACjB,IAAD,EAAO1D,UAAUC,mBAAjB,KACbqC,KAAKtC,QAAQ4E,YAAR,CAAqBlB,IAArB,CAAL,EAAiC1D,OAAjC,CADF;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","getValue","node","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","createWalkerNode","TreeWalker","wrap","isNode","Proxy","get","substr","has","hasChild","apply","thisArg","argumentsList","toString","valueOf","Symbol","toPrimitive","children","list","getChildren","descendantsAll","result","getLength","index","child","push","descendantsByName","getName","descendants","childAt","getChildAt","root","getNodeRoot","parent","getNodeParent","at","first","filter","callback","listLength","wrappedNode","map","wrapNodes","areNodes","childResult","reduce","lastResult","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,iBAAiB,IAArB;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC,oBAAoB,MAAMH,cAAhC;;ACLP,MAAMI,eAAe,EAArB;;AAEA,MAAaC,gBAAiBC,MAAD,IAC3B,OAAOA,MAAP,KAAkB,QAAlB,IACGA,OAAOC,MAAP,KAAkB,CADrB,IAEGH,aAAaI,cAAb,CAA4BF,MAA5B,CAHE;;AAMP,AAAO,MAAMG,gBAAiBC,GAAD,IAC3BA,OACG,OAAOA,GAAP,KAAe,QADlB,IAEGA,IAAIH,MAAJ,GAAa,CAFhB,IAGGH,aAAaI,cAAb,CAA4BE,IAAIC,MAAJ,EAA5B,CAJE;;AAOP,AAAO,MAAMC,mBAAoBF,GAAD,IAASN,aAAaM,IAAIC,MAAJ,EAAb,CAAlC;;AAEP,MAAaE,gBAAgB,CAACP,MAAD,EAASQ,OAAT,KAAqB;MAC5C,OAAOR,MAAP,KAAkB,QAAlB,IAA8BA,OAAOC,MAAP,KAAkB,CAApD,EAAuD;UAC/C,IAAIQ,KAAJ,CAAU,2CAAV,CAAN;;;eAGWT,MAAb,IAAuBQ,OAAvB;CALK;;ACjBA,MAAME,WAAYN,GAAD,IAAW,GAAEO,SAASP,GAAT,EAAc,EAAd,CAAkB,EAArB,KAA2BA,GAAtD;;AAEP,AAAO,MAAMQ,WAAW,CAACC,IAAD,EAAOjB,OAAP,EAAgBkB,YAAYC,SAA5B,KAA0C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AoDiB,WAApD,CAAb;;;SAGKM,UAAP;CAZF;;AAeA,WAAe;QAAA;IAAA;OAAA;QAAA;KAAA;;CAAf;;AC3EAnD,iBAAiBoD,iBAAjB;;AAEA,MAAMC,SAAS,CAACjB,IAAD,EAAOlE,UAAUC,mBAAjB,KACbqC,KAAKtC,QAAQoF,YAAR,CAAqBlB,IAArB,CAAL,EAAiClE,OAAjC,CADF;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/tree-walker.min.js b/dist/tree-walker.min.js index ea02fbf..347e51e 100644 --- a/dist/tree-walker.min.js +++ b/dist/tree-walker.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t=null;const r=()=>t,n={},o=e=>"string"==typeof e&&1===e.length&&n.hasOwnProperty(e),a=e=>e&&"string"==typeof e&&e.length>1&&n.hasOwnProperty(e.charAt()),i=e=>n[e.charAt()],s=e=>`${parseInt(e,10)}`===e,l=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,d=(e,t,r)=>{const n=l(e,t,r);return t.isList(n)?t.getNodeAt(e):n},p=(e,t,r)=>t.toList(l(e,t,r));let g={};const u=(e={})=>{g=Object.assign({},g,e)},h=e=>e&&"string"==typeof e&&g.hasOwnProperty(e);let c,f;const w=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function n(){throw new Error("Should have been never called")}return n.node=e,n.childName=r,n.adapter=t,n})(e,t,r),c):e;f={isIntKey:s,getValue:l,getSingleNode:d,getNodeList:p,wrap:w};c={get:({node:e,adapter:t,childName:r},n)=>{if(s(n))return w(t.getNodeAt(p(e,t,r),n),t);if(a(n))return i(n)(l(e,t,r),t,[n.substr(1)],f);return w(l(e,t,r),t,n)},has:({node:e,adapter:t,childName:r},n)=>s(n)?!!t.getNodeAt(p(e,t,r),n):!!a(n)||t.hasChild(d(),n),apply:({node:e,adapter:t,childName:r},n,a)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(o(r))return i(r)(e,t,a,f);if(h(r))return((e,...t)=>g[e](...t))(r,e,t,a,f);throw new Error(`"${r}" is not a callable object.`)}};var m={toString:e=>e.toString(),valueOf:e=>e,[Symbol.toPrimitive]:e=>e};var N={children:(e,t,[r],n)=>{let o;return o=r?t.getChildrenByName(e,r):t.getChildren(e),n.wrap(o,t)},childAt:(e,t,[r=0],n)=>n.wrap(t.getChildAt(e,r),t),root:(e,t,r,n)=>n.wrap(t.getNodeRoot(e),t),parent:(e,t,r,n)=>n.wrap(t.getNodeParent(e),t)};var y={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,first:(e,t,r,n)=>{let o=e;return t.isList(e)&&(e.length?[o]=e:o=[]),n.wrap(o,t)},filter:(e,t,[r],n)=>{e=t.toList(e);const o=[],a=n.wrap(e,t);for(let i=0;i{e=t.toList(e);const a=[];let i=!0;const s=o.wrap(e,t);for(let n=0;n{e=t.toList(e);const a=o.wrap(e,t);for(let i=0;iw(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=u,e.hasAugmentation=h,e.resetAugmentations=((e={})=>{g=e}),e.coreAugmentations=m,e.nodeAugmentations=N,e.listAugmentations=y,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");n[e]=t}),e.isValidPrefix=o,e.create=A,e.default=A,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TreeWalker={})}(this,function(t){"use strict";let e=null;const r=()=>e,n={},o=t=>"string"==typeof t&&1===t.length&&n.hasOwnProperty(t),a=t=>t&&"string"==typeof t&&t.length>1&&n.hasOwnProperty(t.charAt()),s=t=>n[t.charAt()],i=t=>`${parseInt(t,10)}`===t,d=(t,e,r)=>void 0!==r?e.getChildrenByName(t,r):t,l=(t,e,r)=>{const n=d(t,e,r);return e.isList(n)?e.getNodeAt(t):n},g=(t,e,r)=>e.toList(d(t,e,r));let p={};const c=(t={})=>{p=Object.assign({},p,t)},u=t=>t&&"string"==typeof t&&p.hasOwnProperty(t);let h,f;const w=(t,e,r)=>e.isNode(t)||e.isList(t)?new Proxy(((t,e,r)=>{function n(){throw new Error("Should have been never called")}return n.node=t,n.childName=r,n.adapter=e,n})(t,e,r),h):t;f={isIntKey:i,getValue:d,getSingleNode:l,getNodeList:g,wrap:w};h={get:({node:t,adapter:e,childName:r},n)=>{if(i(n))return w(e.getNodeAt(g(t,e,r),n),e);if(a(n))return s(n)(d(t,e,r),e,[n.substr(1)],f);return w(d(t,e,r),e,n)},has:({node:t,adapter:e,childName:r},n)=>i(n)?!!e.getNodeAt(g(t,e,r),n):!!a(n)||e.hasChild(l(),n),apply:({node:t,adapter:e,childName:r},n,a)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(o(r))return s(r)(t,e,a,f);if(u(r))return((t,...e)=>p[t](...e))(r,t,e,a,f);throw new Error(`"${r}" is not a callable object.`)}};var N={toString:t=>t.toString(),valueOf:t=>t,[Symbol.toPrimitive]:t=>t};const m=(t,e,r,n)=>{const o=[],a=e.getChildren(t),s=e.getLength(a,e);for(let t=0;t{const[o]=r,a=[],s=e.getChildren(t),i=e.getLength(s,e);for(let t=0;t{let o;return o=r?e.getChildrenByName(t,r):e.getChildren(t),n.wrap(o,e)},descendants:(t,e,r,n)=>{const[o]=r;return o?n.wrap(y(t,e,r,n),e):n.wrap(m(t,e,r,n),e)},childAt:(t,e,[r=0],n)=>n.wrap(e.getChildAt(t,r),e),root:(t,e,r,n)=>n.wrap(e.getNodeRoot(t),e),parent:(t,e,r,n)=>n.wrap(e.getNodeParent(t),e)};const L=(t,e,r,n)=>{const[o]=r;let a=[];if(e.isList(t)){const r=e.getNodeAt(t,o);r&&(a=r)}return n.wrap(a,e)};var v={length:(t,e)=>e.isList(t)?e.getLength(t):e.isNode(t)?1:0,at:L,first:(t,e,r,n)=>L(t,e,[0],n),filter:(t,e,[r],n)=>{const o=e.toList(t),a=e.getLength(t),s=[],i=n.wrap(o,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(a),i=[];let d=!0;const l=o.wrap(a,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(t);let i=n;const d=o.wrap(a,e);for(let t=0;tw(e.validateRoot(t),e);t.setDefaultAdapter=(t=>{e=t}),t.getDefaultAdapter=r,t.addAugmentations=c,t.hasAugmentation=u,t.resetAugmentations=((t={})=>{p=t}),t.coreAugmentations=N,t.nodeAugmentations=A,t.listAugmentations=v,t.setNamePrefix=((t,e)=>{if("string"!=typeof t||1!==t.length)throw new Error("Name Prefix must be one character string.");n[t]=e}),t.isValidPrefix=o,t.create=P,t.default=P,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=tree-walker.min.js.map diff --git a/dist/tree-walker.min.js.map b/dist/tree-walker.min.js.map index f29e9ea..bb13cf6 100644 --- a/dist/tree-walker.min.js.map +++ b/dist/tree-walker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof(key) === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","const children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\n\r\nexport default {\r\n children,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n return 0;\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => {\r\n let result = node;\r\n\r\n if (adapter.isList(node)) {\r\n if (node.length) {\r\n ([result] = node);\r\n } else {\r\n result = [];\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n node = adapter.toList(node);\r\n const list = [];\r\n\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n list.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n node = adapter.toList(node);\r\n const list = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n const result = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(result);\r\n list.push(result);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(list, adapter) : list;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n node = adapter.toList(node);\r\n\r\n const wrappedNode = utils.wrap(node, adapter);\r\n for (let index = 0; index < node.length; index += 1) {\r\n const child = node[index];\r\n result = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nexport default {\r\n length,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handlers","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","list","getChildren","index","getChildAt","getNodeRoot","getNodeParent","getLength","result","callback","wrappedNode","child","push","wrapNodes","areNodes","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,EAAiB,WAKRC,EAAoB,IAAMD,ECLjCE,KAEOC,EAAiBC,GACV,iBAAXA,GACc,IAAlBA,EAAOC,QACPH,EAAaI,eAAeF,GAGpBG,EAAiBC,GAC5BA,GACmB,iBAATA,GACPA,EAAIH,OAAS,GACbH,EAAaI,eAAeE,EAAIC,UAGxBC,EAAoBF,GAAQN,EAAaM,EAAIC,UCf7CE,EAAYH,MAAYI,SAASJ,EAAK,QAAUA,EAEhDK,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,WACrCI,EAAQP,EAASC,EAAMC,EAASC,UAElCD,EAAQM,OAAOD,GACVL,EAAQO,UAAUR,GAGpBM,GAGIG,EAAc,CAACT,EAAMC,EAASC,IAClCD,EAAQS,OAAOX,EAASC,EAAMC,EAASC,ICrBhD,IAAIS,WAMSC,EAAmB,CAACC,2BAE1BF,EACAE,IAIMC,EAAmBpB,GAC9BA,GACkB,iBAARA,GACPiB,EAAcnB,eAAeE,SCG9BqB,EAEJ,MAeMC,EAAO,CAAChB,EAAMC,EAASC,IACtBD,EAAQgB,OAAOjB,IAAUC,EAAQM,OAAOP,GAItC,IAAIkB,MApBY,EAAClB,EAAMC,EAASC,cAC9BiB,UACD,IAAIC,MAAM,0CAKPpB,KAA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VM,EAASD,EAAQzB,EAAMC,KAAK2B,EAAO1C,GAAUkC,EAAOO,UAGxDF,MC9DQO,SAEXC,EAAS,CAACC,EAAMhD,EAAUd,MAC9B6B,EAAKf,EAAQiD,aAAaD,GAAOhD,uBRTDA,CAAAA,MACfA,wFGDe,EAACY,UACjBA,sFFcW,EAACvB,EAAQiC,QACd,iBAAXjC,GAAyC,IAAlBA,EAAOC,aACjC,IAAI6B,MAAM,+CAGL9B,GAAUiC"} \ No newline at end of file +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,EAAiB,WAKRC,EAAoB,IAAMD,ECLjCE,KAEOC,EAAiBC,GACV,iBAAXA,GACc,IAAlBA,EAAOC,QACPH,EAAaI,eAAeF,GAGpBG,EAAiBC,GAC5BA,GACkB,iBAARA,GACPA,EAAIH,OAAS,GACbH,EAAaI,eAAeE,EAAIC,UAGxBC,EAAoBF,GAAQN,EAAaM,EAAIC,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AAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQtC,EAAQO,UAAU2B,EAAMG,GAChCe,EAAcL,EAAShC,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,KACrDE,GAAYnD,EAAQiB,OAAOmC,KAC/Bb,KAAKa,UAGPF,GAAaC,EAAWpC,EAAMC,KAAKiB,EAAQjC,GAAWiC,UAGhD,CAAClC,EAAMC,GAAU+C,EAAUd,GAASlB,WAE3CmB,EAAOlC,EAAQS,OAAOV,GACtBiD,EAAahD,EAAQoC,UAAUrC,OACjCsD,EAAapB,QAEXgB,EAAclC,EAAMC,KAAKkB,EAAMlC,OAChC,IAAIqC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQtC,EAAQO,UAAU2B,EAAMG,KACzBU,EAASd,EAAQlB,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,UAG5DI,ICxET1C,EAAiB2C,SAEXC,EAAS,CAACC,EAAMxD,EAAUd,MAC9B8B,EAAKhB,EAAQyD,aAAaD,GAAOxD,uBRTDA,CAAAA,MACfA,wFGDe,EAACY,UACjBA,sFFcW,EAACvB,EAAQiC,QACd,iBAAXjC,GAAyC,IAAlBA,EAAOC,aACjC,IAAI8B,MAAM,+CAGL/B,GAAUiC"} \ No newline at end of file diff --git a/example/index.html b/example/index.html index 2b48169..c5bb549 100644 --- a/example/index.html +++ b/example/index.html @@ -1,46 +1,96 @@ + Example - + - - + + + + + -

Tree Walker

-
-

Hello world!

-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +

Tree Walker

+

+ Please, check console for results. +

+ diff --git a/example/onode-adapter.js b/example/onode-adapter.js new file mode 100644 index 0000000..2aec872 --- /dev/null +++ b/example/onode-adapter.js @@ -0,0 +1,24 @@ +((target) => { + const adapter = { + validateRoot: (item) => item, + + // list methods + isList: (item) => item instanceof Array, + toList: (item) => adapter.isList(item) ? item : [item], + getLength: (item) => adapter.toList(item).length, + getNodeAt: (item, index) => adapter.toList(item)[index], + + // node methods + isNode: (item) => item instanceof Object && !adapter.isList(item), + toNode: (item) => adapter.isList(item) ? item[0] : item, + getName: (item) => adapter.toNode(item).name, + hasChild: (item, name) => !!adapter.getChildrenByName(item, name).length, + getChildren: (item) => adapter.toNode(item).children, + getChildrenByName: (item, name) => adapter.toNode(item).children.filter((child) => adapter.getName(child) === name), + getChildAt: (item, index) => adapter.toNode(item).children[index], + getNodeParent: (item) => adapter.toNode(item).parent, + getNodeRoot: (item) => adapter.toNode(item).root, + }; + + target.ONodeAdapter = adapter; +})(window); diff --git a/example/onode.js b/example/onode.js new file mode 100644 index 0000000..08fab69 --- /dev/null +++ b/example/onode.js @@ -0,0 +1,32 @@ +((target) => { + class ONode { + constructor(name, parent, root) { + this.name = name; + this.children = []; + this.parent = parent; + this.root = root; + } + + toString() { + return `[ONode name="${this.name}" level="${this.level}"]`; + } + }; + + const parseONodes = (obj, name = '#root', parent = undefined, root = undefined) => { + const node = new ONode(name, parent, root); + Object.assign(node, obj.data); + const children = []; + + Object.keys(obj).forEach((key) => { + if (key !== 'data') { + children.push(parseONodes(obj[key], key, node, root || node)); + } + }); + + node.children = children; + + return node; + }; + + target.parseONodes = parseONodes; +})(window); diff --git a/example/tree-walker.min.js b/example/tree-walker.min.js new file mode 100644 index 0000000..347e51e --- /dev/null +++ b/example/tree-walker.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TreeWalker={})}(this,function(t){"use strict";let e=null;const r=()=>e,n={},o=t=>"string"==typeof t&&1===t.length&&n.hasOwnProperty(t),a=t=>t&&"string"==typeof t&&t.length>1&&n.hasOwnProperty(t.charAt()),s=t=>n[t.charAt()],i=t=>`${parseInt(t,10)}`===t,d=(t,e,r)=>void 0!==r?e.getChildrenByName(t,r):t,l=(t,e,r)=>{const n=d(t,e,r);return e.isList(n)?e.getNodeAt(t):n},g=(t,e,r)=>e.toList(d(t,e,r));let p={};const c=(t={})=>{p=Object.assign({},p,t)},u=t=>t&&"string"==typeof t&&p.hasOwnProperty(t);let h,f;const w=(t,e,r)=>e.isNode(t)||e.isList(t)?new Proxy(((t,e,r)=>{function n(){throw new Error("Should have been never called")}return n.node=t,n.childName=r,n.adapter=e,n})(t,e,r),h):t;f={isIntKey:i,getValue:d,getSingleNode:l,getNodeList:g,wrap:w};h={get:({node:t,adapter:e,childName:r},n)=>{if(i(n))return w(e.getNodeAt(g(t,e,r),n),e);if(a(n))return s(n)(d(t,e,r),e,[n.substr(1)],f);return w(d(t,e,r),e,n)},has:({node:t,adapter:e,childName:r},n)=>i(n)?!!e.getNodeAt(g(t,e,r),n):!!a(n)||e.hasChild(l(),n),apply:({node:t,adapter:e,childName:r},n,a)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(o(r))return s(r)(t,e,a,f);if(u(r))return((t,...e)=>p[t](...e))(r,t,e,a,f);throw new Error(`"${r}" is not a callable object.`)}};var N={toString:t=>t.toString(),valueOf:t=>t,[Symbol.toPrimitive]:t=>t};const m=(t,e,r,n)=>{const o=[],a=e.getChildren(t),s=e.getLength(a,e);for(let t=0;t{const[o]=r,a=[],s=e.getChildren(t),i=e.getLength(s,e);for(let t=0;t{let o;return o=r?e.getChildrenByName(t,r):e.getChildren(t),n.wrap(o,e)},descendants:(t,e,r,n)=>{const[o]=r;return o?n.wrap(y(t,e,r,n),e):n.wrap(m(t,e,r,n),e)},childAt:(t,e,[r=0],n)=>n.wrap(e.getChildAt(t,r),e),root:(t,e,r,n)=>n.wrap(e.getNodeRoot(t),e),parent:(t,e,r,n)=>n.wrap(e.getNodeParent(t),e)};const L=(t,e,r,n)=>{const[o]=r;let a=[];if(e.isList(t)){const r=e.getNodeAt(t,o);r&&(a=r)}return n.wrap(a,e)};var v={length:(t,e)=>e.isList(t)?e.getLength(t):e.isNode(t)?1:0,at:L,first:(t,e,r,n)=>L(t,e,[0],n),filter:(t,e,[r],n)=>{const o=e.toList(t),a=e.getLength(t),s=[],i=n.wrap(o,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(a),i=[];let d=!0;const l=o.wrap(a,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(t);let i=n;const d=o.wrap(a,e);for(let t=0;tw(e.validateRoot(t),e);t.setDefaultAdapter=(t=>{e=t}),t.getDefaultAdapter=r,t.addAugmentations=c,t.hasAugmentation=u,t.resetAugmentations=((t={})=>{p=t}),t.coreAugmentations=N,t.nodeAugmentations=A,t.listAugmentations=v,t.setNamePrefix=((t,e)=>{if("string"!=typeof t||1!==t.length)throw new Error("Name Prefix must be one character string.");n[t]=e}),t.isValidPrefix=o,t.create=P,t.default=P,Object.defineProperty(t,"__esModule",{value:!0})}); +//# sourceMappingURL=tree-walker.min.js.map diff --git a/example/tree-walker.min.js.map b/example/tree-walker.min.js.map new file mode 100644 index 0000000..bb13cf6 --- /dev/null +++ b/example/tree-walker.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,EAAiB,WAKRC,EAAoB,IAAMD,ECLjCE,KAEOC,EAAiBC,GACV,iBAAXA,GACc,IAAlBA,EAAOC,QACPH,EAAaI,eAAeF,GAGpBG,EAAiBC,GAC5BA,GACkB,iBAARA,GACPA,EAAIH,OAAS,GACbH,EAAaI,eAAeE,EAAIC,UAGxBC,EAAoBF,GAAQN,EAAaM,EAAIC,UCf7CE,EAAYH,MAAYI,SAASJ,EAAK,QAAUA,EAEhDK,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,WACrCI,EAAQP,EAASC,EAAMC,EAASC,UAElCD,EAAQM,OAAOD,GACVL,EAAQO,UAAUR,GAGpBM,GAGIG,EAAc,CAACT,EAAMC,EAASC,IAClCD,EAAQS,OAAOX,EAASC,EAAMC,EAASC,ICrBhD,IAAIS,WAMSC,EAAmB,CAACC,2BAE1BF,EACAE,IAIMC,EAAmBpB,GAC9BA,GACkB,iBAARA,GACPiB,EAAcnB,eAAeE,OCE9BqB,EACAC,EAEJ,MAeMC,EAAO,CAACjB,EAAMC,EAASC,IACtBD,EAAQiB,OAAOlB,IAAUC,EAAQM,OAAOP,GAItC,IAAImB,MApBY,EAACnB,EAAMC,EAASC,cAC9BkB,UACD,IAAIC,MAAM,0CAKPrB,KAAOA,IAGPE,UAAYA,IACZD,QAAUA,EACdmB,GAQUE,CAAiBtB,EAAMC,EAASC,GAAYa,GAHpDf,EAOXgB,+DAgEAD,OAxDY,EAAGf,KAAAA,EAAMC,QAAAA,EAASC,UAAAA,GAAaR,QAOrCG,EAASH,UACJuB,EAAKhB,EAAQO,UAAUC,EAAYT,EAAMC,EAASC,GAAYR,GAAMO,MAGzER,EAAcC,UACAE,EAAiBF,EAC1B6B,CAAQxB,EAASC,EAAMC,EAASC,GAAYD,GA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2B,EAAMG,GAClCU,EAAShC,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,MACvCV,KAAKD,UAITvB,EAAMC,KAAKiB,EAAQjC,QAGhB,CAACD,EAAMC,GAAU+C,EAAUG,GAAY,GAAOnC,WAKlDmB,EAAOlC,EAAQS,OAAOV,GACtBiD,EAAahD,EAAQoC,UAAUF,GAC/BD,SAEFkB,GAAW,QACTF,EAAclC,EAAMC,KAAKkB,EAAMlC,OAChC,IAAIqC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQtC,EAAQO,UAAU2B,EAAMG,GAChCe,EAAcL,EAAShC,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,KACrDE,GAAYnD,EAAQiB,OAAOmC,KAC/Bb,KAAKa,UAGPF,GAAaC,EAAWpC,EAAMC,KAAKiB,EAAQjC,GAAWiC,UAGhD,CAAClC,EAAMC,GAAU+C,EAAUd,GAASlB,WAE3CmB,EAAOlC,EAAQS,OAAOV,GACtBiD,EAAahD,EAAQoC,UAAUrC,OACjCsD,EAAapB,QAEXgB,EAAclC,EAAMC,KAAKkB,EAAMlC,OAChC,IAAIqC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQtC,EAAQO,UAAU2B,EAAMG,KACzBU,EAASd,EAAQlB,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,UAG5DI,ICxET1C,EAAiB2C,SAEXC,EAAS,CAACC,EAAMxD,EAAUd,MAC9B8B,EAAKhB,EAAQyD,aAAaD,GAAOxD,uBRTDA,CAAAA,MACfA,wFGDe,EAACY,UACjBA,sFFcW,EAACvB,EAAQiC,QACd,iBAAXjC,GAAyC,IAAlBA,EAAOC,aACjC,IAAI8B,MAAM,+CAGL/B,GAAUiC"} \ No newline at end of file diff --git a/fixtures/test-adapter.js b/fixtures/test-adapter.js new file mode 100644 index 0000000..3fac95e --- /dev/null +++ b/fixtures/test-adapter.js @@ -0,0 +1,26 @@ +// node structure: { name: string, parent: node, root: node, children: node[], ... } +const adapter = { + validateRoot: (item) => item, + + // list methods + isList: (item) => item instanceof Array, + toList: (item) => (adapter.isList(item) ? item : [item]), + getLength: (item) => adapter.toList(item).length, + getNodeAt: (item, index) => adapter.toList(item)[index], + + // node methods + isNode: (item) => !adapter.isList(item), + toNode: (item) => (adapter.isList(item) ? item[0] : item), + getName: (item) => adapter.toNode(item).name, + hasChild: (item, name) => !!adapter.getChildrenByName(item, name).length, + getChildren: (item) => adapter.toNode(item).children, + getChildrenByName: (item, name) => + adapter + .toNode(item) + .children.filter((child) => adapter.getName(child) === name), + getChildAt: (item, index) => adapter.toNode(item).children[index], + getNodeParent: (item) => adapter.toNode(item).parent, + getNodeRoot: (item) => adapter.toNode(item).root, +}; + +export default adapter; diff --git a/fixtures/tree.js b/fixtures/tree.js new file mode 100644 index 0000000..afc2e5a --- /dev/null +++ b/fixtures/tree.js @@ -0,0 +1,55 @@ +export class Node { + constructor(root, parent, name) { + this.root = root; + this.parent = parent; + this.name = name; + } +} + +export class ParentNode extends Node { + constructor(root, parent, name, children) { + super(root, parent, name); + this.children = children; + } +} + +export class ValueNode extends Node { + constructor(root, parent, name, value) { + super(root, parent, name); + this.value = value; + } +} + +export class RootNode extends ParentNode { + constructor(children = []) { + super(this, this, '#root', children); + } +} + +const construct = (value, name = '') => { + if (value instanceof Array) { + return value.map((item) => construct(item, name)); + } else if (typeof value === 'object') { + return constructList(value); + } + + return new ValueNode(); +}; + +const constructList = (data) => { + const children = []; + + Object.keys(data).map((name) => { + const value = data[name]; + }); + + return children; +}; + +const constructTree = (data) => { + const children = constructList(data); + + return new RootNode(children); +}; + +export default construct; diff --git a/package-lock.json b/package-lock.json index 2f0702d..b11344d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "js-lib-environment", - "version": "0.0.0", + "name": "@actualwave/tree-walker", + "version": "0.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -20,10 +20,10 @@ "dev": true, "requires": { "@babel/types": "7.0.0-beta.44", - "jsesc": "2.5.1", - "lodash": "4.17.4", - "source-map": "0.5.7", - "trim-right": "1.0.1" + "jsesc": "^2.5.1", + "lodash": "^4.2.0", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" }, "dependencies": { "jsesc": { @@ -69,9 +69,9 @@ "integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==", "dev": true, "requires": { - "chalk": "2.3.2", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^3.0.0" }, "dependencies": { "ansi-styles": { @@ -80,7 +80,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -89,9 +89,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -100,7 +100,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -114,7 +114,7 @@ "@babel/code-frame": "7.0.0-beta.44", "@babel/types": "7.0.0-beta.44", "babylon": "7.0.0-beta.44", - "lodash": "4.17.4" + "lodash": "^4.2.0" }, "dependencies": { "babylon": { @@ -137,10 +137,10 @@ "@babel/helper-split-export-declaration": "7.0.0-beta.44", "@babel/types": "7.0.0-beta.44", "babylon": "7.0.0-beta.44", - "debug": "3.1.0", - "globals": "11.4.0", - "invariant": "2.2.2", - "lodash": "4.17.4" + "debug": "^3.1.0", + "globals": "^11.1.0", + "invariant": "^2.2.0", + "lodash": "^4.2.0" }, "dependencies": { "babylon": { @@ -172,9 +172,9 @@ "integrity": "sha512-5eTV4WRmqbaFM3v9gHAIljEQJU4Ssc6fxL61JN+Oe2ga/BwyjzjamwkCVVAQjHGuAX8i0BWo42dshL8eO5KfLQ==", "dev": true, "requires": { - "esutils": "2.0.2", - "lodash": "4.17.4", - "to-fast-properties": "2.0.0" + "esutils": "^2.0.2", + "lodash": "^4.2.0", + "to-fast-properties": "^2.0.0" }, "dependencies": { "to-fast-properties": { @@ -203,7 +203,7 @@ "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", "dev": true, "requires": { - "acorn": "5.5.3" + "acorn": "^5.0.0" } }, "acorn-jsx": { @@ -212,7 +212,7 @@ "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { - "acorn": "3.3.0" + "acorn": "^3.0.4" }, "dependencies": { "acorn": { @@ -229,10 +229,10 @@ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "ajv-keywords": { @@ -247,9 +247,9 @@ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" } }, "amdefine": { @@ -288,8 +288,8 @@ "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, "requires": { - "micromatch": "3.1.10", - "normalize-path": "2.1.1" + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" }, "dependencies": { "arr-diff": { @@ -310,18 +310,18 @@ "integrity": "sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "define-property": "1.0.0", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "kind-of": "6.0.2", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "kind-of": "^6.0.2", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -330,7 +330,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -339,7 +339,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -350,13 +350,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -365,7 +365,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -374,7 +374,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-descriptor": { @@ -383,9 +383,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -402,14 +402,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -418,7 +418,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -427,7 +427,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -438,10 +438,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -450,7 +450,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -461,7 +461,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -470,7 +470,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -481,7 +481,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -490,7 +490,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -501,7 +501,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -510,7 +510,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -533,19 +533,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.1", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } } } @@ -562,7 +562,7 @@ "integrity": "sha1-126/jKlNJ24keja61EpLdKthGZE=", "dev": true, "requires": { - "default-require-extensions": "1.0.0" + "default-require-extensions": "^1.0.0" } }, "argparse": { @@ -571,7 +571,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "1.0.3" + "sprintf-js": "~1.0.2" } }, "aria-query": { @@ -589,7 +589,7 @@ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-flatten": { @@ -616,8 +616,8 @@ "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", "dev": true, "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.10.0" + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" } }, "array-union": { @@ -626,7 +626,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "1.0.3" + "array-uniq": "^1.0.1" } }, "array-uniq": { @@ -695,7 +695,7 @@ "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "dev": true, "requires": { - "lodash": "4.17.4" + "lodash": "^4.14.0" } }, "async-limiter": { @@ -743,9 +743,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" } }, "babel-core": { @@ -754,25 +754,25 @@ "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-generator": "6.26.0", - "babel-helpers": "6.24.1", - "babel-messages": "6.23.0", - "babel-register": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "convert-source-map": "1.5.1", - "debug": "2.6.9", - "json5": "0.5.1", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "path-is-absolute": "1.0.1", - "private": "0.1.8", - "slash": "1.0.0", - "source-map": "0.5.7" + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.0", + "debug": "^2.6.8", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.7", + "slash": "^1.0.0", + "source-map": "^0.5.6" } }, "babel-eslint": { @@ -781,12 +781,12 @@ "integrity": "sha512-Qt2lz2egBxNYWqN9JIO2z4NOOf8i4b5JS6CFoYrOZZTDssueiV1jH/jsefyg+86SeNY3rB361/mi3kE1WK2WYQ==", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-beta.44", - "@babel/traverse": "7.0.0-beta.44", - "@babel/types": "7.0.0-beta.44", - "babylon": "7.0.0-beta.44", - "eslint-scope": "3.7.1", - "eslint-visitor-keys": "1.0.0" + "@babel/code-frame": "^7.0.0-beta.40", + "@babel/traverse": "^7.0.0-beta.40", + "@babel/types": "^7.0.0-beta.40", + "babylon": "^7.0.0-beta.40", + "eslint-scope": "~3.7.1", + "eslint-visitor-keys": "^1.0.0" }, "dependencies": { "babylon": { @@ -803,14 +803,14 @@ "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", "dev": true, "requires": { - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "detect-indent": "4.0.0", - "jsesc": "1.3.0", - "lodash": "4.17.4", - "source-map": "0.5.7", - "trim-right": "1.0.1" + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.6", + "trim-right": "^1.0.1" } }, "babel-helper-function-name": { @@ -819,11 +819,11 @@ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "dev": true, "requires": { - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-get-function-arity": { @@ -832,8 +832,8 @@ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helpers": { @@ -842,8 +842,8 @@ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-jest": { @@ -852,8 +852,8 @@ "integrity": "sha512-BgSjmtl3mW3i+VeVHEr9d2zFSAT66G++pJcHQiUjd00pkW+voYXFctIm/indcqOWWXw5a1nUpR1XWszD9fJ1qg==", "dev": true, "requires": { - "babel-plugin-istanbul": "4.1.6", - "babel-preset-jest": "22.4.3" + "babel-plugin-istanbul": "^4.1.5", + "babel-preset-jest": "^22.4.3" } }, "babel-loader": { @@ -862,9 +862,9 @@ "integrity": "sha512-/hbyEvPzBJuGpk9o80R0ZyTej6heEOr59GoEUtn8qFKbnx4cJm9FWES6J/iv644sYgrtVw9JJQkjaLW/bqb5gw==", "dev": true, "requires": { - "find-cache-dir": "1.0.0", - "loader-utils": "1.1.0", - "mkdirp": "0.5.1" + "find-cache-dir": "^1.0.0", + "loader-utils": "^1.0.2", + "mkdirp": "^0.5.1" } }, "babel-messages": { @@ -873,7 +873,7 @@ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-external-helpers": { @@ -882,7 +882,7 @@ "integrity": "sha1-IoX0iwK9Xe3oUXXK+MYuhq3M76E=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-istanbul": { @@ -891,10 +891,10 @@ "integrity": "sha512-PWP9FQ1AhZhS01T/4qLSKoHGY/xvkZdVBGlKM/HuxxS3+sC66HhTNR7+MpbO/so/cz/wY94MeSWJuP1hXIPfwQ==", "dev": true, "requires": { - "babel-plugin-syntax-object-rest-spread": "6.13.0", - "find-up": "2.1.0", - "istanbul-lib-instrument": "1.10.1", - "test-exclude": "4.2.1" + "babel-plugin-syntax-object-rest-spread": "^6.13.0", + "find-up": "^2.1.0", + "istanbul-lib-instrument": "^1.10.1", + "test-exclude": "^4.2.1" } }, "babel-plugin-jest-hoist": { @@ -927,10 +927,10 @@ "integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-plugin-syntax-class-properties": "6.13.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-plugin-syntax-class-properties": "^6.8.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-commonjs": { @@ -939,10 +939,10 @@ "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", "dev": true, "requires": { - "babel-plugin-transform-strict-mode": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-types": "6.26.0" + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" } }, "babel-plugin-transform-flow-strip-types": { @@ -951,8 +951,8 @@ "integrity": "sha1-hMtnKTXUNxT9wyvOhFaNh0Qc988=", "dev": true, "requires": { - "babel-plugin-syntax-flow": "6.18.0", - "babel-runtime": "6.26.0" + "babel-plugin-syntax-flow": "^6.18.0", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-object-rest-spread": { @@ -961,8 +961,8 @@ "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", "dev": true, "requires": { - "babel-plugin-syntax-object-rest-spread": "6.13.0", - "babel-runtime": "6.26.0" + "babel-plugin-syntax-object-rest-spread": "^6.8.0", + "babel-runtime": "^6.26.0" } }, "babel-plugin-transform-strict-mode": { @@ -971,8 +971,8 @@ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-preset-jest": { @@ -981,8 +981,8 @@ "integrity": "sha512-a+M3LTEXTq3gxv0uBN9Qm6ahUl7a8pj923nFbCUdqFUSsf3YrX8Uc+C3MEwji5Af3LiQjSC7w4ooYewlz8HRTA==", "dev": true, "requires": { - "babel-plugin-jest-hoist": "22.4.3", - "babel-plugin-syntax-object-rest-spread": "6.13.0" + "babel-plugin-jest-hoist": "^22.4.3", + "babel-plugin-syntax-object-rest-spread": "^6.13.0" } }, "babel-register": { @@ -991,13 +991,13 @@ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "dev": true, "requires": { - "babel-core": "6.26.0", - "babel-runtime": "6.26.0", - "core-js": "2.5.3", - "home-or-tmp": "2.0.0", - "lodash": "4.17.4", - "mkdirp": "0.5.1", - "source-map-support": "0.4.18" + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" } }, "babel-runtime": { @@ -1006,8 +1006,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.3", - "regenerator-runtime": "0.11.1" + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" } }, "babel-template": { @@ -1016,11 +1016,11 @@ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "lodash": "4.17.4" + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" } }, "babel-traverse": { @@ -1029,15 +1029,15 @@ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "debug": "2.6.9", - "globals": "9.18.0", - "invariant": "2.2.2", - "lodash": "4.17.4" + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" } }, "babel-types": { @@ -1046,10 +1046,10 @@ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "esutils": "2.0.2", - "lodash": "4.17.4", - "to-fast-properties": "1.0.3" + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" } }, "babylon": { @@ -1070,13 +1070,13 @@ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { "define-property": { @@ -1085,7 +1085,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "isobject": { @@ -1103,7 +1103,7 @@ "dev": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "big.js": { @@ -1118,7 +1118,7 @@ "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", "dev": true, "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "brace-expansion": { @@ -1127,7 +1127,7 @@ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -1137,9 +1137,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, "browser-process-hrtime": { @@ -1171,7 +1171,7 @@ "integrity": "sha1-mseNPtXZFYBP2HrLFYvHlxR6Fxk=", "dev": true, "requires": { - "node-int64": "0.4.0" + "node-int64": "^0.4.0" } }, "buffer-from": { @@ -1192,15 +1192,15 @@ "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" }, "dependencies": { "isobject": { @@ -1217,7 +1217,7 @@ "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, "requires": { - "callsites": "0.2.0" + "callsites": "^0.2.0" } }, "callsites": { @@ -1246,8 +1246,8 @@ "dev": true, "optional": true, "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" } }, "chai": { @@ -1256,12 +1256,12 @@ "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", "dev": true, "requires": { - "assertion-error": "1.0.2", - "check-error": "1.0.2", - "deep-eql": "3.0.1", - "get-func-name": "2.0.0", - "pathval": "1.1.0", - "type-detect": "4.0.5" + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" } }, "chalk": { @@ -1270,11 +1270,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "chardet": { @@ -1307,10 +1307,10 @@ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" }, "dependencies": { "define-property": { @@ -1319,7 +1319,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "is-accessor-descriptor": { @@ -1328,7 +1328,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -1337,7 +1337,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -1348,7 +1348,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -1357,7 +1357,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -1368,9 +1368,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "isobject": { @@ -1393,7 +1393,7 @@ "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "dev": true, "requires": { - "restore-cursor": "2.0.0" + "restore-cursor": "^2.0.0" } }, "cli-spinners": { @@ -1409,7 +1409,7 @@ "dev": true, "requires": { "slice-ansi": "0.0.4", - "string-width": "1.0.2" + "string-width": "^1.0.1" }, "dependencies": { "is-fullwidth-code-point": { @@ -1418,7 +1418,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "slice-ansi": { @@ -1433,9 +1433,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } } } @@ -1453,8 +1453,8 @@ "dev": true, "optional": true, "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", + "center-align": "^0.1.1", + "right-align": "^0.1.1", "wordwrap": "0.0.2" }, "dependencies": { @@ -1485,8 +1485,8 @@ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" } }, "color-convert": { @@ -1495,7 +1495,7 @@ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { - "color-name": "1.1.3" + "color-name": "^1.1.1" } }, "color-name": { @@ -1510,7 +1510,7 @@ "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "dev": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "commander": { @@ -1549,10 +1549,10 @@ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { - "buffer-from": "1.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" } }, "contains-path": { @@ -1591,10 +1591,10 @@ "integrity": "sha512-6e5vDdrXZD+t5v0L8CrurPeybg4Fmf+FCSYxXKYVAqLUtyCSbuyqE059d0kDthTNRzKVjL7QMgNpEUlsoYH3iQ==", "dev": true, "requires": { - "is-directory": "0.3.1", - "js-yaml": "3.11.0", - "parse-json": "4.0.0", - "require-from-string": "2.0.1" + "is-directory": "^0.3.1", + "js-yaml": "^3.9.0", + "parse-json": "^4.0.0", + "require-from-string": "^2.0.1" }, "dependencies": { "parse-json": { @@ -1603,8 +1603,8 @@ "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "error-ex": "1.3.1", - "json-parse-better-errors": "1.0.2" + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" } } } @@ -1615,9 +1615,9 @@ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { - "lru-cache": "4.1.2", - "shebang-command": "1.2.0", - "which": "1.3.0" + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" } }, "cryptiles": { @@ -1626,7 +1626,7 @@ "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", "dev": true, "requires": { - "boom": "5.2.0" + "boom": "5.x.x" }, "dependencies": { "boom": { @@ -1635,7 +1635,7 @@ "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } } } @@ -1652,7 +1652,7 @@ "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=", "dev": true, "requires": { - "cssom": "0.3.2" + "cssom": "0.3.x" } }, "damerau-levenshtein": { @@ -1667,7 +1667,7 @@ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "data-urls": { @@ -1676,9 +1676,9 @@ "integrity": "sha512-ai40PPQR0Fn1lD2PPie79CibnlMN2AYiDhwFX/rZHVsxbs5kNJSjegqXIprhouGXlRdEnfybva7kqRGnB6mypA==", "dev": true, "requires": { - "abab": "1.0.4", - "whatwg-mimetype": "2.1.0", - "whatwg-url": "6.4.0" + "abab": "^1.0.4", + "whatwg-mimetype": "^2.0.0", + "whatwg-url": "^6.4.0" } }, "date-fns": { @@ -1720,7 +1720,7 @@ "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "dev": true, "requires": { - "type-detect": "4.0.5" + "type-detect": "^4.0.0" } }, "deep-is": { @@ -1735,7 +1735,7 @@ "integrity": "sha1-836hXT4T/9m0N9M+GnW1+5eHTLg=", "dev": true, "requires": { - "strip-bom": "2.0.0" + "strip-bom": "^2.0.0" } }, "define-properties": { @@ -1744,8 +1744,8 @@ "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", "dev": true, "requires": { - "foreach": "2.0.5", - "object-keys": "1.0.11" + "foreach": "^2.0.5", + "object-keys": "^1.0.8" } }, "define-property": { @@ -1754,8 +1754,8 @@ "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -1772,13 +1772,13 @@ "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, "requires": { - "globby": "5.0.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.1", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "rimraf": "2.6.2" + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" }, "dependencies": { "pify": { @@ -1801,7 +1801,7 @@ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } }, "detect-newline": { @@ -1822,7 +1822,7 @@ "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { - "esutils": "2.0.2" + "esutils": "^2.0.2" } }, "domexception": { @@ -1831,7 +1831,7 @@ "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", "dev": true, "requires": { - "webidl-conversions": "4.0.2" + "webidl-conversions": "^4.0.2" } }, "ecc-jsbn": { @@ -1841,7 +1841,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "elegant-spinner": { @@ -1868,7 +1868,7 @@ "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", "dev": true, "requires": { - "iconv-lite": "0.4.19" + "iconv-lite": "~0.4.13" } }, "error-ex": { @@ -1877,7 +1877,7 @@ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "dev": true, "requires": { - "is-arrayish": "0.2.1" + "is-arrayish": "^0.2.1" } }, "es-abstract": { @@ -1886,11 +1886,11 @@ "integrity": "sha512-/uh/DhdqIOSkAWifU+8nG78vlQxdLckUdI/sPgy0VhuXi2qJ7T8czBmqIYtLQVpCIFYafChnsRsB5pyb1JdmCQ==", "dev": true, "requires": { - "es-to-primitive": "1.1.1", - "function-bind": "1.1.1", - "has": "1.0.1", - "is-callable": "1.1.3", - "is-regex": "1.0.4" + "es-to-primitive": "^1.1.1", + "function-bind": "^1.1.1", + "has": "^1.0.1", + "is-callable": "^1.1.3", + "is-regex": "^1.0.4" } }, "es-to-primitive": { @@ -1899,9 +1899,9 @@ "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", "dev": true, "requires": { - "is-callable": "1.1.3", - "is-date-object": "1.0.1", - "is-symbol": "1.0.1" + "is-callable": "^1.1.1", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.1" } }, "escape-string-regexp": { @@ -1916,11 +1916,11 @@ "integrity": "sha512-6hTjO1NAWkHnDk3OqQ4YrCuwwmGHL9S3nPlzBOUG/R44rda3wLNrfvQ5fkSGjyhHFKM7ALPKcKGrwvCLe0lC7Q==", "dev": true, "requires": { - "esprima": "3.1.3", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.6.1" + "esprima": "^3.1.3", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" }, "dependencies": { "esprima": { @@ -1944,44 +1944,44 @@ "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", "dev": true, "requires": { - "ajv": "5.5.2", - "babel-code-frame": "6.26.0", - "chalk": "2.3.2", - "concat-stream": "1.6.2", - "cross-spawn": "5.1.0", - "debug": "3.1.0", - "doctrine": "2.1.0", - "eslint-scope": "3.7.1", - "eslint-visitor-keys": "1.0.0", - "espree": "3.5.4", - "esquery": "1.0.1", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "functional-red-black-tree": "1.0.1", - "glob": "7.1.2", - "globals": "11.4.0", - "ignore": "3.3.7", - "imurmurhash": "0.1.4", - "inquirer": "3.3.0", - "is-resolvable": "1.1.0", - "js-yaml": "3.11.0", - "json-stable-stringify-without-jsonify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "7.0.0", - "progress": "2.0.0", - "regexpp": "1.1.0", - "require-uncached": "1.0.3", - "semver": "5.5.0", - "strip-ansi": "4.0.0", - "strip-json-comments": "2.0.1", + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", "table": "4.0.2", - "text-table": "0.2.0" + "text-table": "~0.2.0" }, "dependencies": { "ansi-regex": { @@ -1996,7 +1996,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -2005,9 +2005,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "debug": { @@ -2031,7 +2031,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } }, "supports-color": { @@ -2040,7 +2040,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -2051,7 +2051,7 @@ "integrity": "sha512-zLyOhVWhzB/jwbz7IPSbkUuj7X2ox4PHXTcZkEmDqTvd0baJmJyuxlFPDlZOE/Y5bC+HQRaEkT3FoHo9wIdRiw==", "dev": true, "requires": { - "eslint-config-airbnb-base": "12.1.0" + "eslint-config-airbnb-base": "^12.1.0" } }, "eslint-config-airbnb-base": { @@ -2060,7 +2060,7 @@ "integrity": "sha512-/vjm0Px5ZCpmJqnjIzcFb9TKZrKWz0gnuG/7Gfkt0Db1ELJR51xkZth+t14rYdqWgX836XbuxtArbIHlVhbLBA==", "dev": true, "requires": { - "eslint-restricted-globals": "0.1.1" + "eslint-restricted-globals": "^0.1.1" } }, "eslint-import-resolver-node": { @@ -2069,8 +2069,8 @@ "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", "dev": true, "requires": { - "debug": "2.6.9", - "resolve": "1.6.0" + "debug": "^2.6.9", + "resolve": "^1.5.0" } }, "eslint-module-utils": { @@ -2079,8 +2079,8 @@ "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", "dev": true, "requires": { - "debug": "2.6.9", - "pkg-dir": "1.0.0" + "debug": "^2.6.8", + "pkg-dir": "^1.0.0" }, "dependencies": { "find-up": { @@ -2089,8 +2089,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "path-exists": { @@ -2099,7 +2099,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "2.0.1" + "pinkie-promise": "^2.0.0" } }, "pkg-dir": { @@ -2108,7 +2108,7 @@ "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", "dev": true, "requires": { - "find-up": "1.1.2" + "find-up": "^1.0.0" } } } @@ -2119,16 +2119,16 @@ "integrity": "sha1-+gkIPVp1KI35xsfQn+EiVZhWVec=", "dev": true, "requires": { - "builtin-modules": "1.1.1", - "contains-path": "0.1.0", - "debug": "2.6.9", + "builtin-modules": "^1.1.1", + "contains-path": "^0.1.0", + "debug": "^2.6.8", "doctrine": "1.5.0", - "eslint-import-resolver-node": "0.3.2", - "eslint-module-utils": "2.2.0", - "has": "1.0.1", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "read-pkg-up": "2.0.0" + "eslint-import-resolver-node": "^0.3.1", + "eslint-module-utils": "^2.2.0", + "has": "^1.0.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.3", + "read-pkg-up": "^2.0.0" }, "dependencies": { "doctrine": { @@ -2137,8 +2137,8 @@ "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", "dev": true, "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "esutils": "^2.0.2", + "isarray": "^1.0.0" } }, "load-json-file": { @@ -2147,10 +2147,10 @@ "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "strip-bom": "3.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" } }, "path-type": { @@ -2159,7 +2159,7 @@ "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "dev": true, "requires": { - "pify": "2.3.0" + "pify": "^2.0.0" } }, "pify": { @@ -2174,9 +2174,9 @@ "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "dev": true, "requires": { - "load-json-file": "2.0.0", - "normalize-package-data": "2.4.0", - "path-type": "2.0.0" + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" } }, "read-pkg-up": { @@ -2185,8 +2185,8 @@ "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", "dev": true, "requires": { - "find-up": "2.1.0", - "read-pkg": "2.0.0" + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" } }, "strip-bom": { @@ -2203,13 +2203,13 @@ "integrity": "sha1-VFg9GuRCSDFi4EDhPMMYZUZRAOU=", "dev": true, "requires": { - "aria-query": "0.7.0", - "array-includes": "3.0.3", + "aria-query": "^0.7.0", + "array-includes": "^3.0.3", "ast-types-flow": "0.0.7", - "axobject-query": "0.1.0", - "damerau-levenshtein": "1.0.4", - "emoji-regex": "6.5.1", - "jsx-ast-utils": "2.0.1" + "axobject-query": "^0.1.0", + "damerau-levenshtein": "^1.0.0", + "emoji-regex": "^6.1.0", + "jsx-ast-utils": "^2.0.0" } }, "eslint-plugin-react": { @@ -2218,10 +2218,10 @@ "integrity": "sha512-KC7Snr4YsWZD5flu6A5c0AcIZidzW3Exbqp7OT67OaD2AppJtlBr/GuPrW/vaQM/yfZotEvKAdrxrO+v8vwYJA==", "dev": true, "requires": { - "doctrine": "2.1.0", - "has": "1.0.1", - "jsx-ast-utils": "2.0.1", - "prop-types": "15.6.1" + "doctrine": "^2.0.2", + "has": "^1.0.1", + "jsx-ast-utils": "^2.0.1", + "prop-types": "^15.6.0" } }, "eslint-restricted-globals": { @@ -2236,8 +2236,8 @@ "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", "dev": true, "requires": { - "esrecurse": "4.2.1", - "estraverse": "4.2.0" + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" } }, "eslint-visitor-keys": { @@ -2252,8 +2252,8 @@ "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { - "acorn": "5.5.3", - "acorn-jsx": "3.0.1" + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" } }, "esprima": { @@ -2268,7 +2268,7 @@ "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", "dev": true, "requires": { - "estraverse": "4.2.0" + "estraverse": "^4.0.0" } }, "esrecurse": { @@ -2277,7 +2277,7 @@ "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { - "estraverse": "4.2.0" + "estraverse": "^4.1.0" } }, "estraverse": { @@ -2304,7 +2304,7 @@ "integrity": "sha512-aLt95pexaugVtQerpmE51+4QfWrNc304uez7jvj6fWnN8GeEHpttB8F36n8N7uVhUMbH/1enbxQ9HImZ4w/9qg==", "dev": true, "requires": { - "merge": "1.2.0" + "merge": "^1.1.3" } }, "execa": { @@ -2313,13 +2313,13 @@ "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "1.1.0", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" } }, "exit": { @@ -2340,7 +2340,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "is-posix-bracket": "^0.1.0" } }, "expand-range": { @@ -2349,7 +2349,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "2.2.3" + "fill-range": "^2.1.0" } }, "expect": { @@ -2358,12 +2358,12 @@ "integrity": "sha512-XcNXEPehqn8b/jm8FYotdX0YrXn36qp4HWlrVT4ktwQas1l1LPxiVWncYnnL2eyMtKAmVIaG0XAp0QlrqJaxaA==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "jest-diff": "22.4.3", - "jest-get-type": "22.4.3", - "jest-matcher-utils": "22.4.3", - "jest-message-util": "22.4.3", - "jest-regex-util": "22.4.3" + "ansi-styles": "^3.2.0", + "jest-diff": "^22.4.3", + "jest-get-type": "^22.4.3", + "jest-matcher-utils": "^22.4.3", + "jest-message-util": "^22.4.3", + "jest-regex-util": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -2372,7 +2372,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } } } @@ -2389,8 +2389,8 @@ "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -2399,7 +2399,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -2410,9 +2410,9 @@ "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", "dev": true, "requires": { - "chardet": "0.4.2", - "iconv-lite": "0.4.19", - "tmp": "0.0.33" + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" } }, "extglob": { @@ -2421,7 +2421,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "extsprintf": { @@ -2454,7 +2454,7 @@ "integrity": "sha1-VOmr99+i8mzZsWNsWIwa/AXeXVg=", "dev": true, "requires": { - "bser": "2.0.0" + "bser": "^2.0.0" } }, "fbjs": { @@ -2463,13 +2463,13 @@ "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", "dev": true, "requires": { - "core-js": "1.2.7", - "isomorphic-fetch": "2.2.1", - "loose-envify": "1.3.1", - "object-assign": "4.1.1", - "promise": "7.3.1", - "setimmediate": "1.0.5", - "ua-parser-js": "0.7.17" + "core-js": "^1.0.0", + "isomorphic-fetch": "^2.1.1", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^0.7.9" }, "dependencies": { "core-js": { @@ -2486,7 +2486,7 @@ "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5" + "escape-string-regexp": "^1.0.5" } }, "file-entry-cache": { @@ -2495,8 +2495,8 @@ "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, "requires": { - "flat-cache": "1.3.0", - "object-assign": "4.1.1" + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" } }, "filename-regex": { @@ -2511,8 +2511,8 @@ "integrity": "sha1-jnVIqW08wjJ+5eZ0FocjozO7oqA=", "dev": true, "requires": { - "glob": "7.1.2", - "minimatch": "3.0.4" + "glob": "^7.0.3", + "minimatch": "^3.0.3" } }, "fill-range": { @@ -2521,11 +2521,11 @@ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.7", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, "find-cache-dir": { @@ -2534,9 +2534,9 @@ "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", "dev": true, "requires": { - "commondir": "1.0.1", - "make-dir": "1.2.0", - "pkg-dir": "2.0.0" + "commondir": "^1.0.1", + "make-dir": "^1.0.0", + "pkg-dir": "^2.0.0" } }, "find-parent-dir": { @@ -2551,7 +2551,7 @@ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "2.0.0" + "locate-path": "^2.0.0" } }, "flat-cache": { @@ -2560,10 +2560,10 @@ "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", "dev": true, "requires": { - "circular-json": "0.3.3", - "del": "2.2.2", - "graceful-fs": "4.1.11", - "write": "0.2.1" + "circular-json": "^0.3.1", + "del": "^2.0.2", + "graceful-fs": "^4.1.2", + "write": "^0.2.1" } }, "flow-bin": { @@ -2584,7 +2584,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "foreach": { @@ -2605,9 +2605,9 @@ "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "dev": true, "requires": { - "asynckit": "0.4.0", + "asynckit": "^0.4.0", "combined-stream": "1.0.6", - "mime-types": "2.1.18" + "mime-types": "^2.1.12" } }, "fragment-cache": { @@ -2616,7 +2616,7 @@ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { - "map-cache": "0.2.2" + "map-cache": "^0.2.2" } }, "fs.realpath": { @@ -2632,8 +2632,8 @@ "dev": true, "optional": true, "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.6.39" + "nan": "^2.3.0", + "node-pre-gyp": "^0.6.39" }, "dependencies": { "abbrev": { @@ -2648,8 +2648,8 @@ "dev": true, "optional": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" } }, "ansi-regex": { @@ -2669,8 +2669,8 @@ "dev": true, "optional": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "asn1": { @@ -2714,7 +2714,7 @@ "dev": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "block-stream": { @@ -2722,7 +2722,7 @@ "bundled": true, "dev": true, "requires": { - "inherits": "2.0.3" + "inherits": "~2.0.0" } }, "boom": { @@ -2730,7 +2730,7 @@ "bundled": true, "dev": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "brace-expansion": { @@ -2738,7 +2738,7 @@ "bundled": true, "dev": true, "requires": { - "balanced-match": "0.4.2", + "balanced-match": "^0.4.1", "concat-map": "0.0.1" } }, @@ -2769,7 +2769,7 @@ "bundled": true, "dev": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "concat-map": { @@ -2792,7 +2792,7 @@ "bundled": true, "dev": true, "requires": { - "boom": "2.10.1" + "boom": "2.x.x" } }, "dashdash": { @@ -2801,7 +2801,7 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -2850,7 +2850,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "extend": { @@ -2876,9 +2876,9 @@ "dev": true, "optional": true, "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" } }, "fs.realpath": { @@ -2891,10 +2891,10 @@ "bundled": true, "dev": true, "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" } }, "fstream-ignore": { @@ -2903,9 +2903,9 @@ "dev": true, "optional": true, "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" } }, "gauge": { @@ -2914,14 +2914,14 @@ "dev": true, "optional": true, "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "getpass": { @@ -2930,7 +2930,7 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -2946,12 +2946,12 @@ "bundled": true, "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-fs": { @@ -2971,8 +2971,8 @@ "dev": true, "optional": true, "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" + "ajv": "^4.9.1", + "har-schema": "^1.0.5" } }, "has-unicode": { @@ -2986,10 +2986,10 @@ "bundled": true, "dev": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" } }, "hoek": { @@ -3003,9 +3003,9 @@ "dev": true, "optional": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "inflight": { @@ -3013,8 +3013,8 @@ "bundled": true, "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -3033,7 +3033,7 @@ "bundled": true, "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-typedarray": { @@ -3059,7 +3059,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "jsbn": { @@ -3080,7 +3080,7 @@ "dev": true, "optional": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stringify-safe": { @@ -3125,7 +3125,7 @@ "bundled": true, "dev": true, "requires": { - "mime-db": "1.27.0" + "mime-db": "~1.27.0" } }, "minimatch": { @@ -3133,7 +3133,7 @@ "bundled": true, "dev": true, "requires": { - "brace-expansion": "1.1.7" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -3161,17 +3161,17 @@ "dev": true, "optional": true, "requires": { - "detect-libc": "1.0.2", + "detect-libc": "^1.0.2", "hawk": "3.1.3", - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", + "mkdirp": "^0.5.1", + "nopt": "^4.0.1", + "npmlog": "^4.0.2", + "rc": "^1.1.7", "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^2.2.1", + "tar-pack": "^3.4.0" } }, "nopt": { @@ -3180,8 +3180,8 @@ "dev": true, "optional": true, "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npmlog": { @@ -3190,10 +3190,10 @@ "dev": true, "optional": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -3218,7 +3218,7 @@ "bundled": true, "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -3239,8 +3239,8 @@ "dev": true, "optional": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -3277,10 +3277,10 @@ "dev": true, "optional": true, "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -3296,13 +3296,13 @@ "bundled": true, "dev": true, "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" } }, "request": { @@ -3311,28 +3311,28 @@ "dev": true, "optional": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~4.2.1", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "performance-now": "^0.2.0", + "qs": "~6.4.0", + "safe-buffer": "^5.0.1", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.0.0" } }, "rimraf": { @@ -3340,7 +3340,7 @@ "bundled": true, "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -3371,7 +3371,7 @@ "bundled": true, "dev": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "sshpk": { @@ -3380,15 +3380,15 @@ "dev": true, "optional": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jodid25519": "^1.0.0", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "assert-plus": { @@ -3404,9 +3404,9 @@ "bundled": true, "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -3414,7 +3414,7 @@ "bundled": true, "dev": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "stringstream": { @@ -3428,7 +3428,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -3442,9 +3442,9 @@ "bundled": true, "dev": true, "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" } }, "tar-pack": { @@ -3453,14 +3453,14 @@ "dev": true, "optional": true, "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" + "debug": "^2.2.0", + "fstream": "^1.0.10", + "fstream-ignore": "^1.0.5", + "once": "^1.3.3", + "readable-stream": "^2.1.4", + "rimraf": "^2.5.1", + "tar": "^2.2.1", + "uid-number": "^0.0.6" } }, "tough-cookie": { @@ -3469,7 +3469,7 @@ "dev": true, "optional": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { @@ -3478,7 +3478,7 @@ "dev": true, "optional": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -3519,7 +3519,7 @@ "dev": true, "optional": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { @@ -3577,7 +3577,7 @@ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "glob": { @@ -3586,12 +3586,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "glob-base": { @@ -3600,8 +3600,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, "glob-parent": { @@ -3610,7 +3610,7 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "2.0.1" + "is-glob": "^2.0.0" } }, "globals": { @@ -3625,12 +3625,12 @@ "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, "requires": { - "array-union": "1.0.2", - "arrify": "1.0.1", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "pify": { @@ -3659,10 +3659,10 @@ "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { - "async": "1.5.2", - "optimist": "0.6.1", - "source-map": "0.4.4", - "uglify-js": "2.8.29" + "async": "^1.4.0", + "optimist": "^0.6.1", + "source-map": "^0.4.4", + "uglify-js": "^2.6" }, "dependencies": { "async": { @@ -3677,7 +3677,7 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } }, "uglify-js": { @@ -3687,9 +3687,9 @@ "dev": true, "optional": true, "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" }, "dependencies": { "source-map": { @@ -3708,9 +3708,9 @@ "dev": true, "optional": true, "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", "window-size": "0.1.0" } } @@ -3728,8 +3728,8 @@ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "dev": true, "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.1.0", + "har-schema": "^2.0.0" } }, "has": { @@ -3738,7 +3738,7 @@ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", "dev": true, "requires": { - "function-bind": "1.1.1" + "function-bind": "^1.0.2" } }, "has-ansi": { @@ -3747,7 +3747,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "has-flag": { @@ -3762,9 +3762,9 @@ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -3781,8 +3781,8 @@ "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -3791,7 +3791,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3800,7 +3800,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3811,7 +3811,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3822,10 +3822,10 @@ "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.1", - "sntp": "2.1.0" + "boom": "4.x.x", + "cryptiles": "3.x.x", + "hoek": "4.x.x", + "sntp": "2.x.x" } }, "hoek": { @@ -3840,8 +3840,8 @@ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", "dev": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" } }, "hosted-git-info": { @@ -3856,7 +3856,7 @@ "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", "dev": true, "requires": { - "whatwg-encoding": "1.0.3" + "whatwg-encoding": "^1.0.1" } }, "http-signature": { @@ -3865,9 +3865,9 @@ "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.14.1" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "husky": { @@ -3876,9 +3876,9 @@ "integrity": "sha512-e21wivqHpstpoiWA/Yi8eFti8E+sQDSS53cpJsPptPs295QTOQR0ZwnHo2TXy1XOpZFD9rPOd3NpmqTK6uMLJA==", "dev": true, "requires": { - "is-ci": "1.0.10", - "normalize-path": "1.0.0", - "strip-indent": "2.0.0" + "is-ci": "^1.0.10", + "normalize-path": "^1.0.0", + "strip-indent": "^2.0.0" }, "dependencies": { "normalize-path": { @@ -3907,8 +3907,8 @@ "integrity": "sha512-vAaZHieK9qjGo58agRBg+bhHX3hoTZU/Oa3GESWLz7t1U62fk63aHuDJJEteXoDeTCcPmUT+z38gkHPZkkmpmQ==", "dev": true, "requires": { - "pkg-dir": "2.0.0", - "resolve-cwd": "2.0.0" + "pkg-dir": "^2.0.0", + "resolve-cwd": "^2.0.0" } }, "imurmurhash": { @@ -3923,7 +3923,7 @@ "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } }, "inflight": { @@ -3932,8 +3932,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -3948,20 +3948,20 @@ "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { - "ansi-escapes": "3.1.0", - "chalk": "2.3.2", - "cli-cursor": "2.1.0", - "cli-width": "2.2.0", - "external-editor": "2.2.0", - "figures": "2.0.0", - "lodash": "4.17.4", + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rx-lite": "4.0.8", - "rx-lite-aggregates": "4.0.8", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" }, "dependencies": { "ansi-regex": { @@ -3976,7 +3976,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -3985,9 +3985,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "strip-ansi": { @@ -3996,7 +3996,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } }, "supports-color": { @@ -4005,7 +4005,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4016,7 +4016,7 @@ "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=", "dev": true, "requires": { - "loose-envify": "1.3.1" + "loose-envify": "^1.0.0" } }, "invert-kv": { @@ -4031,7 +4031,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" }, "dependencies": { "kind-of": { @@ -4060,7 +4060,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "1.1.1" + "builtin-modules": "^1.0.0" } }, "is-callable": { @@ -4075,7 +4075,7 @@ "integrity": "sha1-9zkzayYyNlBhqdSCcM1WrjNpMY4=", "dev": true, "requires": { - "ci-info": "1.1.2" + "ci-info": "^1.0.0" } }, "is-data-descriptor": { @@ -4084,7 +4084,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" }, "dependencies": { "kind-of": { @@ -4107,9 +4107,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" }, "dependencies": { "kind-of": { @@ -4138,7 +4138,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "2.0.0" + "is-primitive": "^2.0.0" } }, "is-extendable": { @@ -4159,7 +4159,7 @@ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-fullwidth-code-point": { @@ -4180,7 +4180,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "is-module": { @@ -4195,7 +4195,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-obj": { @@ -4210,7 +4210,7 @@ "integrity": "sha1-s2ExHYPG5dcmyr9eJQsCNxBvWuI=", "dev": true, "requires": { - "symbol-observable": "0.2.4" + "symbol-observable": "^0.2.2" } }, "is-odd": { @@ -4219,7 +4219,7 @@ "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", "dev": true, "requires": { - "is-number": "4.0.0" + "is-number": "^4.0.0" }, "dependencies": { "is-number": { @@ -4242,7 +4242,7 @@ "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, "requires": { - "is-path-inside": "1.0.1" + "is-path-inside": "^1.0.0" } }, "is-path-inside": { @@ -4251,7 +4251,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "1.0.2" + "path-is-inside": "^1.0.1" } }, "is-plain-object": { @@ -4260,7 +4260,7 @@ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -4295,7 +4295,7 @@ "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", "dev": true, "requires": { - "has": "1.0.1" + "has": "^1.0.1" } }, "is-regexp": { @@ -4367,8 +4367,8 @@ "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "dev": true, "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "2.0.4" + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" } }, "isstream": { @@ -4383,18 +4383,18 @@ "integrity": "sha512-duj6AlLcsWNwUpfyfHt0nWIeRiZpuShnP40YTxOGQgtaN8fd6JYSxsvxUphTDy8V5MfDXo4s/xVCIIvVCO808g==", "dev": true, "requires": { - "async": "2.6.0", - "compare-versions": "3.1.0", - "fileset": "2.0.3", - "istanbul-lib-coverage": "1.2.0", - "istanbul-lib-hook": "1.2.0", - "istanbul-lib-instrument": "1.10.1", - "istanbul-lib-report": "1.1.4", - "istanbul-lib-source-maps": "1.2.4", - "istanbul-reports": "1.3.0", - "js-yaml": "3.11.0", - "mkdirp": "0.5.1", - "once": "1.4.0" + "async": "^2.1.4", + "compare-versions": "^3.1.0", + "fileset": "^2.0.2", + "istanbul-lib-coverage": "^1.2.0", + "istanbul-lib-hook": "^1.2.0", + "istanbul-lib-instrument": "^1.10.1", + "istanbul-lib-report": "^1.1.4", + "istanbul-lib-source-maps": "^1.2.4", + "istanbul-reports": "^1.3.0", + "js-yaml": "^3.7.0", + "mkdirp": "^0.5.1", + "once": "^1.4.0" }, "dependencies": { "debug": { @@ -4412,11 +4412,11 @@ "integrity": "sha512-UzuK0g1wyQijiaYQxj/CdNycFhAd2TLtO2obKQMTZrZ1jzEMRY3rvpASEKkaxbRR6brvdovfA03znPa/pXcejg==", "dev": true, "requires": { - "debug": "3.1.0", - "istanbul-lib-coverage": "1.2.0", - "mkdirp": "0.5.1", - "rimraf": "2.6.2", - "source-map": "0.5.7" + "debug": "^3.1.0", + "istanbul-lib-coverage": "^1.2.0", + "mkdirp": "^0.5.1", + "rimraf": "^2.6.1", + "source-map": "^0.5.3" } } } @@ -4433,7 +4433,7 @@ "integrity": "sha512-p3En6/oGkFQV55Up8ZPC2oLxvgSxD8CzA0yBrhRZSh3pfv3OFj9aSGVC0yoerAi/O4u7jUVnOGVX1eVFM+0tmQ==", "dev": true, "requires": { - "append-transform": "0.4.0" + "append-transform": "^0.4.0" } }, "istanbul-lib-instrument": { @@ -4442,13 +4442,13 @@ "integrity": "sha512-1dYuzkOCbuR5GRJqySuZdsmsNKPL3PTuyPevQfoCXJePT9C8y1ga75neU+Tuy9+yS3G/dgx8wgOmp2KLpgdoeQ==", "dev": true, "requires": { - "babel-generator": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "istanbul-lib-coverage": "1.2.0", - "semver": "5.5.0" + "babel-generator": "^6.18.0", + "babel-template": "^6.16.0", + "babel-traverse": "^6.18.0", + "babel-types": "^6.18.0", + "babylon": "^6.18.0", + "istanbul-lib-coverage": "^1.2.0", + "semver": "^5.3.0" } }, "istanbul-lib-report": { @@ -4457,10 +4457,10 @@ "integrity": "sha512-Azqvq5tT0U09nrncK3q82e/Zjkxa4tkFZv7E6VcqP0QCPn6oNljDPfrZEC/umNXds2t7b8sRJfs6Kmpzt8m2kA==", "dev": true, "requires": { - "istanbul-lib-coverage": "1.2.0", - "mkdirp": "0.5.1", - "path-parse": "1.0.5", - "supports-color": "3.2.3" + "istanbul-lib-coverage": "^1.2.0", + "mkdirp": "^0.5.1", + "path-parse": "^1.0.5", + "supports-color": "^3.1.2" }, "dependencies": { "has-flag": { @@ -4475,7 +4475,7 @@ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } } } @@ -4486,11 +4486,11 @@ "integrity": "sha512-fDa0hwU/5sDXwAklXgAoCJCOsFsBplVQ6WBldz5UwaqOzmDhUK4nfuR7/G//G2lERlblUNJB8P6e8cXq3a7MlA==", "dev": true, "requires": { - "debug": "3.1.0", - "istanbul-lib-coverage": "1.2.0", - "mkdirp": "0.5.1", - "rimraf": "2.6.2", - "source-map": "0.5.7" + "debug": "^3.1.0", + "istanbul-lib-coverage": "^1.1.2", + "mkdirp": "^0.5.1", + "rimraf": "^2.6.1", + "source-map": "^0.5.3" }, "dependencies": { "debug": { @@ -4510,7 +4510,7 @@ "integrity": "sha512-y2Z2IMqE1gefWUaVjrBm0mSKvUkaBy9Vqz8iwr/r40Y9hBbIteH5wqHG/9DLTfJ9xUnUT2j7A3+VVJ6EaYBllA==", "dev": true, "requires": { - "handlebars": "4.0.11" + "handlebars": "^4.0.3" } }, "jest": { @@ -4519,8 +4519,8 @@ "integrity": "sha512-FFCdU/pXOEASfHxFDOWUysI/+FFoqiXJADEIXgDKuZyqSmBD3tZ4BEGH7+M79v7czj7bbkhwtd2LaEDcJiM/GQ==", "dev": true, "requires": { - "import-local": "1.0.0", - "jest-cli": "22.4.3" + "import-local": "^1.0.0", + "jest-cli": "^22.4.3" }, "dependencies": { "ansi-regex": { @@ -4535,7 +4535,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4544,9 +4544,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "jest-cli": { @@ -4555,40 +4555,40 @@ "integrity": "sha512-IiHybF0DJNqZPsbjn4Cy4vcqcmImpoFwNFnkehzVw8lTUSl4axZh5DHewu5bdpZF2Y5gUqFKYzH0FH4Qx2k+UA==", "dev": true, "requires": { - "ansi-escapes": "3.1.0", - "chalk": "2.3.2", - "exit": "0.1.2", - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "import-local": "1.0.0", - "is-ci": "1.0.10", - "istanbul-api": "1.3.1", - "istanbul-lib-coverage": "1.2.0", - "istanbul-lib-instrument": "1.10.1", - "istanbul-lib-source-maps": "1.2.3", - "jest-changed-files": "22.4.3", - "jest-config": "22.4.3", - "jest-environment-jsdom": "22.4.3", - "jest-get-type": "22.4.3", - "jest-haste-map": "22.4.3", - "jest-message-util": "22.4.3", - "jest-regex-util": "22.4.3", - "jest-resolve-dependencies": "22.4.3", - "jest-runner": "22.4.3", - "jest-runtime": "22.4.3", - "jest-snapshot": "22.4.3", - "jest-util": "22.4.3", - "jest-validate": "22.4.3", - "jest-worker": "22.4.3", - "micromatch": "2.3.11", - "node-notifier": "5.2.1", - "realpath-native": "1.0.0", - "rimraf": "2.6.2", - "slash": "1.0.0", - "string-length": "2.0.0", - "strip-ansi": "4.0.0", - "which": "1.3.0", - "yargs": "10.1.2" + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.2", + "graceful-fs": "^4.1.11", + "import-local": "^1.0.0", + "is-ci": "^1.0.10", + "istanbul-api": "^1.1.14", + "istanbul-lib-coverage": "^1.1.1", + "istanbul-lib-instrument": "^1.8.0", + "istanbul-lib-source-maps": "^1.2.1", + "jest-changed-files": "^22.4.3", + "jest-config": "^22.4.3", + "jest-environment-jsdom": "^22.4.3", + "jest-get-type": "^22.4.3", + "jest-haste-map": "^22.4.3", + "jest-message-util": "^22.4.3", + "jest-regex-util": "^22.4.3", + "jest-resolve-dependencies": "^22.4.3", + "jest-runner": "^22.4.3", + "jest-runtime": "^22.4.3", + "jest-snapshot": "^22.4.3", + "jest-util": "^22.4.3", + "jest-validate": "^22.4.3", + "jest-worker": "^22.4.3", + "micromatch": "^2.3.11", + "node-notifier": "^5.2.1", + "realpath-native": "^1.0.0", + "rimraf": "^2.5.4", + "slash": "^1.0.0", + "string-length": "^2.0.0", + "strip-ansi": "^4.0.0", + "which": "^1.2.12", + "yargs": "^10.0.3" } }, "strip-ansi": { @@ -4597,7 +4597,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } }, "supports-color": { @@ -4606,7 +4606,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4617,7 +4617,7 @@ "integrity": "sha512-83Dh0w1aSkUNFhy5d2dvqWxi/y6weDwVVLU6vmK0cV9VpRxPzhTeGimbsbRDSnEoszhF937M4sDLLeS7Cu/Tmw==", "dev": true, "requires": { - "throat": "4.1.0" + "throat": "^4.0.0" } }, "jest-config": { @@ -4626,17 +4626,17 @@ "integrity": "sha512-KSg3EOToCgkX+lIvenKY7J8s426h6ahXxaUFJxvGoEk0562Z6inWj1TnKoGycTASwiLD+6kSYFALcjdosq9KIQ==", "dev": true, "requires": { - "chalk": "2.3.2", - "glob": "7.1.2", - "jest-environment-jsdom": "22.4.3", - "jest-environment-node": "22.4.3", - "jest-get-type": "22.4.3", - "jest-jasmine2": "22.4.3", - "jest-regex-util": "22.4.3", - "jest-resolve": "22.4.3", - "jest-util": "22.4.3", - "jest-validate": "22.4.3", - "pretty-format": "22.4.3" + "chalk": "^2.0.1", + "glob": "^7.1.1", + "jest-environment-jsdom": "^22.4.3", + "jest-environment-node": "^22.4.3", + "jest-get-type": "^22.4.3", + "jest-jasmine2": "^22.4.3", + "jest-regex-util": "^22.4.3", + "jest-resolve": "^22.4.3", + "jest-util": "^22.4.3", + "jest-validate": "^22.4.3", + "pretty-format": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -4645,7 +4645,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4654,9 +4654,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -4665,7 +4665,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4676,10 +4676,10 @@ "integrity": "sha512-/QqGvCDP5oZOF6PebDuLwrB2BMD8ffJv6TAGAdEVuDx1+uEgrHpSFrfrOiMRx2eJ1hgNjlQrOQEHetVwij90KA==", "dev": true, "requires": { - "chalk": "2.3.2", - "diff": "3.5.0", - "jest-get-type": "22.4.3", - "pretty-format": "22.4.3" + "chalk": "^2.0.1", + "diff": "^3.2.0", + "jest-get-type": "^22.4.3", + "pretty-format": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -4688,7 +4688,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4697,9 +4697,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -4708,7 +4708,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4719,7 +4719,7 @@ "integrity": "sha512-uPKBEAw7YrEMcXueMKZXn/rbMxBiSv48fSqy3uEnmgOlQhSX+lthBqHb1fKWNVmFqAp9E/RsSdBfiV31LbzaOg==", "dev": true, "requires": { - "detect-newline": "2.1.0" + "detect-newline": "^2.1.0" } }, "jest-environment-jsdom": { @@ -4728,9 +4728,9 @@ "integrity": "sha512-FviwfR+VyT3Datf13+ULjIMO5CSeajlayhhYQwpzgunswoaLIPutdbrnfUHEMyJCwvqQFaVtTmn9+Y8WCt6n1w==", "dev": true, "requires": { - "jest-mock": "22.4.3", - "jest-util": "22.4.3", - "jsdom": "11.7.0" + "jest-mock": "^22.4.3", + "jest-util": "^22.4.3", + "jsdom": "^11.5.1" } }, "jest-environment-node": { @@ -4739,8 +4739,8 @@ "integrity": "sha512-reZl8XF6t/lMEuPWwo9OLfttyC26A5AMgDyEQ6DBgZuyfyeNUzYT8BFo6uxCCP/Av/b7eb9fTi3sIHFPBzmlRA==", "dev": true, "requires": { - "jest-mock": "22.4.3", - "jest-util": "22.4.3" + "jest-mock": "^22.4.3", + "jest-util": "^22.4.3" } }, "jest-get-type": { @@ -4755,13 +4755,13 @@ "integrity": "sha512-4Q9fjzuPVwnaqGKDpIsCSoTSnG3cteyk2oNVjBX12HHOaF1oxql+uUiqZb5Ndu7g/vTZfdNwwy4WwYogLh29DQ==", "dev": true, "requires": { - "fb-watchman": "2.0.0", - "graceful-fs": "4.1.11", - "jest-docblock": "22.4.3", - "jest-serializer": "22.4.3", - "jest-worker": "22.4.3", - "micromatch": "2.3.11", - "sane": "2.5.0" + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.1.11", + "jest-docblock": "^22.4.3", + "jest-serializer": "^22.4.3", + "jest-worker": "^22.4.3", + "micromatch": "^2.3.11", + "sane": "^2.0.0" } }, "jest-jasmine2": { @@ -4770,17 +4770,17 @@ "integrity": "sha512-yZCPCJUcEY6R5KJB/VReo1AYI2b+5Ky+C+JA1v34jndJsRcLpU4IZX4rFJn7yDTtdNbO/nNqg+3SDIPNH2ecnw==", "dev": true, "requires": { - "chalk": "2.3.2", - "co": "4.6.0", - "expect": "22.4.3", - "graceful-fs": "4.1.11", - "is-generator-fn": "1.0.0", - "jest-diff": "22.4.3", - "jest-matcher-utils": "22.4.3", - "jest-message-util": "22.4.3", - "jest-snapshot": "22.4.3", - "jest-util": "22.4.3", - "source-map-support": "0.5.4" + "chalk": "^2.0.1", + "co": "^4.6.0", + "expect": "^22.4.3", + "graceful-fs": "^4.1.11", + "is-generator-fn": "^1.0.0", + "jest-diff": "^22.4.3", + "jest-matcher-utils": "^22.4.3", + "jest-message-util": "^22.4.3", + "jest-snapshot": "^22.4.3", + "jest-util": "^22.4.3", + "source-map-support": "^0.5.0" }, "dependencies": { "ansi-styles": { @@ -4789,7 +4789,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4798,9 +4798,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "source-map": { @@ -4815,7 +4815,7 @@ "integrity": "sha512-PETSPG6BjY1AHs2t64vS2aqAgu6dMIMXJULWFBGbh2Gr8nVLbCFDo6i/RMMvviIQ2h1Z8+5gQhVKSn2je9nmdg==", "dev": true, "requires": { - "source-map": "0.6.1" + "source-map": "^0.6.0" } }, "supports-color": { @@ -4824,7 +4824,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4835,7 +4835,7 @@ "integrity": "sha512-NZpR/Ls7+ndO57LuXROdgCGz2RmUdC541tTImL9bdUtU3WadgFGm0yV+Ok4Fuia/1rLAn5KaJ+i76L6e3zGJYQ==", "dev": true, "requires": { - "pretty-format": "22.4.3" + "pretty-format": "^22.4.3" } }, "jest-matcher-utils": { @@ -4844,9 +4844,9 @@ "integrity": "sha512-lsEHVaTnKzdAPR5t4B6OcxXo9Vy4K+kRRbG5gtddY8lBEC+Mlpvm1CJcsMESRjzUhzkz568exMV1hTB76nAKbA==", "dev": true, "requires": { - "chalk": "2.3.2", - "jest-get-type": "22.4.3", - "pretty-format": "22.4.3" + "chalk": "^2.0.1", + "jest-get-type": "^22.4.3", + "pretty-format": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -4855,7 +4855,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4864,9 +4864,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -4875,7 +4875,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4886,11 +4886,11 @@ "integrity": "sha512-iAMeKxhB3Se5xkSjU0NndLLCHtP4n+GtCqV0bISKA5dmOXQfEbdEmYiu2qpnWBDCQdEafNDDU6Q+l6oBMd/+BA==", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-beta.44", - "chalk": "2.3.2", - "micromatch": "2.3.11", - "slash": "1.0.0", - "stack-utils": "1.0.1" + "@babel/code-frame": "^7.0.0-beta.35", + "chalk": "^2.0.1", + "micromatch": "^2.3.11", + "slash": "^1.0.0", + "stack-utils": "^1.0.1" }, "dependencies": { "ansi-styles": { @@ -4899,7 +4899,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4908,9 +4908,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -4919,7 +4919,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4942,8 +4942,8 @@ "integrity": "sha512-u3BkD/MQBmwrOJDzDIaxpyqTxYH+XqAXzVJP51gt29H8jpj3QgKof5GGO2uPGKGeA1yTMlpbMs1gIQ6U4vcRhw==", "dev": true, "requires": { - "browser-resolve": "1.11.2", - "chalk": "2.3.2" + "browser-resolve": "^1.11.2", + "chalk": "^2.0.1" }, "dependencies": { "ansi-styles": { @@ -4952,7 +4952,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -4961,9 +4961,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -4972,7 +4972,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -4983,7 +4983,7 @@ "integrity": "sha512-06czCMVToSN8F2U4EvgSB1Bv/56gc7MpCftZ9z9fBgUQM7dzHGCMBsyfVA6dZTx8v0FDcnALf7hupeQxaBCvpA==", "dev": true, "requires": { - "jest-regex-util": "22.4.3" + "jest-regex-util": "^22.4.3" } }, "jest-runner": { @@ -4992,17 +4992,17 @@ "integrity": "sha512-U7PLlQPRlWNbvOHWOrrVay9sqhBJmiKeAdKIkvX4n1G2tsvzLlf77nBD28GL1N6tGv4RmuTfI8R8JrkvCa+IBg==", "dev": true, "requires": { - "exit": "0.1.2", - "jest-config": "22.4.3", - "jest-docblock": "22.4.3", - "jest-haste-map": "22.4.3", - "jest-jasmine2": "22.4.3", - "jest-leak-detector": "22.4.3", - "jest-message-util": "22.4.3", - "jest-runtime": "22.4.3", - "jest-util": "22.4.3", - "jest-worker": "22.4.3", - "throat": "4.1.0" + "exit": "^0.1.2", + "jest-config": "^22.4.3", + "jest-docblock": "^22.4.3", + "jest-haste-map": "^22.4.3", + "jest-jasmine2": "^22.4.3", + "jest-leak-detector": "^22.4.3", + "jest-message-util": "^22.4.3", + "jest-runtime": "^22.4.3", + "jest-util": "^22.4.3", + "jest-worker": "^22.4.3", + "throat": "^4.0.0" } }, "jest-runtime": { @@ -5011,26 +5011,26 @@ "integrity": "sha512-Eat/esQjevhx9BgJEC8udye+FfoJ2qvxAZfOAWshYGS22HydHn5BgsvPdTtt9cp0fSl5LxYOFA1Pja9Iz2Zt8g==", "dev": true, "requires": { - "babel-core": "6.26.0", - "babel-jest": "22.4.3", - "babel-plugin-istanbul": "4.1.6", - "chalk": "2.3.2", - "convert-source-map": "1.5.1", - "exit": "0.1.2", - "graceful-fs": "4.1.11", - "jest-config": "22.4.3", - "jest-haste-map": "22.4.3", - "jest-regex-util": "22.4.3", - "jest-resolve": "22.4.3", - "jest-util": "22.4.3", - "jest-validate": "22.4.3", - "json-stable-stringify": "1.0.1", - "micromatch": "2.3.11", - "realpath-native": "1.0.0", - "slash": "1.0.0", + "babel-core": "^6.0.0", + "babel-jest": "^22.4.3", + "babel-plugin-istanbul": "^4.1.5", + "chalk": "^2.0.1", + "convert-source-map": "^1.4.0", + "exit": "^0.1.2", + "graceful-fs": "^4.1.11", + "jest-config": "^22.4.3", + "jest-haste-map": "^22.4.3", + "jest-regex-util": "^22.4.3", + "jest-resolve": "^22.4.3", + "jest-util": "^22.4.3", + "jest-validate": "^22.4.3", + "json-stable-stringify": "^1.0.1", + "micromatch": "^2.3.11", + "realpath-native": "^1.0.0", + "slash": "^1.0.0", "strip-bom": "3.0.0", - "write-file-atomic": "2.3.0", - "yargs": "10.1.2" + "write-file-atomic": "^2.1.0", + "yargs": "^10.0.3" }, "dependencies": { "ansi-styles": { @@ -5039,7 +5039,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -5048,9 +5048,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "strip-bom": { @@ -5065,7 +5065,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5082,12 +5082,12 @@ "integrity": "sha512-JXA0gVs5YL0HtLDCGa9YxcmmV2LZbwJ+0MfyXBBc5qpgkEYITQFJP7XNhcHFbUvRiniRpRbGVfJrOoYhhGE0RQ==", "dev": true, "requires": { - "chalk": "2.3.2", - "jest-diff": "22.4.3", - "jest-matcher-utils": "22.4.3", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "pretty-format": "22.4.3" + "chalk": "^2.0.1", + "jest-diff": "^22.4.3", + "jest-matcher-utils": "^22.4.3", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "pretty-format": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -5096,7 +5096,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -5105,9 +5105,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -5116,7 +5116,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5127,13 +5127,13 @@ "integrity": "sha512-rfDfG8wyC5pDPNdcnAlZgwKnzHvZDu8Td2NJI/jAGKEGxJPYiE4F0ss/gSAkG4778Y23Hvbz+0GMrDJTeo7RjQ==", "dev": true, "requires": { - "callsites": "2.0.0", - "chalk": "2.3.2", - "graceful-fs": "4.1.11", - "is-ci": "1.0.10", - "jest-message-util": "22.4.3", - "mkdirp": "0.5.1", - "source-map": "0.6.1" + "callsites": "^2.0.0", + "chalk": "^2.0.1", + "graceful-fs": "^4.1.11", + "is-ci": "^1.0.10", + "jest-message-util": "^22.4.3", + "mkdirp": "^0.5.1", + "source-map": "^0.6.0" }, "dependencies": { "ansi-styles": { @@ -5142,7 +5142,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "callsites": { @@ -5157,9 +5157,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "source-map": { @@ -5174,7 +5174,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5185,11 +5185,11 @@ "integrity": "sha512-CfFM18W3GSP/xgmA4UouIx0ljdtfD2mjeBC6c89Gg17E44D4tQhAcTrZmf9djvipwU30kSTnk6CzcxdCCeSXfA==", "dev": true, "requires": { - "chalk": "2.3.2", - "jest-config": "22.4.3", - "jest-get-type": "22.4.3", - "leven": "2.1.0", - "pretty-format": "22.4.3" + "chalk": "^2.0.1", + "jest-config": "^22.4.3", + "jest-get-type": "^22.4.3", + "leven": "^2.1.0", + "pretty-format": "^22.4.3" }, "dependencies": { "ansi-styles": { @@ -5198,7 +5198,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -5207,9 +5207,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -5218,7 +5218,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5229,7 +5229,7 @@ "integrity": "sha512-B1ucW4fI8qVAuZmicFxI1R3kr2fNeYJyvIQ1rKcuLYnenFV5K5aMbxFj6J0i00Ju83S8jP2d7Dz14+AvbIHRYQ==", "dev": true, "requires": { - "merge-stream": "1.0.1" + "merge-stream": "^1.0.1" } }, "js-tokens": { @@ -5244,8 +5244,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "1.0.10", - "esprima": "4.0.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" } }, "jsbn": { @@ -5261,32 +5261,32 @@ "integrity": "sha512-9NzSc4Iz4gN9p4uoPbBUzro21QdgL32swaWIaWS8eEVQ2I69fRJAy/MKyvlEIk0V7HtKgfMbbOKyTZUrzR2Hsw==", "dev": true, "requires": { - "abab": "1.0.4", - "acorn": "5.5.3", - "acorn-globals": "4.1.0", - "array-equal": "1.0.0", - "cssom": "0.3.2", - "cssstyle": "0.2.37", - "data-urls": "1.0.0", - "domexception": "1.0.1", - "escodegen": "1.9.1", - "html-encoding-sniffer": "1.0.2", - "left-pad": "1.2.0", - "nwmatcher": "1.4.4", + "abab": "^1.0.4", + "acorn": "^5.3.0", + "acorn-globals": "^4.1.0", + "array-equal": "^1.0.0", + "cssom": ">= 0.3.2 < 0.4.0", + "cssstyle": ">= 0.2.37 < 0.3.0", + "data-urls": "^1.0.0", + "domexception": "^1.0.0", + "escodegen": "^1.9.0", + "html-encoding-sniffer": "^1.0.2", + "left-pad": "^1.2.0", + "nwmatcher": "^1.4.3", "parse5": "4.0.0", - "pn": "1.1.0", - "request": "2.85.0", - "request-promise-native": "1.0.5", - "sax": "1.2.4", - "symbol-tree": "3.2.2", - "tough-cookie": "2.3.4", - "w3c-hr-time": "1.0.1", - "webidl-conversions": "4.0.2", - "whatwg-encoding": "1.0.3", - "whatwg-mimetype": "2.1.0", - "whatwg-url": "6.4.0", - "ws": "4.1.0", - "xml-name-validator": "3.0.0" + "pn": "^1.1.0", + "request": "^2.83.0", + "request-promise-native": "^1.0.5", + "sax": "^1.2.4", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.3.3", + "w3c-hr-time": "^1.0.1", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.3", + "whatwg-mimetype": "^2.1.0", + "whatwg-url": "^6.4.0", + "ws": "^4.0.0", + "xml-name-validator": "^3.0.0" } }, "jsesc": { @@ -5319,7 +5319,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stable-stringify-without-jsonify": { @@ -5364,7 +5364,7 @@ "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", "dev": true, "requires": { - "array-includes": "3.0.3" + "array-includes": "^3.0.3" } }, "kind-of": { @@ -5373,7 +5373,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } }, "lazy-cache": { @@ -5389,7 +5389,7 @@ "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", "dev": true, "requires": { - "invert-kv": "1.0.0" + "invert-kv": "^1.0.0" } }, "left-pad": { @@ -5410,8 +5410,8 @@ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" } }, "lint-staged": { @@ -5420,26 +5420,26 @@ "integrity": "sha512-M/7bwLdXbeG7ZNLcasGeLMBDg60/w6obj3KOtINwJyxAxb53XGY0yH5FSZlWklEzuVbTtqtIfAajh6jYIN90AA==", "dev": true, "requires": { - "app-root-path": "2.0.1", - "chalk": "2.3.2", - "commander": "2.12.2", - "cosmiconfig": "4.0.0", - "debug": "3.1.0", - "dedent": "0.7.0", - "execa": "0.8.0", - "find-parent-dir": "0.3.0", - "is-glob": "4.0.0", - "jest-validate": "21.2.1", - "listr": "0.13.0", - "lodash": "4.17.4", - "log-symbols": "2.2.0", - "minimatch": "3.0.4", - "npm-which": "3.0.1", - "p-map": "1.2.0", - "path-is-inside": "1.0.2", - "pify": "3.0.0", + "app-root-path": "^2.0.0", + "chalk": "^2.1.0", + "commander": "^2.11.0", + "cosmiconfig": "^4.0.0", + "debug": "^3.1.0", + "dedent": "^0.7.0", + "execa": "^0.8.0", + "find-parent-dir": "^0.3.0", + "is-glob": "^4.0.0", + "jest-validate": "^21.1.0", + "listr": "^0.13.0", + "lodash": "^4.17.4", + "log-symbols": "^2.0.0", + "minimatch": "^3.0.0", + "npm-which": "^3.0.1", + "p-map": "^1.1.1", + "path-is-inside": "^1.0.2", + "pify": "^3.0.0", "staged-git-files": "1.0.0", - "stringify-object": "3.2.2" + "stringify-object": "^3.2.0" }, "dependencies": { "ansi-regex": { @@ -5454,7 +5454,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -5463,9 +5463,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "debug": { @@ -5483,13 +5483,13 @@ "integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=", "dev": true, "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "1.1.0", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" } }, "is-extglob": { @@ -5504,7 +5504,7 @@ "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", "dev": true, "requires": { - "is-extglob": "2.1.1" + "is-extglob": "^2.1.1" } }, "jest-get-type": { @@ -5519,10 +5519,10 @@ "integrity": "sha512-k4HLI1rZQjlU+EC682RlQ6oZvLrE5SCh3brseQc24vbZTxzT/k/3urar5QMCVgjadmSO7lECeGdc6YxnM3yEGg==", "dev": true, "requires": { - "chalk": "2.3.2", - "jest-get-type": "21.2.0", - "leven": "2.1.0", - "pretty-format": "21.2.1" + "chalk": "^2.0.1", + "jest-get-type": "^21.2.0", + "leven": "^2.1.0", + "pretty-format": "^21.2.1" } }, "pretty-format": { @@ -5531,8 +5531,8 @@ "integrity": "sha512-ZdWPGYAnYfcVP8yKA3zFjCn8s4/17TeYH28MXuC8vTp0o21eXjbFGcOAXZEaDaOFJjc3h2qa7HQNHNshhvoh2A==", "dev": true, "requires": { - "ansi-regex": "3.0.0", - "ansi-styles": "3.2.1" + "ansi-regex": "^3.0.0", + "ansi-styles": "^3.2.0" } }, "supports-color": { @@ -5541,7 +5541,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5552,23 +5552,23 @@ "integrity": "sha1-ILsLowuuZg7oTMBQPfS+PVYjiH0=", "dev": true, "requires": { - "chalk": "1.1.3", - "cli-truncate": "0.2.1", - "figures": "1.7.0", - "indent-string": "2.1.0", - "is-observable": "0.2.0", - "is-promise": "2.1.0", - "is-stream": "1.1.0", - "listr-silent-renderer": "1.1.1", - "listr-update-renderer": "0.4.0", - "listr-verbose-renderer": "0.4.1", - "log-symbols": "1.0.2", - "log-update": "1.0.2", - "ora": "0.2.3", - "p-map": "1.2.0", - "rxjs": "5.5.8", - "stream-to-observable": "0.2.0", - "strip-ansi": "3.0.1" + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "figures": "^1.7.0", + "indent-string": "^2.1.0", + "is-observable": "^0.2.0", + "is-promise": "^2.1.0", + "is-stream": "^1.1.0", + "listr-silent-renderer": "^1.1.1", + "listr-update-renderer": "^0.4.0", + "listr-verbose-renderer": "^0.4.0", + "log-symbols": "^1.0.2", + "log-update": "^1.0.2", + "ora": "^0.2.3", + "p-map": "^1.1.1", + "rxjs": "^5.4.2", + "stream-to-observable": "^0.2.0", + "strip-ansi": "^3.0.1" }, "dependencies": { "figures": { @@ -5577,8 +5577,8 @@ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" } }, "log-symbols": { @@ -5587,7 +5587,7 @@ "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", "dev": true, "requires": { - "chalk": "1.1.3" + "chalk": "^1.0.0" } } } @@ -5604,14 +5604,14 @@ "integrity": "sha1-NE2YDaLKLosUW6MFkI8yrj9MyKc=", "dev": true, "requires": { - "chalk": "1.1.3", - "cli-truncate": "0.2.1", - "elegant-spinner": "1.0.1", - "figures": "1.7.0", - "indent-string": "3.2.0", - "log-symbols": "1.0.2", - "log-update": "1.0.2", - "strip-ansi": "3.0.1" + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "elegant-spinner": "^1.0.1", + "figures": "^1.7.0", + "indent-string": "^3.0.0", + "log-symbols": "^1.0.2", + "log-update": "^1.0.2", + "strip-ansi": "^3.0.1" }, "dependencies": { "figures": { @@ -5620,8 +5620,8 @@ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" } }, "indent-string": { @@ -5636,7 +5636,7 @@ "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", "dev": true, "requires": { - "chalk": "1.1.3" + "chalk": "^1.0.0" } } } @@ -5647,10 +5647,10 @@ "integrity": "sha1-ggb0z21S3cWCfl/RSYng6WWTOjU=", "dev": true, "requires": { - "chalk": "1.1.3", - "cli-cursor": "1.0.2", - "date-fns": "1.29.0", - "figures": "1.7.0" + "chalk": "^1.1.3", + "cli-cursor": "^1.0.2", + "date-fns": "^1.27.2", + "figures": "^1.7.0" }, "dependencies": { "cli-cursor": { @@ -5659,7 +5659,7 @@ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "restore-cursor": "^1.0.1" } }, "figures": { @@ -5668,13 +5668,13 @@ "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" } }, "onetime": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, @@ -5684,8 +5684,8 @@ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" } } } @@ -5696,11 +5696,11 @@ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "strip-bom": "2.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" }, "dependencies": { "pify": { @@ -5717,9 +5717,9 @@ "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", "dev": true, "requires": { - "big.js": "3.2.0", - "emojis-list": "2.1.0", - "json5": "0.5.1" + "big.js": "^3.1.3", + "emojis-list": "^2.0.0", + "json5": "^0.5.0" } }, "locate-path": { @@ -5728,8 +5728,8 @@ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "2.0.0", - "path-exists": "3.0.0" + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" } }, "lodash": { @@ -5750,7 +5750,7 @@ "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", "dev": true, "requires": { - "chalk": "2.3.2" + "chalk": "^2.0.1" }, "dependencies": { "ansi-styles": { @@ -5759,7 +5759,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -5768,9 +5768,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -5779,7 +5779,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -5790,8 +5790,8 @@ "integrity": "sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=", "dev": true, "requires": { - "ansi-escapes": "1.4.0", - "cli-cursor": "1.0.2" + "ansi-escapes": "^1.0.0", + "cli-cursor": "^1.0.2" }, "dependencies": { "ansi-escapes": { @@ -5806,12 +5806,12 @@ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "restore-cursor": "^1.0.1" } }, "onetime": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, @@ -5821,8 +5821,8 @@ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" } } } @@ -5839,7 +5839,7 @@ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", "dev": true, "requires": { - "js-tokens": "3.0.2" + "js-tokens": "^3.0.0" } }, "lru-cache": { @@ -5848,8 +5848,8 @@ "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", "dev": true, "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" } }, "magic-string": { @@ -5858,7 +5858,7 @@ "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", "dev": true, "requires": { - "vlq": "0.2.3" + "vlq": "^0.2.2" } }, "make-dir": { @@ -5867,7 +5867,7 @@ "integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==", "dev": true, "requires": { - "pify": "3.0.0" + "pify": "^3.0.0" } }, "makeerror": { @@ -5876,7 +5876,7 @@ "integrity": "sha1-4BpckQnyr3lmDk6LlYd5AYT1qWw=", "dev": true, "requires": { - "tmpl": "1.0.4" + "tmpl": "1.0.x" } }, "map-cache": { @@ -5891,7 +5891,7 @@ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { - "object-visit": "1.0.1" + "object-visit": "^1.0.0" } }, "mem": { @@ -5900,7 +5900,7 @@ "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", "dev": true, "requires": { - "mimic-fn": "1.2.0" + "mimic-fn": "^1.0.0" } }, "merge": { @@ -5915,7 +5915,7 @@ "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.1" } }, "micromatch": { @@ -5924,19 +5924,19 @@ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.4" + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, "mime": { @@ -5957,7 +5957,7 @@ "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { - "mime-db": "1.33.0" + "mime-db": "~1.33.0" } }, "mimic-fn": { @@ -5972,7 +5972,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -5987,8 +5987,8 @@ "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -5997,7 +5997,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -6036,18 +6036,18 @@ "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-odd": "2.0.0", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-odd": "^2.0.0", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "arr-diff": { @@ -6082,8 +6082,8 @@ "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", "dev": true, "requires": { - "encoding": "0.1.12", - "is-stream": "1.1.0" + "encoding": "^0.1.11", + "is-stream": "^1.0.1" } }, "node-int64": { @@ -6098,10 +6098,10 @@ "integrity": "sha512-MIBs+AAd6dJ2SklbbE8RUDRlIVhU8MaNLh1A9SUZDUHPiZkWLFde6UNwG41yQHZEToHgJMXqyVZ9UcS/ReOVTg==", "dev": true, "requires": { - "growly": "1.3.0", - "semver": "5.5.0", - "shellwords": "0.1.1", - "which": "1.3.0" + "growly": "^1.3.0", + "semver": "^5.4.1", + "shellwords": "^0.1.1", + "which": "^1.3.0" } }, "normalize-package-data": { @@ -6110,10 +6110,10 @@ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { - "hosted-git-info": "2.6.0", - "is-builtin-module": "1.0.0", - "semver": "5.5.0", - "validate-npm-package-license": "3.0.3" + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "normalize-path": { @@ -6122,7 +6122,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "npm-path": { @@ -6131,7 +6131,7 @@ "integrity": "sha512-IFsj0R9C7ZdR5cP+ET342q77uSRdtWOlWpih5eC+lu29tIDbNEgDbzgVJ5UFvYHWhxDZ5TFkJafFioO0pPQjCw==", "dev": true, "requires": { - "which": "1.3.0" + "which": "^1.2.10" } }, "npm-run-path": { @@ -6140,7 +6140,7 @@ "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { - "path-key": "2.0.1" + "path-key": "^2.0.0" } }, "npm-which": { @@ -6149,9 +6149,9 @@ "integrity": "sha1-kiXybsOihcIJyuZ8OxGmtKtxQKo=", "dev": true, "requires": { - "commander": "2.12.2", - "npm-path": "2.0.4", - "which": "1.3.0" + "commander": "^2.9.0", + "npm-path": "^2.0.2", + "which": "^1.2.10" } }, "number-is-nan": { @@ -6184,9 +6184,9 @@ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" }, "dependencies": { "define-property": { @@ -6195,7 +6195,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "is-accessor-descriptor": { @@ -6204,7 +6204,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-data-descriptor": { @@ -6213,7 +6213,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-descriptor": { @@ -6222,9 +6222,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" }, "dependencies": { "kind-of": { @@ -6249,7 +6249,7 @@ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -6266,8 +6266,8 @@ "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", "dev": true, "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.10.0" + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" } }, "object.omit": { @@ -6276,8 +6276,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, "object.pick": { @@ -6286,7 +6286,7 @@ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -6303,7 +6303,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "onetime": { @@ -6312,7 +6312,7 @@ "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, "requires": { - "mimic-fn": "1.2.0" + "mimic-fn": "^1.0.0" } }, "opener": { @@ -6327,8 +6327,8 @@ "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "minimist": "0.0.8", - "wordwrap": "0.0.3" + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" }, "dependencies": { "wordwrap": { @@ -6345,12 +6345,12 @@ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" } }, "ora": { @@ -6359,10 +6359,10 @@ "integrity": "sha1-N1J9Igrc1Tw5tzVx11QVbV22V6Q=", "dev": true, "requires": { - "chalk": "1.1.3", - "cli-cursor": "1.0.2", - "cli-spinners": "0.1.2", - "object-assign": "4.1.1" + "chalk": "^1.1.1", + "cli-cursor": "^1.0.2", + "cli-spinners": "^0.1.2", + "object-assign": "^4.0.1" }, "dependencies": { "cli-cursor": { @@ -6371,12 +6371,12 @@ "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "restore-cursor": "^1.0.1" } }, "onetime": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, @@ -6386,8 +6386,8 @@ "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" } } } @@ -6404,9 +6404,9 @@ "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "dev": true, "requires": { - "execa": "0.7.0", - "lcid": "1.0.0", - "mem": "1.1.0" + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" } }, "os-tmpdir": { @@ -6427,7 +6427,7 @@ "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", "dev": true, "requires": { - "p-try": "1.0.0" + "p-try": "^1.0.0" } }, "p-locate": { @@ -6436,7 +6436,7 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "1.2.0" + "p-limit": "^1.1.0" } }, "p-map": { @@ -6457,10 +6457,10 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, "parse-json": { @@ -6469,7 +6469,7 @@ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { - "error-ex": "1.3.1" + "error-ex": "^1.2.0" } }, "parse5": { @@ -6520,9 +6520,9 @@ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "pify": { @@ -6563,7 +6563,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "2.0.4" + "pinkie": "^2.0.0" } }, "pkg-dir": { @@ -6572,7 +6572,7 @@ "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "2.1.0" + "find-up": "^2.1.0" } }, "pluralize": { @@ -6617,8 +6617,8 @@ "integrity": "sha512-S4oT9/sT6MN7/3COoOy+ZJeA92VmOnveLHgrwBE3Z1W5N9S2A1QGNYiE1z75DAENbJrXXUb+OWXhpJcg05QKQQ==", "dev": true, "requires": { - "ansi-regex": "3.0.0", - "ansi-styles": "3.2.1" + "ansi-regex": "^3.0.0", + "ansi-styles": "^3.2.0" }, "dependencies": { "ansi-regex": { @@ -6633,7 +6633,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } } } @@ -6662,7 +6662,7 @@ "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", "dev": true, "requires": { - "asap": "2.0.6" + "asap": "~2.0.3" } }, "prop-types": { @@ -6671,9 +6671,9 @@ "integrity": "sha512-4ec7bY1Y66LymSUOH/zARVYObB23AT2h8cf6e/O6ZALB/N0sqZFEx7rq6EYPX2MkOdKORuooI/H5k9TlR4q7kQ==", "dev": true, "requires": { - "fbjs": "0.8.16", - "loose-envify": "1.3.1", - "object-assign": "4.1.1" + "fbjs": "^0.8.16", + "loose-envify": "^1.3.1", + "object-assign": "^4.1.1" } }, "pseudomap": { @@ -6700,8 +6700,8 @@ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -6710,7 +6710,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -6719,7 +6719,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -6730,7 +6730,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -6741,9 +6741,9 @@ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { - "load-json-file": "1.1.0", - "normalize-package-data": "2.4.0", - "path-type": "1.1.0" + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" } }, "read-pkg-up": { @@ -6752,8 +6752,8 @@ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, "requires": { - "find-up": "1.1.2", - "read-pkg": "1.1.0" + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" }, "dependencies": { "find-up": { @@ -6762,8 +6762,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "path-exists": { @@ -6772,7 +6772,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "2.0.1" + "pinkie-promise": "^2.0.0" } } } @@ -6783,13 +6783,13 @@ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "realpath-native": { @@ -6798,7 +6798,7 @@ "integrity": "sha512-XJtlRJ9jf0E1H1SLeJyQ9PGzQD7S65h1pRXEcAeK48doKOnKxcgPeNohJvD5u/2sI9J1oke6E8bZHS/fmW1UiQ==", "dev": true, "requires": { - "util.promisify": "1.0.0" + "util.promisify": "^1.0.0" } }, "regenerator-runtime": { @@ -6813,7 +6813,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "0.1.3" + "is-equal-shallow": "^0.1.3" } }, "regex-not": { @@ -6822,8 +6822,8 @@ "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, "regexpp": { @@ -6856,7 +6856,7 @@ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { - "is-finite": "1.0.2" + "is-finite": "^1.0.0" } }, "request": { @@ -6865,28 +6865,28 @@ "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", "dev": true, "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.18", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "hawk": "~6.0.2", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "stringstream": "~0.0.5", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" } }, "request-promise-core": { @@ -6895,7 +6895,7 @@ "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", "dev": true, "requires": { - "lodash": "4.17.4" + "lodash": "^4.13.1" } }, "request-promise-native": { @@ -6905,8 +6905,8 @@ "dev": true, "requires": { "request-promise-core": "1.1.1", - "stealthy-require": "1.1.1", - "tough-cookie": "2.3.4" + "stealthy-require": "^1.1.0", + "tough-cookie": ">=2.3.3" } }, "require-directory": { @@ -6933,8 +6933,8 @@ "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { - "caller-path": "0.1.0", - "resolve-from": "1.0.1" + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" } }, "resolve": { @@ -6943,7 +6943,7 @@ "integrity": "sha512-mw7JQNu5ExIkcw4LPih0owX/TZXjD/ZUF/ZQ/pDnkw3ZKhDcZZw5klmBlj6gVMwjQ3Pz5Jgu7F3d0jcDVuEWdw==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resolve-cwd": { @@ -6952,7 +6952,7 @@ "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", "dev": true, "requires": { - "resolve-from": "3.0.0" + "resolve-from": "^3.0.0" }, "dependencies": { "resolve-from": { @@ -6981,8 +6981,8 @@ "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "onetime": "2.0.1", - "signal-exit": "3.0.2" + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" } }, "ret": { @@ -6998,7 +6998,7 @@ "dev": true, "optional": true, "requires": { - "align-text": "0.1.4" + "align-text": "^0.1.1" } }, "rimraf": { @@ -7007,7 +7007,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "rollup-plugin-babel": { @@ -7016,7 +7016,7 @@ "integrity": "sha512-5kzM/Rr4jQSRPLc2eN5NuD+CI/6AAy7S1O18Ogu4U3nq1Q42VJn0C9EMtqnvxtfwf1XrezOtdA9ro1VZI5B0mA==", "dev": true, "requires": { - "rollup-pluginutils": "1.5.2" + "rollup-pluginutils": "^1.5.0" } }, "rollup-plugin-commonjs": { @@ -7025,11 +7025,11 @@ "integrity": "sha512-mg+WuD+jlwoo8bJtW3Mvx7Tz6TsIdMsdhuvCnDMoyjh0oxsVgsjB/N0X984RJCWwc5IIiqNVJhXeeITcc73++A==", "dev": true, "requires": { - "acorn": "5.5.3", - "estree-walker": "0.5.1", - "magic-string": "0.22.5", - "resolve": "1.6.0", - "rollup-pluginutils": "2.0.1" + "acorn": "^5.2.1", + "estree-walker": "^0.5.0", + "magic-string": "^0.22.4", + "resolve": "^1.4.0", + "rollup-pluginutils": "^2.0.1" }, "dependencies": { "estree-walker": { @@ -7044,8 +7044,8 @@ "integrity": "sha1-fslbNXP2VDpGpkYb2afFRFJdD8A=", "dev": true, "requires": { - "estree-walker": "0.3.1", - "micromatch": "2.3.11" + "estree-walker": "^0.3.0", + "micromatch": "^2.3.11" }, "dependencies": { "estree-walker": { @@ -7064,7 +7064,7 @@ "integrity": "sha512-W45nZH7lmXgkSR/DkeyF4ks0YWFrMysdjUT049gTuAg+lwUEDBKI2+PztqW8UDSMlXCAeEONsLzpDDyBy9m+9A==", "dev": true, "requires": { - "rollup-pluginutils": "2.0.1" + "rollup-pluginutils": "^2.0.1" }, "dependencies": { "estree-walker": { @@ -7079,8 +7079,8 @@ "integrity": "sha1-fslbNXP2VDpGpkYb2afFRFJdD8A=", "dev": true, "requires": { - "estree-walker": "0.3.1", - "micromatch": "2.3.11" + "estree-walker": "^0.3.0", + "micromatch": "^2.3.11" } } } @@ -7091,9 +7091,9 @@ "integrity": "sha512-9zHGr3oUJq6G+X0oRMYlzid9fXicBdiydhwGChdyeNRGPcN/majtegApRKHLR5drboUvEWU+QeUmGTyEZQs3WA==", "dev": true, "requires": { - "builtin-modules": "2.0.0", - "is-module": "1.0.0", - "resolve": "1.6.0" + "builtin-modules": "^2.0.0", + "is-module": "^1.0.0", + "resolve": "^1.1.6" }, "dependencies": { "builtin-modules": { @@ -7110,8 +7110,8 @@ "integrity": "sha512-lQX8/MSgWDrsbp8euBQKxJ9O2KxQerMVmStYi3zlP9jYL1v3OPtWyXbWNRfgeQTTNJtcQvaZglMGWw9YTLWw3A==", "dev": true, "requires": { - "mime": "1.6.0", - "opener": "1.4.3" + "mime": "^1.3.6", + "opener": "^1.4.3" } }, "rollup-plugin-uglify": { @@ -7120,7 +7120,7 @@ "integrity": "sha1-Z7N60e/a+9g69MNrQMGJ7khmyWk=", "dev": true, "requires": { - "uglify-js": "3.3.3" + "uglify-js": "^3.0.9" }, "dependencies": { "source-map": { @@ -7135,8 +7135,8 @@ "integrity": "sha512-blnyad6BpMsz0H4P2Ck863hy0aORNb75ty+o4h0JwMFKeRvrUkmaY7USQWRTsGE2uHcj9F2uAPCJBNVISknH/g==", "dev": true, "requires": { - "commander": "2.12.2", - "source-map": "0.6.1" + "commander": "~2.12.1", + "source-map": "~0.6.1" } } } @@ -7147,8 +7147,8 @@ "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=", "dev": true, "requires": { - "estree-walker": "0.2.1", - "minimatch": "3.0.4" + "estree-walker": "^0.2.1", + "minimatch": "^3.0.2" } }, "run-async": { @@ -7157,7 +7157,7 @@ "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "dev": true, "requires": { - "is-promise": "2.1.0" + "is-promise": "^2.1.0" } }, "rx-lite": { @@ -7172,7 +7172,7 @@ "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", "dev": true, "requires": { - "rx-lite": "4.0.8" + "rx-lite": "*" } }, "rxjs": { @@ -7204,7 +7204,7 @@ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { - "ret": "0.1.15" + "ret": "~0.1.10" } }, "sane": { @@ -7213,14 +7213,14 @@ "integrity": "sha512-glfKd7YH4UCrh/7dD+UESsr8ylKWRE7UQPoXuz28FgmcF0ViJQhCTCCZHICRKxf8G8O1KdLEn20dcICK54c7ew==", "dev": true, "requires": { - "anymatch": "2.0.0", - "exec-sh": "0.2.1", - "fb-watchman": "2.0.0", - "fsevents": "1.1.3", - "micromatch": "3.1.10", - "minimist": "1.2.0", - "walker": "1.0.7", - "watch": "0.18.0" + "anymatch": "^2.0.0", + "exec-sh": "^0.2.0", + "fb-watchman": "^2.0.0", + "fsevents": "^1.1.1", + "micromatch": "^3.1.4", + "minimist": "^1.1.1", + "walker": "~1.0.5", + "watch": "~0.18.0" }, "dependencies": { "arr-diff": { @@ -7241,18 +7241,18 @@ "integrity": "sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "define-property": "1.0.0", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "kind-of": "6.0.2", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "kind-of": "^6.0.2", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -7261,7 +7261,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -7270,7 +7270,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -7281,13 +7281,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -7296,7 +7296,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -7305,7 +7305,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-descriptor": { @@ -7314,9 +7314,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -7333,14 +7333,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -7349,7 +7349,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -7358,7 +7358,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -7369,10 +7369,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -7381,7 +7381,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -7392,7 +7392,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7401,7 +7401,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7412,7 +7412,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7421,7 +7421,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7432,7 +7432,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7441,7 +7441,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7464,19 +7464,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.1", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } }, "minimist": { @@ -7511,10 +7511,10 @@ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -7523,7 +7523,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -7540,7 +7540,7 @@ "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { - "shebang-regex": "1.0.0" + "shebang-regex": "^1.0.0" } }, "shebang-regex": { @@ -7573,7 +7573,7 @@ "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0" + "is-fullwidth-code-point": "^2.0.0" } }, "snapdragon": { @@ -7582,14 +7582,14 @@ "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.1", - "use": "3.1.0" + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" }, "dependencies": { "define-property": { @@ -7598,7 +7598,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -7607,7 +7607,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-accessor-descriptor": { @@ -7616,7 +7616,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7625,7 +7625,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7636,7 +7636,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7645,7 +7645,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7656,9 +7656,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -7675,9 +7675,9 @@ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" }, "dependencies": { "define-property": { @@ -7686,7 +7686,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "isobject": { @@ -7703,7 +7703,7 @@ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.2.0" } }, "sntp": { @@ -7712,7 +7712,7 @@ "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "source-map": { @@ -7727,11 +7727,11 @@ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", "dev": true, "requires": { - "atob": "2.1.0", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" + "atob": "^2.0.0", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-support": { @@ -7740,7 +7740,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.6" } }, "source-map-url": { @@ -7755,8 +7755,8 @@ "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { - "spdx-expression-parse": "3.0.0", - "spdx-license-ids": "3.0.0" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-exceptions": { @@ -7771,8 +7771,8 @@ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { - "spdx-exceptions": "2.1.0", - "spdx-license-ids": "3.0.0" + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-license-ids": { @@ -7787,7 +7787,7 @@ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "extend-shallow": "3.0.2" + "extend-shallow": "^3.0.0" } }, "sprintf-js": { @@ -7802,14 +7802,14 @@ "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "dev": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" } }, "stack-utils": { @@ -7830,8 +7830,8 @@ "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" + "define-property": "^0.2.5", + "object-copy": "^0.1.0" }, "dependencies": { "define-property": { @@ -7840,7 +7840,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "is-accessor-descriptor": { @@ -7849,7 +7849,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7858,7 +7858,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7869,7 +7869,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -7878,7 +7878,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -7889,9 +7889,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -7914,7 +7914,7 @@ "integrity": "sha1-WdbqOT2HwsDdrBCqDVYbxrpvDhA=", "dev": true, "requires": { - "any-observable": "0.2.0" + "any-observable": "^0.2.0" } }, "string-length": { @@ -7923,8 +7923,8 @@ "integrity": "sha1-1A27aGo6zpYMHP/KVivyxF+DY+0=", "dev": true, "requires": { - "astral-regex": "1.0.0", - "strip-ansi": "4.0.0" + "astral-regex": "^1.0.0", + "strip-ansi": "^4.0.0" }, "dependencies": { "ansi-regex": { @@ -7939,7 +7939,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -7950,8 +7950,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" }, "dependencies": { "ansi-regex": { @@ -7966,7 +7966,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -7977,7 +7977,7 @@ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "stringify-object": { @@ -7986,9 +7986,9 @@ "integrity": "sha512-O696NF21oLiDy8PhpWu8AEqoZHw++QW6mUv0UvKZe8gWSdSvMXkiLufK7OmnP27Dro4GU5kb9U7JIO0mBuCRQg==", "dev": true, "requires": { - "get-own-enumerable-property-symbols": "2.0.1", - "is-obj": "1.0.1", - "is-regexp": "1.0.0" + "get-own-enumerable-property-symbols": "^2.0.1", + "is-obj": "^1.0.1", + "is-regexp": "^1.0.0" } }, "stringstream": { @@ -8003,7 +8003,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-bom": { @@ -8012,7 +8012,7 @@ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "is-utf8": "0.2.1" + "is-utf8": "^0.2.0" } }, "strip-eof": { @@ -8057,12 +8057,12 @@ "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "dev": true, "requires": { - "ajv": "5.5.2", - "ajv-keywords": "2.1.1", - "chalk": "2.3.2", - "lodash": "4.17.4", + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", "slice-ansi": "1.0.0", - "string-width": "2.1.1" + "string-width": "^2.1.1" }, "dependencies": { "ansi-styles": { @@ -8071,7 +8071,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "chalk": { @@ -8080,9 +8080,9 @@ "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "supports-color": { @@ -8091,7 +8091,7 @@ "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } } } @@ -8102,11 +8102,11 @@ "integrity": "sha512-qpqlP/8Zl+sosLxBcVKl9vYy26T9NPalxSzzCP/OY6K7j938ui2oKgo+kRZYfxAeIpLqpbVnsHq1tyV70E4lWQ==", "dev": true, "requires": { - "arrify": "1.0.1", - "micromatch": "3.1.10", - "object-assign": "4.1.1", - "read-pkg-up": "1.0.1", - "require-main-filename": "1.0.1" + "arrify": "^1.0.1", + "micromatch": "^3.1.8", + "object-assign": "^4.1.0", + "read-pkg-up": "^1.0.1", + "require-main-filename": "^1.0.1" }, "dependencies": { "arr-diff": { @@ -8127,18 +8127,18 @@ "integrity": "sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "define-property": "1.0.0", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "kind-of": "6.0.2", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "kind-of": "^6.0.2", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -8147,7 +8147,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -8156,7 +8156,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -8167,13 +8167,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -8182,7 +8182,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -8191,7 +8191,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-descriptor": { @@ -8200,9 +8200,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -8219,14 +8219,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -8235,7 +8235,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -8244,7 +8244,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -8255,10 +8255,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -8267,7 +8267,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -8278,7 +8278,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -8287,7 +8287,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -8298,7 +8298,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -8307,7 +8307,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -8318,7 +8318,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -8327,7 +8327,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -8350,19 +8350,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.1", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } } } @@ -8391,7 +8391,7 @@ "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { - "os-tmpdir": "1.0.2" + "os-tmpdir": "~1.0.2" } }, "tmpl": { @@ -8412,7 +8412,7 @@ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "to-regex": { @@ -8421,10 +8421,10 @@ "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" } }, "to-regex-range": { @@ -8433,8 +8433,8 @@ "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" }, "dependencies": { "is-number": { @@ -8443,7 +8443,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } } } @@ -8454,7 +8454,7 @@ "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" }, "dependencies": { "punycode": { @@ -8471,7 +8471,7 @@ "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", "dev": true, "requires": { - "punycode": "2.1.0" + "punycode": "^2.1.0" } }, "trim-right": { @@ -8486,7 +8486,7 @@ "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "dev": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -8502,7 +8502,7 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { - "prelude-ls": "1.1.2" + "prelude-ls": "~1.1.2" } }, "type-detect": { @@ -8529,8 +8529,8 @@ "integrity": "sha512-rPzPisCzW68Okj1zNrfa2dR9uEm43SevDmpR6FChoZABFk9dANGnzzBMgHYUXI3609//63fnVkyQ1SQmAMyjww==", "dev": true, "requires": { - "commander": "2.14.1", - "source-map": "0.6.1" + "commander": "~2.14.1", + "source-map": "~0.6.1" }, "dependencies": { "commander": { @@ -8560,10 +8560,10 @@ "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "dev": true, "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" }, "dependencies": { "extend-shallow": { @@ -8572,7 +8572,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "set-value": { @@ -8581,10 +8581,10 @@ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" } } } @@ -8595,8 +8595,8 @@ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" + "has-value": "^0.3.1", + "isobject": "^3.0.0" }, "dependencies": { "has-value": { @@ -8605,9 +8605,9 @@ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" }, "dependencies": { "isobject": { @@ -8647,7 +8647,7 @@ "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" }, "dependencies": { "kind-of": { @@ -8670,8 +8670,8 @@ "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", "dev": true, "requires": { - "define-properties": "1.1.2", - "object.getownpropertydescriptors": "2.0.3" + "define-properties": "^1.1.2", + "object.getownpropertydescriptors": "^2.0.3" } }, "uuid": { @@ -8686,8 +8686,8 @@ "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { - "spdx-correct": "3.0.0", - "spdx-expression-parse": "3.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, "verror": { @@ -8696,9 +8696,9 @@ "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "vlq": { @@ -8713,7 +8713,7 @@ "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", "dev": true, "requires": { - "browser-process-hrtime": "0.1.2" + "browser-process-hrtime": "^0.1.2" } }, "walker": { @@ -8722,7 +8722,7 @@ "integrity": "sha1-L3+bj9ENZ3JisYqITijRlhjgKPs=", "dev": true, "requires": { - "makeerror": "1.0.11" + "makeerror": "1.0.x" } }, "watch": { @@ -8731,8 +8731,8 @@ "integrity": "sha1-KAlUdsbffJDJYxOJkMClQj60uYY=", "dev": true, "requires": { - "exec-sh": "0.2.1", - "minimist": "1.2.0" + "exec-sh": "^0.2.0", + "minimist": "^1.2.0" }, "dependencies": { "minimist": { @@ -8776,9 +8776,9 @@ "integrity": "sha512-Z0CVh/YE217Foyb488eo+iBv+r7eAQ0wSTyApi9n06jhcA3z6Nidg/EGvl0UFkg7kMdKxfBzzr+o9JF+cevgMg==", "dev": true, "requires": { - "lodash.sortby": "4.7.0", - "tr46": "1.0.1", - "webidl-conversions": "4.0.2" + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.0", + "webidl-conversions": "^4.0.1" } }, "which": { @@ -8787,7 +8787,7 @@ "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, "which-module": { @@ -8815,8 +8815,8 @@ "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1" + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" }, "dependencies": { "is-fullwidth-code-point": { @@ -8825,7 +8825,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "string-width": { @@ -8834,9 +8834,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } } } @@ -8853,7 +8853,7 @@ "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, "requires": { - "mkdirp": "0.5.1" + "mkdirp": "^0.5.1" } }, "write-file-atomic": { @@ -8862,9 +8862,9 @@ "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "imurmurhash": "0.1.4", - "signal-exit": "3.0.2" + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" } }, "ws": { @@ -8873,8 +8873,8 @@ "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==", "dev": true, "requires": { - "async-limiter": "1.0.0", - "safe-buffer": "5.1.1" + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0" } }, "xml-name-validator": { @@ -8901,18 +8901,18 @@ "integrity": "sha512-ivSoxqBGYOqQVruxD35+EyCFDYNEFL/Uo6FcOnz+9xZdZzK0Zzw4r4KhbrME1Oo2gOggwJod2MnsdamSG7H9ig==", "dev": true, "requires": { - "cliui": "4.0.0", - "decamelize": "1.2.0", - "find-up": "2.1.0", - "get-caller-file": "1.0.2", - "os-locale": "2.1.0", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "2.1.1", - "which-module": "2.0.0", - "y18n": "3.2.1", - "yargs-parser": "8.1.0" + "cliui": "^4.0.0", + "decamelize": "^1.1.1", + "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^8.1.0" }, "dependencies": { "ansi-regex": { @@ -8927,9 +8927,9 @@ "integrity": "sha512-nY3W5Gu2racvdDk//ELReY+dHjb9PlIcVDFXP72nVIhq2Gy3LuVXYwJoPVudwQnv1shtohpgkdCKT2YaKY0CKw==", "dev": true, "requires": { - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "wrap-ansi": "2.1.0" + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" } }, "strip-ansi": { @@ -8938,7 +8938,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -8949,7 +8949,7 @@ "integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==", "dev": true, "requires": { - "camelcase": "4.1.0" + "camelcase": "^4.1.0" }, "dependencies": { "camelcase": { diff --git a/package.json b/package.json index 65b0b12..d838526 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ }, "prettier": { "singleQuote": true, - "trailing-comma": "es5", + "trailing-comma": "all", "arrowParens": "always", "parser": "flow" }, diff --git a/source/__tests__/prefixes.js b/source/__tests__/prefixes.js new file mode 100644 index 0000000..e69de29 diff --git a/source/__tests__/utils.js b/source/__tests__/utils.js new file mode 100644 index 0000000..e69de29 diff --git a/source/__tests__/wrapper.js b/source/__tests__/wrapper.js new file mode 100644 index 0000000..e69de29 diff --git a/source/augmentations/__tests__/core.js b/source/augmentations/__tests__/core.js new file mode 100644 index 0000000..e69de29 diff --git a/source/augmentations/__tests__/list.js b/source/augmentations/__tests__/list.js new file mode 100644 index 0000000..e69de29 diff --git a/source/augmentations/__tests__/node.js b/source/augmentations/__tests__/node.js new file mode 100644 index 0000000..e69de29 diff --git a/source/augmentations/list.js b/source/augmentations/list.js index 9b6e47a..f20a500 100644 --- a/source/augmentations/list.js +++ b/source/augmentations/list.js @@ -4,38 +4,45 @@ const length = (node, adapter) => { } else if (adapter.isNode(node)) { return 1; } + return 0; }; -const first = (node, adapter, args, utils) => { - let result = node; +const at = (node, adapter, args, utils) => { + const [index] = args; + // return empty array, which will create empty wrapper for chained calls, + // this will make next calls errorless. + let result = []; if (adapter.isList(node)) { - if (node.length) { - ([result] = node); - } else { - result = []; + const child = adapter.getNodeAt(node, index); + + if (child) { + result = child; } } return utils.wrap(result, adapter); }; +const first = (node, adapter, args, utils) => at(node, adapter, [0], utils); + const filter = (node, adapter, [callback], utils) => { // apply filter on element collection // always return wrapped list - node = adapter.toList(node); - const list = []; + const list = adapter.toList(node); + const listLength = adapter.getLength(node); + const result = []; - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); if (callback(utils.wrap(child, adapter), index, wrappedNode)) { - list.push(child); + result.push(child); } } - return utils.wrap(list, adapter); + return utils.wrap(result, adapter); }; const map = (node, adapter, [callback, wrapNodes = true], utils) => { @@ -43,38 +50,51 @@ const map = (node, adapter, [callback, wrapNodes = true], utils) => { // if wrapNodes in FALSE, will generate normal Array with RAW results in it // if wrapNodes in TRUE and all elements of resulting list are nodes, will // generate wrapped list and put all result into it - node = adapter.toList(node); - const list = []; + const list = adapter.toList(node); + const listLength = adapter.getLength(list); + const result = []; let areNodes = true; - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; - const result = callback(utils.wrap(child, adapter), index, wrappedNode); - areNodes = areNodes && adapter.isNode(result); - list.push(result); + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); + const childResult = callback( + utils.wrap(child, adapter), + index, + wrappedNode + ); + areNodes = areNodes && adapter.isNode(childResult); + result.push(childResult); } - return wrapNodes && areNodes ? utils.wrap(list, adapter) : list; + return wrapNodes && areNodes ? utils.wrap(result, adapter) : result; }; const reduce = (node, adapter, [callback, result], utils) => { // apply reduce on element collection - node = adapter.toList(node); + const list = adapter.toList(node); + const listLength = adapter.getLength(node); + let lastResult = result; - const wrappedNode = utils.wrap(node, adapter); - for (let index = 0; index < node.length; index += 1) { - const child = node[index]; - result = callback(result, utils.wrap(child, adapter), index, wrappedNode); + const wrappedNode = utils.wrap(list, adapter); + for (let index = 0; index < listLength; index += 1) { + const child = adapter.getNodeAt(list, index); + lastResult = callback( + result, + utils.wrap(child, adapter), + index, + wrappedNode + ); } - return result; + return lastResult; }; export default { length, + at, first, filter, map, - reduce, + reduce }; diff --git a/source/augmentations/node.js b/source/augmentations/node.js index c545b15..9f5cd44 100644 --- a/source/augmentations/node.js +++ b/source/augmentations/node.js @@ -1,3 +1,4 @@ +/* eslint-disable prefer-spread */ const children = (node, adapter, [childName], utils) => { let list; @@ -10,6 +11,53 @@ const children = (node, adapter, [childName], utils) => { return utils.wrap(list, adapter); }; +/** + * @internal + */ +const descendantsAll = (node, adapter, args, utils) => { + const result = []; + const list = adapter.getChildren(node); + const length = adapter.getLength(list, adapter); + + for (let index = 0; index < length; index += 1) { + const child = list[index]; + result.push(child); + result.push.apply(result, descendantsAll(child, adapter, args, utils)); + } + + return result; +}; + +/** + * @internal + */ +const descendantsByName = (node, adapter, args, utils) => { + const [childName] = args; + const result = []; + const list = adapter.getChildren(node); + const length = adapter.getLength(list, adapter); + + for (let index = 0; index < length; index += 1) { + const child = list[index]; + if (adapter.getName(child) === childName) { + result.push(child); + } + result.push.apply(result, descendantsByName(child, adapter, args, utils)); + } + + return result; +}; + +const descendants = (node, adapter, args, utils) => { + const [childName] = args; + + if (childName) { + return utils.wrap(descendantsByName(node, adapter, args, utils), adapter); + } + + return utils.wrap(descendantsAll(node, adapter, args, utils), adapter); +}; + const childAt = (node, adapter, [index = 0], utils) => utils.wrap(adapter.getChildAt(node, index), adapter); @@ -19,10 +67,10 @@ const root = (node, adapter, args, utils) => const parent = (node, adapter, args, utils) => utils.wrap(adapter.getNodeParent(node), adapter); - export default { children, + descendants, childAt, root, - parent, + parent }; diff --git a/source/prefixes.js b/source/prefixes.js index 5235f3e..f9eb9f4 100644 --- a/source/prefixes.js +++ b/source/prefixes.js @@ -1,17 +1,15 @@ const namePrefixes = {}; -export const isValidPrefix = (prefix) => ( - typeof prefix === 'string' - && prefix.length === 1 - && namePrefixes.hasOwnProperty(prefix) -); +export const isValidPrefix = (prefix) => + typeof prefix === 'string' && + prefix.length === 1 && + namePrefixes.hasOwnProperty(prefix); -export const isPrefixedKey = (key) => ( - key - && typeof(key) === 'string' - && key.length > 1 - && namePrefixes.hasOwnProperty(key.charAt()) -); +export const isPrefixedKey = (key) => + key && + typeof key === 'string' && + key.length > 1 && + namePrefixes.hasOwnProperty(key.charAt()); export const getPrefixHandler = (key) => namePrefixes[key.charAt()]; diff --git a/source/stub-adapter.js b/source/stub-adapter.js index 344e4a0..cd4aa02 100644 --- a/source/stub-adapter.js +++ b/source/stub-adapter.js @@ -14,12 +14,13 @@ const adapter = { // node methods isNode: fn, toNode: fn, + getName: fn, hasChild: fn, getChildren: fn, getChildrenByName: fn, getChildAt: fn, getNodeParent: fn, - getNodeRoot: fn, + getNodeRoot: fn }; export default adapter; From 305e6e07d719a452dc2e4063d3fa4f5831265543 Mon Sep 17 00:00:00 2001 From: Oleg Galaburda Date: Mon, 20 Aug 2018 14:06:42 +0300 Subject: [PATCH 2/5] add docs --- .editorconfig | 17 ++ .env | 0 .eslintrc | 19 +- .prettierrc | 6 + .travis.yml | 11 +- README.md | 251 +++++++++++++++++- dist/tree-walker.js | 140 ++++++---- dist/tree-walker.js.map | 2 +- dist/tree-walker.min.js | 2 +- dist/tree-walker.min.js.map | 2 +- eslintrc.spec.json | 3 +- example/index.html | 9 +- example/onode-adapter.js | 18 +- example/onode.js | 29 +- example/tree-walker.min.js | 2 +- example/tree-walker.min.js.map | 2 +- fixtures/index.js | 45 ++++ .../{test-adapter.js => onode-adapter.js} | 16 +- fixtures/onode.js | 67 +++++ fixtures/tree.js | 55 ---- package-lock.json | 17 ++ package.json | 15 +- rollup.helpers.js | 8 +- source/__tests__/default-adapter.js | 27 ++ source/__tests__/index.js | 58 +++- source/__tests__/prefixes.js | 113 ++++++++ source/__tests__/utils.js | 85 ++++++ source/__tests__/wrapper.js | 115 ++++++++ source/augmentations/__tests__/core.js | 25 ++ source/augmentations/__tests__/index.js | 83 ++++++ source/augmentations/__tests__/list.js | 163 ++++++++++++ source/augmentations/__tests__/node.js | 152 +++++++++++ source/augmentations/core.js | 1 - source/augmentations/index.js | 11 +- source/augmentations/list.js | 33 ++- source/augmentations/node.js | 29 +- source/default-adapter.js | 2 +- source/prefixes.js | 8 +- source/stub-adapter.js | 26 -- source/utils.js | 22 +- source/wrapper.js | 68 +++-- stub-adapter.js | 119 +++++++++ 42 files changed, 1612 insertions(+), 264 deletions(-) create mode 100644 .editorconfig create mode 100644 .env create mode 100644 .prettierrc create mode 100644 fixtures/index.js rename fixtures/{test-adapter.js => onode-adapter.js} (60%) create mode 100644 fixtures/onode.js delete mode 100644 fixtures/tree.js create mode 100644 source/__tests__/default-adapter.js create mode 100644 source/augmentations/__tests__/index.js delete mode 100644 source/stub-adapter.js create mode 100644 stub-adapter.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..370647b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.js] +charset = utf-8 +indent_style = space +indent_size = 2 +trim_trailing_whitespace = false diff --git a/.env b/.env new file mode 100644 index 0000000..e69de29 diff --git a/.eslintrc b/.eslintrc index 6bacd8a..486dd67 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,6 +12,21 @@ "browser": true, "node": true }, + "globals": { + "jest": true, + "describe": true, + "it": true, + "test": true, + "expect": true, + "should": true, + "assert": true, + "beforeEach": true, + "afterEach": true, + "beforeAll": true, + "afterAll": true, + "before": true, + "after": true + }, "rules": { "arrow-parens": [ "error", @@ -25,6 +40,8 @@ ], "no-param-reassign": 1, "padded-blocks": 0, - "no-plusplus": 0 + "no-plusplus": 0, + "function-paren-newline": 0, + "no-bitwise": 0 } } diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..70c233a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "arrowParens": "always", + "parser": "flow" +} diff --git a/.travis.yml b/.travis.yml index 06b1246..a3c8100 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ language: node_js node_js: - "8" -addons: - firefox: "latest" before_script: - - npm install rollup -g - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - sleep 3 - - webpack + - npm install rollup jest-cli eslint coveralls -g + - npm run build + - npm run lint +script: npm run test -- --coverage --coverageReporters=text-lcov | coveralls diff --git a/README.md b/README.md index 1ed13d4..01318da 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,248 @@ This is wireframe based on ES6 Proxies for making tree traversing APIs. You may check ready to use implementation DOMWalker for better understanding. Inspired by [E4X(ECMAScript for XML)](https://en.wikipedia.org/wiki/ECMAScript_for_XML) and its ActionScript 3 implementation. RIP. -To use TreeWalker, developer should implement adapter for source data structure, -additionally augmentations and prefixes could be used to enrich final API. +## Installation -Augmentations and prefixes should interact with data structure only by using adapter -methods, this way they will be kept agnostic to data structures and can be used with -any adapter i.e. data structure. +Via NPM +``` +npm install @actualwave/tree-walker --save +``` +Or Yarn +``` +yarn add @actualwave/tree-walker +``` -### TODO add docs +After importing TreeWalker, it needs to be configured to specify default adapter and augmentations, prefixes. Without any configurations you will be able to access child nodes +``` +const root = create(mySourceTreeData); +const myDescendants = root.child.otherChild.descendant; +``` +but no methods can be called on them except + * valueOf() -- to return raw data(source node) + * toString() -- to call `toString()` method on source node -## Installation +## How it works +When you call `create()` function, you pass source data and adapter object. These two will be packed into [wrapper Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) which will be returned. +Proxy object will work with adapter(with its `getChildren()`, `getChildrenByName()` and other methods) to retrieve a list of child nodes with requested name. +``` +const root = create(mySourceTreeData); +const myDescendants = root.child.otherChild.descendant; +``` +With this code, on line 1, Proxy object for root node of the source tree is created. On line 2 three additional Proxies are created for `child`, `otherChild` and `descendant` node requests. When requesting a child node by name, it returns not one node but a list of all child nodes with same name, but when children requested off the list, Proxy will take first node from this list and return its children. So, if you have a list of 2 nodes where first does not have children and second has children +``` +const root = ; +/** +node structure + root + / \ + one one + / \ + two two +*/ + +const rootProxy = create(root, myAdapter); +const twoProxy = rootProxy.one.two; +``` +`twoProxy` will contain empty list, because only first `one` node is checked for children. Here are equivalent code +``` +const rootProxy = create(root, myAdapter); +const twoProxy = rootProxy.one[0].two; +``` +To retrieve children from second `one` node you should specify it, like this +``` +const rootProxy = create(root, myAdapter); +const twoProxy = rootProxy.one[1].two; +``` +Now we will have two `two` nodes in `twoProxy`. + +Adapter should always return empty list if no nodes found +``` +const rootProxy = create(root, myAdapter); +const veryDeepNode = rootProxy.one.five.seven.anyOther.dont.know.if.it.exists; +``` +in this way you can request any descendants from any depth without worrying about their existence. + + +## Usage + +To use TreeWalker, it should be supplied with two required components: +1. Source data - Tree data structure, that you want to work with +2. Adapter - Provides standardized API to work with source data +Additionally augmentations and prefixes could be used to enrich final API. + +Before using, TreeWalker must be created via factory function `create()`, it returns source data wrapped into a Proxy wrapper(just "wrapper" in text below) which will use adapter to get children nodes, call augmentations and apply prefixes. TreeWrapper is read-only tree traverser, so it has only `get`, `has` and `apply` traps, `set` or `deleteProperty` are not implemented. But you may create an augmentation for source data mutations(explained below). +``` +import { create } from '@actualwave/tree-walker'; + +// root is a wrapped "source" node +const root = create(source, myAdapter); +``` +After instantiating, you can access child nodes as properties and augmentations as methods. Its possible to have methods and nodes of same name, its because, when wrapper is created for child object, it stores parent node and name of child node. + + If request a property from wrapper, it will look for a node to return new wrapper with that node and name of the property: +``` +// stores { target: node, name: "parent" } +const parent = node.parent; +// stores { target: parent, name: "otherChild" } +const child = parent.otherChild; +// stores { target: child, name: "sibblings" } +const sibblings = child.sibblings; +``` +or +``` +// stores { target: otherChild, name: "sibblings" } +const sibblings = node.parent.otherChild.sibblings; +``` +If `sibblings` node from example above will be replaced in a source tree or removed, your wrapper object will reflect changes. + +When requesting a child, wrapper uses `getChildren()` and `getChildrenByName()` methods of adapter, so its always a list of nodes, even if single child available -- it will be a list with one child. +``` +const firstSibbling = sibblings[0]; +``` +When requesting a child from wrapped list of nodes, wrapper will request children of first node from the list. + +> Adapter methods `toList()`, `getChildren()` and `getChildrenByName()` must always return list of nodes. In case of 0 nodes it should be empty list. Single node must have length 1 and, if requested, index 0 must return same node. + +If you wish to have specific node in a wrapper, you can request it by specifying index: +``` +// stores { target: otherChild } +const sibblings = node.parent.otherChild[0]; +``` +In this case wrapper will contain one node resolved by name. + +If wrapper is being called as function, it will look for augmentation registered for that name: +``` +// stores { target: node, name: "parent" } +const parent = node.parent; +// will call augmentation +console.log(parent()); +``` +or +``` +// will call augmentation "descendants" on "otherChild" node +console.log(node.child.otherChild.descendants()); +``` +Important to say, that wrapper has set of restricted names for child nodes +**constructor** +**prototype** +Values of these properties will be requested directly from source node or list and returned as is. ## API -### Core -### Adapters -### Prefixes -### Augmentations +* **create(rootNode, adapter)** -- create wrapper for node and use supplied adapter to work with it +* **setDefaultAdapter(adapter)** -- specifying default adapter makes optional defining adapter in `create()` factory function +* **getDefaultAdapter(adapter)** -- get default adapter +* **addAugmentations({...})** -- add augmentations to the pool, accepts an object with functions, name of the property will be used as name of augmentation. +``` +addAugmentations({ + children: (node, adapter, utils) => {...}, + parent: (node, adapter, utils) => {...}, + name: (node, adapter, utils) => {...}, +}); +``` +* **hasAugmentation(name)** -- check if augmentation was added +* **resetAugmentations({...})** -- remove all currently registered augmentations(including core augmentations) and, replace them with augmentations if passed +* **setNamePrefix(char, handlerFunc)** -- set prefix handler +* **isValidPrefix(char)** -- check if prefix is valid and has handler registered + +## Adapter +Adapter is an object with set of methods required by wrapper and augmentations to work with source data. Each instance of wrapper and augmentation calls receive instance of adapter as well as target node or list of nodes to pass into adapter. All calls to source data should be done via adapter API. + +Adapter API(required methods marked with bold) +* **validateRoot(item)** -- is called before crating wrapper for root node, could accept anything and must return root node. +* **isList(item)** -- check if item is a list +* **toList(item)** -- convert anything to list, node to list with one item or nothing to empty list +* getLength(item) -- returns length of the item, in case of node it should be 1 +* **getNodeAt(item, index = 0)** -- return node from a list by its index +* **isNode(item)** -- check if item is single node +* **toNode(item)** -- convert anything to node, if possible. If list, get first node from it +* getName(item) -- return name of the node +* hasChild(item, name) -- check if node has children with specified name +* **getChildren(item)** -- get list of all children from node +* **getChildrenByName(item, name)** -- get list of children with specified name +* getChildAt: (item, index = 0) -- get child of the node by index +* getNodeParent(item) -- get node parent +* getNodeRoot(item) -- get root node of the tree + +All methods should work equally with lists and nodes, if it requires node but was supplied with list, it should get first node from the list and continue and vice versa -- if list is required but node supplied, convert it to list with one node and proceed. + +> You are free to add any methods or properties to adapter for your custom augmentations, but its not recommended to change signature of described here methods. + +## Augmentations +Augmentations are simple functions which receive set of arguments and result with any kind of data(not limited to nodes). Augmentations work only when called as function, otherwise it's treated as wrapped node: +``` +// add "children" augmentation +addAugmentations({ + children: (node, adapter, [childName], utils) => { + let list; + + if (childName) { + list = adapter.getChildrenByName(node, childName); + } else { + list = adapter.getChildren(node); + } + + return utils.wrap(list, adapter); + }, +}}; + +// now augmentation may be called from any wrapped node +const root = create(source, myAdapter); + +// list of "children" nodes +const children1 = root.children; + +// result of "children" augmentation call +const children2 = root.children(); +``` +When wrapper received a function call, it checks for available augmentations and if its available, its being called. In other cases it will act as node list retrieved by name, so this will work too. +``` +// result of "children" augmentation call +const children2 = children1(); +``` +Because wrapper in `children1` have stored its parent `root` node and `children` name. + +TreeWalker supplied with set of basic augmentations: +#### coreAugmentations +There are only two augmentations `toString()` and `valueOf()`, they are pre-applied. + * **valueOf():any** -- Unwrap source node or list of nodes and return it + * **toString():String** -- Call `toString()` method on source node + +#### nodeAugmentations +Set of augmentations to work with nodes and their children. +* **children(name:String?):WrappedNode[]** - List of all children nodes, if name is supplied, list will be filtered by name. +* **descendants(name:String?):WrappedNode[]** - List of all descendant nodes, if name is supplied, list will be filtered by name. +* **childAt (index:Number=0):WrappedNode** - Child node at index +* **root():WrappedNode** - Root node of the tree +* **parent():WrappedNode** - Parent node + +#### listAugmentations +Set of augmentations to work with lists. +* **length():Number** - Length of the list, will return 1 for single wrapped node +* **at(index:Number=0):WrappedNode** - Get item from list by index, can be called on single node as on list with one item +* **first():WrappedNode** - Get first item from the list, can be called in single node, will return itself +* **filter(handler:Function):WrappedNode[]** - Filter list of nodes, will return filtered list +* **map(handler:Function):any[]** - Map list of nodes, will return list with map results for each node +* **reduce(handler:Function, initialValue:any?):any** - Reduce list of nodes will return final value + + +## Prefixes +Prefix is always a one symbol string, any character. It registers a handler which will be called when property which prefixed by that symbol was requested(`get` Proxy trap). +For example, every node in our tree has some `data` object which holds additional properties of the node. We register such handler: +``` +const dataPrefixGetHandler = (target, adapter, [name]) => { + const node = adapter.toNode(target); + return node.data ? node.data[name] : undefined; +}; + +setNamePrefix("$", dataPrefixGetHandler); +``` +Handler receives source node, adapter, list of arguments in case of function call and utils object which contains method to wrap with Proxy. + +After registering this prefix, we may access node properties stored in `data` like this +``` +const root = create(source, myAdapter); +console.log(root.@prop1); // will request "prop1" from "data" object +console.log(root.child.@prop1); // will request "prop1" from "data" object of "child" node +``` + +For additional example of prefix utilization, check `js-dom-walker` project, it uses `$` as prefix for DOM node attributes. diff --git a/dist/tree-walker.js b/dist/tree-walker.js index 6de4727..29cbcc4 100644 --- a/dist/tree-walker.js +++ b/dist/tree-walker.js @@ -2,18 +2,43 @@ Object.defineProperty(exports, '__esModule', { value: true }); -let defaultAdapter = null; +let defaultAdapter; const setDefaultAdapter = adapter => { defaultAdapter = adapter; }; const getDefaultAdapter = () => defaultAdapter; +function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var hasOwn_1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, '__esModule', { value: true }); + +const hasOwn = ( + (has) => + (target, property) => + Boolean(target && has.call(target, property)) +)(Object.prototype.hasOwnProperty); + +exports.hasOwn = hasOwn; +exports.default = hasOwn; +}); + +var hasOwn = unwrapExports(hasOwn_1); +var hasOwn_2 = hasOwn_1.hasOwn; + const namePrefixes = {}; -const isValidPrefix = prefix => typeof prefix === 'string' && prefix.length === 1 && namePrefixes.hasOwnProperty(prefix); +const isValidPrefix = prefix => typeof prefix === 'string' && hasOwn(namePrefixes, prefix); -const isPrefixedKey = key => key && typeof key === 'string' && key.length > 1 && namePrefixes.hasOwnProperty(key.charAt()); +const isPrefixedKey = key => key && typeof key === 'string' && key.length > 1 && hasOwn(namePrefixes, key.charAt()); const getPrefixHandler = key => namePrefixes[key.charAt()]; @@ -25,7 +50,11 @@ const setNamePrefix = (prefix, handler) => { namePrefixes[prefix] = handler; }; -const isIntKey = key => `${parseInt(key, 10)}` === key; +const isIntKey = key => +// it is unsigned int +typeof key === 'number' && key >>> 0 === key || +// it is integer number string +`${parseInt(String(key), 10)}` === key; const getValue = (node, adapter, childName = undefined) => { if (childName !== undefined) { @@ -35,19 +64,9 @@ const getValue = (node, adapter, childName = undefined) => { return node; }; -const getSingleNode = (node, adapter, childName = undefined) => { - const value = getValue(node, adapter, childName); +const getSingleNode = (node, adapter, childName = undefined) => adapter.toNode(getValue(node, adapter, childName)); - if (adapter.isList(value)) { - return adapter.getNodeAt(node); - } - - return value; -}; - -const getNodeList = (node, adapter, childName = undefined) => { - return adapter.toList(getValue(node, adapter, childName)); -}; +const getNodeList = (node, adapter, childName = undefined) => adapter.toList(getValue(node, adapter, childName)); let augmentations = {}; @@ -55,17 +74,26 @@ const resetAugmentations = (augs = {}) => { augmentations = augs; }; -const addAugmentations = (augs = {}) => { +const addAugmentations = augs => { augmentations = Object.assign({}, augmentations, augs); }; -const hasAugmentation = key => key && typeof key === 'string' && augmentations.hasOwnProperty(key); +const hasAugmentation = key => key && typeof key === 'string' && hasOwn(augmentations, key); const applyAugmentation = (key, ...args) => augmentations[key](...args); let handlers; let utils; +const GET_RESTRICTED_NAMES = { + constructor: true, + prototype: true + /* + call: true, + apply: true, + */ +}; + const createWalkerNode = (node, adapter, childName = undefined) => { function TreeWalker() { throw new Error('Should have been never called'); @@ -100,11 +128,16 @@ utils = { const get = ({ node, adapter, childName }, key) => { /* + if symbol, return node property if string childName used if starts with $, return attribute value else return wrapper with current single node and property childName if numeric index used, use node as parent and childName is undefined */ + if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) { + return node[key]; + } + if (isIntKey(key)) { return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter); } @@ -114,8 +147,10 @@ const get = ({ node, adapter, childName }, key) => { return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils); } + const result = getValue(node, adapter, childName); + // return wrap with node and childName - return wrap(getValue(node, adapter, childName), adapter, key); + return wrap(result, adapter, key); }; const has = ({ node, adapter, childName }, key) => { @@ -126,10 +161,11 @@ const has = ({ node, adapter, childName }, key) => { if (isPrefixedKey(key)) { // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1)); // don't know how to implement this, calling same handler as in GET seems overkill + // FIXME let user to register GET and optional SET/HAS handlers return true; } - return adapter.hasChild(getSingleNode(), key); + return adapter.hasChild(getSingleNode(node, adapter, childName), key); }; const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { @@ -139,9 +175,12 @@ const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { // this works only of childName === prefix, one char string // otherwise it should be passed into arguments + + // FIXME if GET always return result of prefixed property, means there are + // no cases when we get a wrapped node to APPLY trap with prefixed name. if (isValidPrefix(childName)) { const handler = getPrefixHandler(childName); - return handler(node, adapter, argumentsList, utils); + return handler(node, adapter, [childName.substr(1), ...argumentsList], utils); } if (hasAugmentation(childName)) { @@ -150,6 +189,12 @@ const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { return applyAugmentation(childName, node, adapter, argumentsList, utils); } + // in case of normal function being called out of the tree node + const targetNode = adapter.toNode(node); + if (typeof targetNode[childName] === 'function') { + return targetNode[childName](...argumentsList); + } + // FIXME might throw only in dev mode(needs implementation) throw new Error(`"${childName}" is not a callable object.`); }; @@ -165,8 +210,7 @@ const valueOf = node => node; var coreAugmentations = { toString, - valueOf, - [Symbol.toPrimitive]: node => node + valueOf }; /* eslint-disable prefer-spread */ @@ -186,17 +230,19 @@ const children = (node, adapter, [childName], utils) => { * @internal */ const descendantsAll = (node, adapter, args, utils) => { - const result = []; + const children = []; // eslint-disable-line no-shadow + const descendants = []; const list = adapter.getChildren(node); const length = adapter.getLength(list, adapter); for (let index = 0; index < length; index += 1) { const child = list[index]; - result.push(child); - result.push.apply(result, descendantsAll(child, adapter, args, utils)); + children.push(child); + descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils)); } - return result; + /* children go first, then other descendants */ + return [...children, ...descendants]; }; /** @@ -204,19 +250,22 @@ const descendantsAll = (node, adapter, args, utils) => { */ const descendantsByName = (node, adapter, args, utils) => { const [childName] = args; - const result = []; + const children = []; // eslint-disable-line no-shadow + const descendants = []; const list = adapter.getChildren(node); const length = adapter.getLength(list, adapter); for (let index = 0; index < length; index += 1) { const child = list[index]; if (adapter.getName(child) === childName) { - result.push(child); + children.push(child); } - result.push.apply(result, descendantsByName(child, adapter, args, utils)); + + descendants.push.apply(descendants, descendantsByName(child, adapter, args, utils)); } - return result; + /* children go first, then other descendants */ + return [...children, ...descendants]; }; const descendants = (node, adapter, args, utils) => { @@ -254,10 +303,8 @@ const length = (node, adapter) => { }; const at = (node, adapter, args, utils) => { - const [index] = args; - // return empty array, which will create empty wrapper for chained calls, - // this will make next calls errorless. - let result = []; + const [index = 0] = args; + let result; if (adapter.isList(node)) { const child = adapter.getNodeAt(node, index); @@ -265,9 +312,13 @@ const at = (node, adapter, args, utils) => { if (child) { result = child; } + } else if (!index) { + result = node; } - return utils.wrap(result, adapter); + // if nothing found return empty array, which will create empty wrapper for + // chained calls, this will make next calls errorless. + return utils.wrap(result || [], adapter); }; const first = (node, adapter, args, utils) => at(node, adapter, [0], utils); @@ -290,25 +341,22 @@ const filter = (node, adapter, [callback], utils) => { return utils.wrap(result, adapter); }; -const map = (node, adapter, [callback, wrapNodes = true], utils) => { +const map = (node, adapter, [callback], utils) => { // apply map on element collection - // if wrapNodes in FALSE, will generate normal Array with RAW results in it - // if wrapNodes in TRUE and all elements of resulting list are nodes, will - // generate wrapped list and put all result into it const list = adapter.toList(node); const listLength = adapter.getLength(list); const result = []; - let areNodes = true; - const wrappedNode = utils.wrap(list, adapter); + const wrappedList = utils.wrap(list, adapter); for (let index = 0; index < listLength; index += 1) { const child = adapter.getNodeAt(list, index); - const childResult = callback(utils.wrap(child, adapter), index, wrappedNode); - areNodes = areNodes && adapter.isNode(childResult); + const childResult = callback(utils.wrap(child, adapter), index, wrappedList); result.push(childResult); } - return wrapNodes && areNodes ? utils.wrap(result, adapter) : result; + // returns normal array because we don't know if all items in result are nodes + // and if they are, they will be likely already wrapped + return result; }; const reduce = (node, adapter, [callback, result], utils) => { @@ -320,7 +368,7 @@ const reduce = (node, adapter, [callback, result], utils) => { const wrappedNode = utils.wrap(list, adapter); for (let index = 0; index < listLength; index += 1) { const child = adapter.getNodeAt(list, index); - lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode); + lastResult = callback(lastResult, utils.wrap(child, adapter), index, wrappedNode); } return lastResult; diff --git a/dist/tree-walker.js.map b/dist/tree-walker.js.map index 28f6d04..9d8dbfb 100644 --- a/dist/tree-walker.js.map +++ b/dist/tree-walker.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","getValue","node","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","createWalkerNode","TreeWalker","wrap","isNode","Proxy","get","substr","has","hasChild","apply","thisArg","argumentsList","toString","valueOf","Symbol","toPrimitive","children","list","getChildren","descendantsAll","result","getLength","index","child","push","descendantsByName","getName","descendants","childAt","getChildAt","root","getNodeRoot","parent","getNodeParent","at","first","filter","callback","listLength","wrappedNode","map","wrapNodes","areNodes","childResult","reduce","lastResult","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,iBAAiB,IAArB;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC,oBAAoB,MAAMH,cAAhC;;ACLP,MAAMI,eAAe,EAArB;;AAEA,MAAaC,gBAAiBC,MAAD,IAC3B,OAAOA,MAAP,KAAkB,QAAlB,IACGA,OAAOC,MAAP,KAAkB,CADrB,IAEGH,aAAaI,cAAb,CAA4BF,MAA5B,CAHE;;AAMP,AAAO,MAAMG,gBAAiBC,GAAD,IAC3BA,OACG,OAAOA,GAAP,KAAe,QADlB,IAEGA,IAAIH,MAAJ,GAAa,CAFhB,IAGGH,aAAaI,cAAb,CAA4BE,IAAIC,MAAJ,EAA5B,CAJE;;AAOP,AAAO,MAAMC,mBAAoBF,GAAD,IAASN,aAAaM,IAAIC,MAAJ,EAAb,CAAlC;;AAEP,MAAaE,gBAAgB,CAACP,MAAD,EAASQ,OAAT,KAAqB;MAC5C,OAAOR,MAAP,KAAkB,QAAlB,IAA8BA,OAAOC,MAAP,KAAkB,CAApD,EAAuD;UAC/C,IAAIQ,KAAJ,CAAU,2CAAV,CAAN;;;eAGWT,MAAb,IAAuBQ,OAAvB;CALK;;ACjBA,MAAME,WAAYN,GAAD,IAAW,GAAEO,SAASP,GAAT,EAAc,EAAd,CAAkB,EAArB,KAA2BA,GAAtD;;AAEP,AAAO,MAAMQ,WAAW,CAACC,IAAD,EAAOjB,OAAP,EAAgBkB,YAAYC,SA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,KAA7C,EAAoDiB,WAApD,CAAb;;;SAGKM,UAAP;CAZF;;AAeA,WAAe;QAAA;IAAA;OAAA;QAAA;KAAA;;CAAf;;AC3EAnD,iBAAiBoD,iBAAjB;;AAEA,MAAMC,SAAS,CAACjB,IAAD,EAAOlE,UAAUC,mBAAjB,KACbqC,KAAKtC,QAAQoF,YAAR,CAAqBlB,IAArB,CAAL,EAAiClE,OAAjC,CADF;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && hasOwn(augmentations, key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","hasOwn","isPrefixedKey","key","length","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","String","getValue","node","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","GET_RESTRICTED_NAMES","createWalkerNode","TreeWalker","wrap","isNode","isList","Proxy","get","getNodeAt","substr","result","has","hasChild","apply","thisArg","argumentsList","targetNode","toString","valueOf","children","list","getChildren","descendantsAll","descendants","getLength","index","child","push","descendantsByName","getName","childAt","getChildAt","root","getNodeRoot","parent","getNodeParent","at","first","filter","callback","listLength","wrappedNode","map","wrappedList","childResult","reduce","lastResult","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,cAAJ;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC,oBAAoB,MAAMH,cAAhC;;;;;;;;;;;ACLP;AAEA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;AAE9D,MAAM,MAAM,GAAG;EACb,CAAC,GAAG;EACJ,CAAC,MAAM,EAAE,QAAQ;EACjB,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;EAC7C,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;;AAEnC,cAAc,GAAG,MAAM,CAAC;AACxB,eAAe,GAAG,MAAM;;;;;;ACTxB,MAAMI,eAAe,EAArB;;AAEA,MAAaC,gBAAiBC,MAAD,IAC3B,OAAOA,MAAP,KAAkB,QAAlB,IAA8BC,OAAOH,YAAP,EAAqBE,MAArB,CADzB;;AAGP,AAAO,MAAME,gBAAiBC,GAAD,IAC3BA,OACA,OAAOA,GAAP,KAAe,QADf,IAEAA,I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.js index 347e51e..88dfafc 100644 --- a/dist/tree-walker.min.js +++ b/dist/tree-walker.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TreeWalker={})}(this,function(t){"use strict";let e=null;const r=()=>e,n={},o=t=>"string"==typeof t&&1===t.length&&n.hasOwnProperty(t),a=t=>t&&"string"==typeof t&&t.length>1&&n.hasOwnProperty(t.charAt()),s=t=>n[t.charAt()],i=t=>`${parseInt(t,10)}`===t,d=(t,e,r)=>void 0!==r?e.getChildrenByName(t,r):t,l=(t,e,r)=>{const n=d(t,e,r);return e.isList(n)?e.getNodeAt(t):n},g=(t,e,r)=>e.toList(d(t,e,r));let p={};const c=(t={})=>{p=Object.assign({},p,t)},u=t=>t&&"string"==typeof t&&p.hasOwnProperty(t);let h,f;const w=(t,e,r)=>e.isNode(t)||e.isList(t)?new Proxy(((t,e,r)=>{function n(){throw new Error("Should have been never called")}return n.node=t,n.childName=r,n.adapter=e,n})(t,e,r),h):t;f={isIntKey:i,getValue:d,getSingleNode:l,getNodeList:g,wrap:w};h={get:({node:t,adapter:e,childName:r},n)=>{if(i(n))return w(e.getNodeAt(g(t,e,r),n),e);if(a(n))return s(n)(d(t,e,r),e,[n.substr(1)],f);return w(d(t,e,r),e,n)},has:({node:t,adapter:e,childName:r},n)=>i(n)?!!e.getNodeAt(g(t,e,r),n):!!a(n)||e.hasChild(l(),n),apply:({node:t,adapter:e,childName:r},n,a)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(o(r))return s(r)(t,e,a,f);if(u(r))return((t,...e)=>p[t](...e))(r,t,e,a,f);throw new Error(`"${r}" is not a callable object.`)}};var N={toString:t=>t.toString(),valueOf:t=>t,[Symbol.toPrimitive]:t=>t};const m=(t,e,r,n)=>{const o=[],a=e.getChildren(t),s=e.getLength(a,e);for(let t=0;t{const[o]=r,a=[],s=e.getChildren(t),i=e.getLength(s,e);for(let t=0;t{let o;return o=r?e.getChildrenByName(t,r):e.getChildren(t),n.wrap(o,e)},descendants:(t,e,r,n)=>{const[o]=r;return o?n.wrap(y(t,e,r,n),e):n.wrap(m(t,e,r,n),e)},childAt:(t,e,[r=0],n)=>n.wrap(e.getChildAt(t,r),e),root:(t,e,r,n)=>n.wrap(e.getNodeRoot(t),e),parent:(t,e,r,n)=>n.wrap(e.getNodeParent(t),e)};const L=(t,e,r,n)=>{const[o]=r;let a=[];if(e.isList(t)){const r=e.getNodeAt(t,o);r&&(a=r)}return n.wrap(a,e)};var v={length:(t,e)=>e.isList(t)?e.getLength(t):e.isNode(t)?1:0,at:L,first:(t,e,r,n)=>L(t,e,[0],n),filter:(t,e,[r],n)=>{const o=e.toList(t),a=e.getLength(t),s=[],i=n.wrap(o,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(a),i=[];let d=!0;const l=o.wrap(a,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(t);let i=n;const d=o.wrap(a,e);for(let t=0;tw(e.validateRoot(t),e);t.setDefaultAdapter=(t=>{e=t}),t.getDefaultAdapter=r,t.addAugmentations=c,t.hasAugmentation=u,t.resetAugmentations=((t={})=>{p=t}),t.coreAugmentations=N,t.nodeAugmentations=A,t.listAugmentations=v,t.setNamePrefix=((t,e)=>{if("string"!=typeof t||1!==t.length)throw new Error("Name Prefix must be one character string.");n[t]=e}),t.isValidPrefix=o,t.create=P,t.default=P,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t;const r=()=>t;var o,n,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(o={exports:{}},o.exports),o.exports),s=(n=a)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;a.hasOwn;const i={},d=e=>"string"==typeof e&&s(i,e),l=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>"number"==typeof e&&e>>>0===e||`${parseInt(String(e),10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>t.toNode(u(e,t,r)),f=(e,t,r)=>t.toList(u(e,t,r));let h={};const w=e=>{h=Object.assign({},h,e)},y=e=>e&&"string"==typeof e&&s(h,e);let N,m;const A={constructor:!0,prototype:!0},b=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function o(){throw new Error("Should have been never called")}return o.node=e,o.childName=r,o.adapter=t,o})(e,t,r),N):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:f,wrap:b};N={get:({node:e,adapter:t,childName:r},o)=>{if("symbol"==typeof o||!0===A[o])return e[o];if(c(o))return b(t.getNodeAt(f(e,t,r),o),t);if(l(o))return p(o)(u(e,t,r),t,[o.substr(1)],m);const n=u(e,t,r);return b(n,t,o)},has:({node:e,adapter:t,childName:r},o)=>c(o)?!!t.getNodeAt(f(e,t,r),o):!!l(o)||t.hasChild(g(e,t,r),o),apply:({node:e,adapter:t,childName:r},o,n)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(d(r))return p(r)(e,t,[r.substr(1),...n],m);if(y(r))return((e,...t)=>h[e](...t))(r,e,t,n,m);const a=t.toNode(e);if("function"==typeof a[r])return a[r](...n);throw new Error(`"${r}" is not a callable object.`)}};var L={toString:e=>e.toString(),valueOf:e=>e};const v=(e,t,r,o)=>{const n=[],a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{const[n]=r,a=[],s=[],i=t.getChildren(e),d=t.getLength(i,t);for(let e=0;e{let n;return n=r?t.getChildrenByName(e,r):t.getChildren(e),o.wrap(n,t)},descendants:(e,t,r,o)=>{const[n]=r;return n?o.wrap(x(e,t,r,o),t):o.wrap(v(e,t,r,o),t)},childAt:(e,t,[r=0],o)=>o.wrap(t.getChildAt(e,r),t),root:(e,t,r,o)=>o.wrap(t.getNodeRoot(e),t),parent:(e,t,r,o)=>o.wrap(t.getNodeParent(e),t)};const P=(e,t,r,o)=>{const[n=0]=r;let a;if(t.isList(e)){const r=t.getNodeAt(e,n);r&&(a=r)}else n||(a=e);return o.wrap(a||[],t)};var C={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,o)=>P(e,t,[0],o),filter:(e,t,[r],o)=>{const n=t.toList(e),a=t.getLength(e),s=[],i=o.wrap(n,t);for(let e=0;e{const n=t.toList(e),a=t.getLength(n),s=[],i=o.wrap(n,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=o;const d=n.wrap(a,t);for(let e=0;eb(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=y,e.resetAugmentations=((e={})=>{h=e}),e.coreAugmentations=L,e.nodeAugmentations=O,e.listAugmentations=C,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=d,e.create=j,e.default=j,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=tree-walker.min.js.map diff --git a/dist/tree-walker.min.js.map b/dist/tree-walker.min.js.map index bb13cf6..6c8ea90 100644 --- a/dist/tree-walker.min.js.map +++ b/dist/tree-walker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,EAAiB,WAKRC,EAAoB,IAAMD,ECLjCE,KAEOC,EAAiBC,GACV,iBAAXA,GACc,IAAlBA,EAAOC,QACPH,EAAaI,eAAeF,GAGpBG,EAAiBC,GAC5BA,GACkB,iBAARA,GACPA,EAAIH,OAAS,GACbH,EAAaI,eAAeE,EAAIC,UAGxBC,EAAoBF,GAAQN,EAAaM,EAAIC,UCf7CE,EAAYH,MAAYI,SAASJ,EAAK,QAAUA,EAEhDK,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,WACrCI,EAAQP,EAASC,EAAMC,EAASC,UAElCD,EAAQM,OAAOD,GACVL,EAAQO,UAAUR,GAGpBM,GAGIG,EAAc,CAACT,EAAMC,EAASC,IAClCD,EAAQS,OAAOX,EAASC,EAAMC,EAASC,ICrBhD,IAAIS,WAMSC,EAAmB,CAACC,2BAE1BF,EACAE,IAIMC,EAAmBpB,GAC9BA,GACkB,iBAARA,GACPiB,EAAcnB,eAAeE,OCE9BqB,EACAC,EAEJ,MAeMC,EAAO,CAACjB,EAAMC,EAASC,IACtBD,EAAQiB,OAAOlB,IAAUC,EAAQM,OAAOP,GAItC,IAAImB,MApBY,EAACnB,EAAMC,EAASC,cAC9BkB,UACD,IAAIC,MAAM,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S,CAACC,EAAMxD,EAAUd,MAC9B8B,EAAKhB,EAAQyD,aAAaD,GAAOxD,uBRTDA,CAAAA,MACfA,wFGDe,EAACY,UACjBA,sFFcW,EAACvB,EAAQiC,QACd,iBAAXjC,GAAyC,IAAlBA,EAAOC,aACjC,IAAI8B,MAAM,+CAGL/B,GAAUiC"} \ No newline at end of file +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && hasOwn(augmentations, key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","isPrefixedKey","key","length","charAt","getPrefixHandler","isIntKey","parseInt","String","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","GET_RESTRICTED_NAMES","wrap","isNode","isList","Proxy","TreeWalker","Error","createWalkerNode","getNodeAt","handler","substr","result","hasChild","thisArg","argumentsList","args","applyAugmentation","targetNode","toString","descendantsAll","children","descendants","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrappedList","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,QAKSC,EAAoB,IAAMD,2BCHvCE,OAAOC,eAAeC,EAAS,cAAgBC,OAAO,IAEtD,MAAMC,EAAS,CACZC,GACD,CAACC,EAAQC,IACTC,QAAQF,GAAUD,EAAII,KAAKH,EAAQC,IAHtB,CAIbP,OAAOU,UAAUC,gBAEnBT,SAAiBE,EACjBF,UAAkBE,sICTlB,MAAMQ,KAEOC,EAAiBC,GACV,iBAAXA,GAAuBV,EAAOQ,EAAcE,GAExCC,EAAiBC,GAC5BA,GACe,iBAARA,GACPA,EAAIC,OAAS,GACbb,EAAOQ,EAAcI,EAAIE,UAEdC,EAAoBH,GAAQJ,EAAaI,EAAIE,UCb7CE,EAAYJ,GAEP,iBAARA,GAAoBA,IAAQ,IAAMA,MAEvCK,SAASC,OAAON,GAAM,QAAUA,EAExBO,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,IAC3CD,EAAQK,OAAOP,EAASC,EAAMC,EAASC,IAE5BK,EAAc,CAACP,EAAMC,EAASC,IACzCD,EAAQO,OAAOT,EAASC,EAAMC,EAASC,IChBzC,IAAIO,WAMSC,EAAoBC,uBAE1BF,EACAE,IAIMC,EAAmBpB,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AUxB,GAASZ,WAE3CuB,EAAOpC,EAAQO,OAAOR,GACtBmD,EAAalD,EAAQsC,UAAUvC,OACjCuD,EAAa7B,QAEX0B,EAActC,EAAME,KAAKqB,EAAMpC,OAChC,IAAIuC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQxC,EAAQsB,UAAUc,EAAMG,KACzBU,EACXK,EACAzC,EAAME,KAAKyB,EAAOxC,GAClBuC,EACAY,UAIGG,IChFT7C,EAAiB8C,SAEXC,EAAS,CAACC,EAAMzD,EAAU1B,MAC9ByC,EAAKf,EAAQ0D,aAAaD,GAAOzD,uBTTDA,CAAAA,MACfA,wFICe,EAACU,UACjBA,sFFUW,EAACrB,EAAQkC,QACd,iBAAXlC,GAAyC,IAAlBA,EAAOG,aACjC,IAAI4B,MAAM,+CAGL/B,GAAUkC"} \ No newline at end of file diff --git a/eslintrc.spec.json b/eslintrc.spec.json index 1032ce4..846d1c6 100644 --- a/eslintrc.spec.json +++ b/eslintrc.spec.json @@ -38,6 +38,7 @@ "no-shadow": 1, "no-param-reassign": 1, "padded-blocks": 0, - "no-plusplus": 0 + "no-plusplus": 0, + "function-paren-newline": 0 } } diff --git a/example/index.html b/example/index.html index c5bb549..fb8059f 100644 --- a/example/index.html +++ b/example/index.html @@ -69,10 +69,13 @@ const root = create(tree); - const first1 = root.children('first').children('first').first(); + const first1 = root.first.first.first(); + /* equivalent using augmentations: + const first1 = root.children('first').children('first').first(); + */ console.log('Get child "first"(level 1) of child "first"(level 0):', first1.valueOf()); console.log('Get its children: ', first1.children().valueOf()); - console.log('Get its children with name "third"(level 2): ', first1.children('third').valueOf()); + console.log('Get its children with name "third"(level 2): ', first1.third.valueOf()); console.log(`Root has ${root.descendants().length()} descendants`); console.log('Get list of descendants from root node:'); @@ -82,7 +85,7 @@ console.log(root.descendants('first').valueOf()); console.log('Find "uniqueName" descendant and get its "uniqueParam" value:', - root.descendants('uniqueName').first().valueOf().uniqueParam); + root.descendants('uniqueName').first().valueOf().data.uniqueParam); diff --git a/example/onode-adapter.js b/example/onode-adapter.js index 2aec872..7efb435 100644 --- a/example/onode-adapter.js +++ b/example/onode-adapter.js @@ -4,18 +4,24 @@ // list methods isList: (item) => item instanceof Array, - toList: (item) => adapter.isList(item) ? item : [item], + toList: (item) => (adapter.isList(item) ? item : [item]), getLength: (item) => adapter.toList(item).length, - getNodeAt: (item, index) => adapter.toList(item)[index], + getNodeAt: (item, index = 0) => adapter.toList(item)[index], // node methods isNode: (item) => item instanceof Object && !adapter.isList(item), - toNode: (item) => adapter.isList(item) ? item[0] : item, + toNode: (item) => (adapter.isList(item) ? item[0] : item), getName: (item) => adapter.toNode(item).name, hasChild: (item, name) => !!adapter.getChildrenByName(item, name).length, - getChildren: (item) => adapter.toNode(item).children, - getChildrenByName: (item, name) => adapter.toNode(item).children.filter((child) => adapter.getName(child) === name), - getChildAt: (item, index) => adapter.toNode(item).children[index], + getChildren: (item) => { + const node = adapter.toNode(item); + return (node && node.children) || []; + }, + getChildrenByName: (item, name) => + adapter + .getChildren(item) + .filter((child) => adapter.getName(child) === name), + getChildAt: (item, index = 0) => adapter.toNode(item).children[index], getNodeParent: (item) => adapter.toNode(item).parent, getNodeRoot: (item) => adapter.toNode(item).root, }; diff --git a/example/onode.js b/example/onode.js index 08fab69..92a6781 100644 --- a/example/onode.js +++ b/example/onode.js @@ -4,26 +4,41 @@ this.name = name; this.children = []; this.parent = parent; - this.root = root; + this.root = root || this; } - toString() { - return `[ONode name="${this.name}" level="${this.level}"]`; + toString = () => `[ONode name="${this.name}" ${JSON.stringify(this.data)}]`; + valueOf = () => ({ name: this.name, data: this.data }); + normalMethod() { + return this.data; } - }; + } - const parseONodes = (obj, name = '#root', parent = undefined, root = undefined) => { + const parseONodes = ( + obj, + name = '#root', + parent = undefined, + root = undefined, + ) => { const node = new ONode(name, parent, root); - Object.assign(node, obj.data); const children = []; Object.keys(obj).forEach((key) => { + const source = obj[key]; if (key !== 'data') { - children.push(parseONodes(obj[key], key, node, root || node)); + if (source instanceof Array) { + children.push.apply( + children, + source.map((item) => parseONodes(item, key, node, root || node)), + ); + } else { + children.push(parseONodes(source, key, node, root || node)); + } } }); node.children = children; + node.data = obj.data; return node; }; diff --git a/example/tree-walker.min.js b/example/tree-walker.min.js index 347e51e..e466584 100644 --- a/example/tree-walker.min.js +++ b/example/tree-walker.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TreeWalker={})}(this,function(t){"use strict";let e=null;const r=()=>e,n={},o=t=>"string"==typeof t&&1===t.length&&n.hasOwnProperty(t),a=t=>t&&"string"==typeof t&&t.length>1&&n.hasOwnProperty(t.charAt()),s=t=>n[t.charAt()],i=t=>`${parseInt(t,10)}`===t,d=(t,e,r)=>void 0!==r?e.getChildrenByName(t,r):t,l=(t,e,r)=>{const n=d(t,e,r);return e.isList(n)?e.getNodeAt(t):n},g=(t,e,r)=>e.toList(d(t,e,r));let p={};const c=(t={})=>{p=Object.assign({},p,t)},u=t=>t&&"string"==typeof t&&p.hasOwnProperty(t);let h,f;const w=(t,e,r)=>e.isNode(t)||e.isList(t)?new Proxy(((t,e,r)=>{function n(){throw new Error("Should have been never called")}return n.node=t,n.childName=r,n.adapter=e,n})(t,e,r),h):t;f={isIntKey:i,getValue:d,getSingleNode:l,getNodeList:g,wrap:w};h={get:({node:t,adapter:e,childName:r},n)=>{if(i(n))return w(e.getNodeAt(g(t,e,r),n),e);if(a(n))return s(n)(d(t,e,r),e,[n.substr(1)],f);return w(d(t,e,r),e,n)},has:({node:t,adapter:e,childName:r},n)=>i(n)?!!e.getNodeAt(g(t,e,r),n):!!a(n)||e.hasChild(l(),n),apply:({node:t,adapter:e,childName:r},n,a)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(o(r))return s(r)(t,e,a,f);if(u(r))return((t,...e)=>p[t](...e))(r,t,e,a,f);throw new Error(`"${r}" is not a callable object.`)}};var N={toString:t=>t.toString(),valueOf:t=>t,[Symbol.toPrimitive]:t=>t};const m=(t,e,r,n)=>{const o=[],a=e.getChildren(t),s=e.getLength(a,e);for(let t=0;t{const[o]=r,a=[],s=e.getChildren(t),i=e.getLength(s,e);for(let t=0;t{let o;return o=r?e.getChildrenByName(t,r):e.getChildren(t),n.wrap(o,e)},descendants:(t,e,r,n)=>{const[o]=r;return o?n.wrap(y(t,e,r,n),e):n.wrap(m(t,e,r,n),e)},childAt:(t,e,[r=0],n)=>n.wrap(e.getChildAt(t,r),e),root:(t,e,r,n)=>n.wrap(e.getNodeRoot(t),e),parent:(t,e,r,n)=>n.wrap(e.getNodeParent(t),e)};const L=(t,e,r,n)=>{const[o]=r;let a=[];if(e.isList(t)){const r=e.getNodeAt(t,o);r&&(a=r)}return n.wrap(a,e)};var v={length:(t,e)=>e.isList(t)?e.getLength(t):e.isNode(t)?1:0,at:L,first:(t,e,r,n)=>L(t,e,[0],n),filter:(t,e,[r],n)=>{const o=e.toList(t),a=e.getLength(t),s=[],i=n.wrap(o,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(a),i=[];let d=!0;const l=o.wrap(a,e);for(let t=0;t{const a=e.toList(t),s=e.getLength(t);let i=n;const d=o.wrap(a,e);for(let t=0;tw(e.validateRoot(t),e);t.setDefaultAdapter=(t=>{e=t}),t.getDefaultAdapter=r,t.addAugmentations=c,t.hasAugmentation=u,t.resetAugmentations=((t={})=>{p=t}),t.coreAugmentations=N,t.nodeAugmentations=A,t.listAugmentations=v,t.setNamePrefix=((t,e)=>{if("string"!=typeof t||1!==t.length)throw new Error("Name Prefix must be one character string.");n[t]=e}),t.isValidPrefix=o,t.create=P,t.default=P,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t=null;const r=()=>t;var n,o,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(n={exports:{}},n.exports),n.exports),s=(o=a)&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o;a.hasOwn;const i={},l=e=>"string"==typeof e&&1===e.length&&s(i,e),d=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>`${parseInt(e,10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>{const n=u(e,t,r);return t.isList(n)?t.getNodeAt(e):n},h=(e,t,r)=>t.toList(u(e,t,r));let f={};const w=(e={})=>{f=Object.assign({},f,e)},N=e=>e&&"string"==typeof e&&f.hasOwnProperty(e);let y,m;const A=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function n(){throw new Error("Should have been never called")}return n.node=e,n.childName=r,n.adapter=t,n})(e,t,r),y):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:h,wrap:A};y={get:({node:e,adapter:t,childName:r},n)=>{if(c(n))return A(t.getNodeAt(h(e,t,r),n),t);if(d(n))return p(n)(u(e,t,r),t,[n.substr(1)],m);return A(u(e,t,r),t,n)},has:({node:e,adapter:t,childName:r},n)=>c(n)?!!t.getNodeAt(h(e,t,r),n):!!d(n)||t.hasChild(g(),n),apply:({node:e,adapter:t,childName:r},n,o)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(l(r))return p(r)(e,t,o,m);if(N(r))return((e,...t)=>f[e](...t))(r,e,t,o,m);throw new Error(`"${r}" is not a callable object.`)}};var L={toString:e=>e.toString(),valueOf:e=>e,[Symbol.toPrimitive]:e=>e};const v=(e,t,r,n)=>{const o=[],a=t.getChildren(e),s=t.getLength(a,t);for(let e=0;e{const[o]=r,a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{let o;return o=r?t.getChildrenByName(e,r):t.getChildren(e),n.wrap(o,t)},descendants:(e,t,r,n)=>{const[o]=r;return o?n.wrap(b(e,t,r,n),t):n.wrap(v(e,t,r,n),t)},childAt:(e,t,[r=0],n)=>n.wrap(t.getChildAt(e,r),t),root:(e,t,r,n)=>n.wrap(t.getNodeRoot(e),t),parent:(e,t,r,n)=>n.wrap(t.getNodeParent(e),t)};const P=(e,t,r,n)=>{const[o]=r;let a=[];if(t.isList(e)){const r=t.getNodeAt(e,o);r&&(a=r)}return n.wrap(a,t)};var x={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,n)=>P(e,t,[0],n),filter:(e,t,[r],n)=>{const o=t.toList(e),a=t.getLength(e),s=[],i=n.wrap(o,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(a),i=[];let l=!0;const d=o.wrap(a,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=n;const l=o.wrap(a,t);for(let e=0;eA(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=N,e.resetAugmentations=((e={})=>{f=e}),e.coreAugmentations=L,e.nodeAugmentations=O,e.listAugmentations=x,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=l,e.create=C,e.default=C,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=tree-walker.min.js.map diff --git a/example/tree-walker.min.js.map b/example/tree-walker.min.js.map index bb13cf6..5f05788 100644 --- a/example/tree-walker.min.js.map +++ b/example/tree-walker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","const namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) => (\r\n typeof prefix === 'string'\r\n && prefix.length === 1\r\n && namePrefixes.hasOwnProperty(prefix)\r\n);\r\n\r\nexport const isPrefixedKey = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && key.length > 1\r\n && namePrefixes.hasOwnProperty(key.charAt())\r\n);\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(utils.wrap(child, adapter), index, wrappedNode);\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(result, utils.wrap(child, adapter), index, wrappedNode);\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","length","hasOwnProperty","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","value","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,EAAiB,WAKRC,EAAoB,IAAMD,ECLjCE,KAEOC,EAAiBC,GACV,iBAAXA,GACc,IAAlBA,EAAOC,QACPH,EAAaI,eAAeF,GAGpBG,EAAiBC,GAC5BA,GACkB,iBAARA,GACPA,EAAIH,OAAS,GACbH,EAAaI,eAAeE,EAAIC,UAGxBC,EAAoBF,GAAQN,EAAaM,EAAIC,UCf7CE,EAAYH,MAAYI,SAASJ,EAAK,QAAUA,EAEhDK,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,WACrCI,EAAQP,EAASC,EAAMC,EAASC,UAElCD,EAAQM,OAAOD,GACVL,EAAQO,UAAUR,GAGpBM,GAGIG,EAAc,CAACT,EAAMC,EAASC,IAClCD,EAAQS,OAAOX,EAASC,EAAMC,EAASC,ICrBhD,IAAIS,WAMSC,EAAmB,CAACC,2BAE1BF,EACAE,IAIMC,EAAmBpB,GAC9BA,GACkB,iBAARA,GACPiB,EAAcnB,eAAeE,OCE9BqB,EACAC,EAEJ,MAeMC,EAAO,CAACjB,EAAMC,EAASC,IACtBD,EAAQiB,OAAOlB,IAAUC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AQlB,EAAMC,KAAKsB,EAAOtC,GAAUqC,EAAOY,UAG5DI,ICxET1C,EAAiB2C,SAEXC,EAAS,CAACC,EAAMxD,EAAUd,MAC9B8B,EAAKhB,EAAQyD,aAAaD,GAAOxD,uBRTDA,CAAAA,MACfA,wFGDe,EAACY,UACjBA,sFFcW,EAACvB,EAAQiC,QACd,iBAAXjC,GAAyC,IAAlBA,EAAOC,aACjC,IAAI8B,MAAM,+CAGL/B,GAAUiC"} \ No newline at end of file +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' &&\r\n prefix.length === 1 &&\r\n hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode\r\n );\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n result,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","length","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes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,GAAyC,IAAlBA,EAAOC,aACjC,IAAI4B,MAAM,+CAGL7B,GAAU+B"} \ No newline at end of file diff --git a/fixtures/index.js b/fixtures/index.js new file mode 100644 index 0000000..ecc48f9 --- /dev/null +++ b/fixtures/index.js @@ -0,0 +1,45 @@ +import { ONode, parseONodes, toString, valueOf } from './onode'; +import ONodeAdapter from './onode-adapter'; + +const getSourceTree = () => + parseONodes({ + data: { level: 0 }, + first: { + data: { level: 1 }, + first: { + data: { level: 2 }, + first: { + data: { level: 3 }, + first: { data: { level: 4 } }, + second: { data: { level: 4 } }, + third: { data: { level: 4 } }, + fourth: { data: { level: 4 } }, + fifth: { data: { level: 4 } }, + sixth: { data: { level: 4 } }, + }, + second: { data: { level: 3 } }, + third: [ + { data: { index: 0, level: 3 } }, + { data: { index: 1, level: 3 } }, + { data: { index: 2, level: 3 } }, + { data: { index: 3, level: 3 } }, + ], + fourth: { data: { level: 3 } }, + uniqueName: { data: { uniqueParam: '123-456', level: 3 } }, + fifth: { data: { level: 3 } }, + sixth: { data: { level: 3 } }, + }, + second: { data: { level: 2 } }, + third: { data: { level: 2 } }, + fourth: { data: { level: 2 } }, + fifth: { data: { level: 2 } }, + sixth: { data: { level: 2 } }, + }, + second: { data: { level: 1 } }, + third: { data: { level: 1 } }, + fourth: { data: { level: 1 } }, + fifth: { data: { level: 1 } }, + sixth: { data: { level: 1 } }, + }); + +export { ONode, ONodeAdapter, getSourceTree, toString, valueOf }; diff --git a/fixtures/test-adapter.js b/fixtures/onode-adapter.js similarity index 60% rename from fixtures/test-adapter.js rename to fixtures/onode-adapter.js index 3fac95e..91f64c7 100644 --- a/fixtures/test-adapter.js +++ b/fixtures/onode-adapter.js @@ -1,4 +1,3 @@ -// node structure: { name: string, parent: node, root: node, children: node[], ... } const adapter = { validateRoot: (item) => item, @@ -6,19 +5,22 @@ const adapter = { isList: (item) => item instanceof Array, toList: (item) => (adapter.isList(item) ? item : [item]), getLength: (item) => adapter.toList(item).length, - getNodeAt: (item, index) => adapter.toList(item)[index], + getNodeAt: (item, index = 0) => adapter.toList(item)[index], // node methods - isNode: (item) => !adapter.isList(item), + isNode: (item) => item instanceof Object && !adapter.isList(item), toNode: (item) => (adapter.isList(item) ? item[0] : item), getName: (item) => adapter.toNode(item).name, hasChild: (item, name) => !!adapter.getChildrenByName(item, name).length, - getChildren: (item) => adapter.toNode(item).children, + getChildren: (item) => { + const node = adapter.toNode(item); + return (node && node.children) || []; + }, getChildrenByName: (item, name) => adapter - .toNode(item) - .children.filter((child) => adapter.getName(child) === name), - getChildAt: (item, index) => adapter.toNode(item).children[index], + .getChildren(item) + .filter((child) => adapter.getName(child) === name), + getChildAt: (item, index = 0) => adapter.toNode(item).children[index], getNodeParent: (item) => adapter.toNode(item).parent, getNodeRoot: (item) => adapter.toNode(item).root, }; diff --git a/fixtures/onode.js b/fixtures/onode.js new file mode 100644 index 0000000..ccff366 --- /dev/null +++ b/fixtures/onode.js @@ -0,0 +1,67 @@ +export const toString = (node) => { + if (!node) return ''; + + const source = node.valueOf(); + if (source instanceof Array) { + return source.map((item) => item ? item.toString() : String(item)).join('\n'); + } + + return source.toString(); +}; + +export const valueOf = (node) => { + if (!node) return null; + + const source = node.valueOf(); + if (source instanceof Array) { + return source.map((item) => item && item.valueOf()); + } + + return source.valueOf(); +}; + +export class ONode { + constructor(name, parent, root) { + this.name = name; + this.children = []; + this.parent = parent; + this.root = root || this; + } + + toString = () => `[ONode name="${this.name}" ${JSON.stringify(this.data)}]`; + valueOf = () => ({ name: this.name, data: this.data }); + normalMethod() { + return this.data; + } +} + +export const parseONodes = ( + obj, + name = '#root', + parent = undefined, + root = undefined, +) => { + const node = new ONode(name, parent, root); + const children = []; + + Object.keys(obj).forEach((key) => { + const source = obj[key]; + if (key !== 'data') { + if (source instanceof Array) { + children.push.apply( + children, + source.map((item) => parseONodes(item, key, node, root || node)), + ); + } else { + children.push(parseONodes(source, key, node, root || node)); + } + } + }); + + node.children = children; + node.data = obj.data; + + return node; +}; + +export default parseONodes; diff --git a/fixtures/tree.js b/fixtures/tree.js deleted file mode 100644 index afc2e5a..0000000 --- a/fixtures/tree.js +++ /dev/null @@ -1,55 +0,0 @@ -export class Node { - constructor(root, parent, name) { - this.root = root; - this.parent = parent; - this.name = name; - } -} - -export class ParentNode extends Node { - constructor(root, parent, name, children) { - super(root, parent, name); - this.children = children; - } -} - -export class ValueNode extends Node { - constructor(root, parent, name, value) { - super(root, parent, name); - this.value = value; - } -} - -export class RootNode extends ParentNode { - constructor(children = []) { - super(this, this, '#root', children); - } -} - -const construct = (value, name = '') => { - if (value instanceof Array) { - return value.map((item) => construct(item, name)); - } else if (typeof value === 'object') { - return constructList(value); - } - - return new ValueNode(); -}; - -const constructList = (data) => { - const children = []; - - Object.keys(data).map((name) => { - const value = data[name]; - }); - - return children; -}; - -const constructTree = (data) => { - const children = constructList(data); - - return new RootNode(children); -}; - -export default construct; diff --git a/package-lock.json b/package-lock.json index b11344d..eacd8fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@actualwave/has-own": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@actualwave/has-own/-/has-own-0.0.1.tgz", + "integrity": "sha512-XT6D4kmKRwlpZpwfNr9qLUl5q2ll1Wo0IX35ax4aIS3zOcKyuH+uyuKWnDO1WJtp0eoqGpPE9DYFUjZjjRlJ0g==" + }, "@babel/code-frame": { "version": "7.0.0-beta.44", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", @@ -921,6 +926,12 @@ "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", "dev": true }, + "babel-plugin-syntax-trailing-function-commas": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", + "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", + "dev": true + }, "babel-plugin-transform-class-properties": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz", @@ -1834,6 +1845,12 @@ "webidl-conversions": "^4.0.2" } }, + "dotenv": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz", + "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg==", + "dev": true + }, "ecc-jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", diff --git a/package.json b/package.json index d838526..1905798 100644 --- a/package.json +++ b/package.json @@ -21,19 +21,23 @@ "type": "git", "url": "https://github.com/burdiuz/js-tree-walker.git" }, - "dependencies": {}, + "dependencies": { + "@actualwave/has-own": "0.0.1" + }, "devDependencies": { "babel-core": "^6.26.0", "babel-eslint": "^8.2.2", "babel-loader": "^7.1.4", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-istanbul": "^4.1.6", + "babel-plugin-syntax-trailing-function-commas": "^6.22.0", "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-jest": "^22.4.3", "chai": "^4.1.2", + "dotenv": "^6.0.0", "eslint": "^4.19.1", "eslint-config-airbnb": "^16.1.0", "eslint-plugin-import": "^2.10.0", @@ -60,12 +64,6 @@ "git add" ] }, - "prettier": { - "singleQuote": true, - "trailing-comma": "all", - "arrowParens": "always", - "parser": "flow" - }, "babel": { "env": { "test": { @@ -97,6 +95,9 @@ "source/**/*.js", "!**/node_modules/**", "!**/vendor/**" + ], + "modulePathIgnorePatterns": [ + "\\/\\." ] }, "scripts": { diff --git a/rollup.helpers.js b/rollup.helpers.js index 5c18271..5b6769f 100644 --- a/rollup.helpers.js +++ b/rollup.helpers.js @@ -1,3 +1,4 @@ +import { config } from 'dotenv'; import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; import babel from 'rollup-plugin-babel'; @@ -9,6 +10,8 @@ import { minify } from 'uglify-es'; export const LIBRARY_FILE_NAME = 'tree-walker'; // dummy, replace with project name export const LIBRARY_VAR_NAME = 'TreeWalker'; // dummy, replace with project name +config(); + export const plugins = [ resolve(), // flow(), @@ -52,8 +55,5 @@ export const minConfig = { format: 'umd', }, ], - plugins: [ - ...plugins, - uglify({}, minify), - ], + plugins: [...plugins, uglify({}, minify)], }; diff --git a/source/__tests__/default-adapter.js b/source/__tests__/default-adapter.js new file mode 100644 index 0000000..99cab07 --- /dev/null +++ b/source/__tests__/default-adapter.js @@ -0,0 +1,27 @@ +/* eslint-disable global-require */ +describe('Default Adapter', () => { + let setDefaultAdapter; + let getDefaultAdapter; + + beforeEach(() => { + jest.resetModules(); + + ({ setDefaultAdapter, getDefaultAdapter } = require('../default-adapter')); + }); + + const ADAPTER = { type: 'default-adapter' }; + + it('should not have default adapter at beginnig', () => { + expect(getDefaultAdapter()).toBe(undefined); + }); + + describe('When set default adapter', () => { + beforeEach(() => { + setDefaultAdapter(ADAPTER); + }); + + it('should have default adapter', () => { + expect(getDefaultAdapter()).toBe(ADAPTER); + }); + }); +}); diff --git a/source/__tests__/index.js b/source/__tests__/index.js index 25e4bd7..930ba35 100644 --- a/source/__tests__/index.js +++ b/source/__tests__/index.js @@ -1,11 +1,57 @@ -import SomeString from '../index'; +/* eslint-disable global-require */ +import { create } from '../index'; +import { ONodeAdapter, getSourceTree } from '../../fixtures'; -describe('index', () => { - it('should export string as default', () => { - expect(typeof SomeString).toEqual('string'); +describe('When initialized', () => { + let addAugs; + let coreAugs; + + beforeEach(() => { + jest.resetModules(); + jest.doMock('../augmentations/core', () => ({ + type: 'core-augmentations', + })); + jest.doMock('../augmentations', () => ({ + addAugmentations: jest.fn(), + resetAugmentations: jest.fn(), + })); + + coreAugs = require('../augmentations/core'); + ({ addAugmentations: addAugs } = require('../augmentations')); + require('../index'); + }); + + it('should add core augmentations', () => { + expect(addAugs).toHaveBeenCalledTimes(1); + expect(addAugs).toHaveBeenCalledWith(coreAugs); + }); +}); + +describe('create()', () => { + let source; + let root; + + beforeEach(() => { + source = getSourceTree(); + jest.spyOn(ONodeAdapter, 'validateRoot'); + root = create(source, ONodeAdapter); + }); + + afterEach(() => { + ONodeAdapter.validateRoot.mockRestore(); + }); + + it('should validate root node', () => { + expect(ONodeAdapter.validateRoot).toHaveBeenCalledTimes(1); + expect(ONodeAdapter.validateRoot).toHaveBeenCalledWith(source); }); - it('should export non-empty string', () => { - expect(SomeString).toBeTruthy(); + it('should result with wrapped root node', () => { + expect(root.first.first.uniqueName.valueOf()).toEqual([ + expect.objectContaining({ + name: 'uniqueName', + data: { uniqueParam: '123-456', level: 3 }, + }), + ]); }); }); diff --git a/source/__tests__/prefixes.js b/source/__tests__/prefixes.js index e69de29..1e96886 100644 --- a/source/__tests__/prefixes.js +++ b/source/__tests__/prefixes.js @@ -0,0 +1,113 @@ +/* eslint-disable global-require */ +import { create } from '../index'; +import { setNamePrefix, isValidPrefix } from '../prefixes'; +import { ONodeAdapter, getSourceTree } from '../../fixtures'; + +const DATA_PREFIX = '$'; + +const dataPrefixGetHandler = (target, adapter, [name]) => { + const node = adapter.toNode(target); + return node.data ? node.data[name] : undefined; +}; + +describe('Using data prefixes', () => { + let source; + let root; + + beforeEach(() => { + setNamePrefix(DATA_PREFIX, dataPrefixGetHandler); + source = getSourceTree(); + + root = create(source, ONodeAdapter); + }); + + describe('GET', () => { + describe('When get from node', () => { + it('should return data property value', () => { + expect(root.$level).toBe(0); + expect(root.first.$level).toBe(1); + expect(root.first.first.third.$index).toBe(0); + expect(root.first.first.uniqueName.$uniqueParam).toBe('123-456'); + }); + }); + + describe('When get from list', () => { + it('should return data property value', () => { + expect(root.first.first.third[0].$index).toBe(0); + expect(root.first.first.third[2].$index).toBe(2); + }); + }); + }); + + describe('APPLY', () => { + // FIXME create augmentation that accepts additional arguments + }); +}); + +describe('isValidPrefix()', () => { + describe('When prefix not registered', () => { + let _isValidPrefix; + let _setNamePrefix; + + beforeEach(() => { + jest.resetModules(); + ({ + isValidPrefix: _isValidPrefix, + setNamePrefix: _setNamePrefix, + } = require('../prefixes')); + }); + + it('should result with FALSE', () => { + expect(_isValidPrefix(DATA_PREFIX)).toBe(false); + }); + + describe('When prefix registered', () => { + beforeEach(() => { + _setNamePrefix(DATA_PREFIX, dataPrefixGetHandler); + }); + + it('should result with TRUE', () => { + expect(_isValidPrefix(DATA_PREFIX)).toBe(true); + }); + }); + }); + + it('should result with FALSE for non registered prefix', () => { + expect(isValidPrefix('a')).toBe(false); + expect(isValidPrefix('@')).toBe(false); + expect(isValidPrefix(' ')).toBe(false); + + expect(isValidPrefix(true)).toBe(false); + expect(isValidPrefix(2)).toBe(false); + expect(isValidPrefix('abc')).toBe(false); + }); +}); + +describe('getPrefixHandler()', () => { + let _getPrefixHandler; + let _setNamePrefix; + + beforeEach(() => { + jest.resetModules(); + ({ + getPrefixHandler: _getPrefixHandler, + setNamePrefix: _setNamePrefix, + } = require('../prefixes')); + }); + + describe('When prefix not registered', () => { + it('should result with NULL', () => { + expect(_getPrefixHandler(DATA_PREFIX)).toBeUndefined(); + }); + }); + + describe('When prefix registered', () => { + beforeEach(() => { + _setNamePrefix(DATA_PREFIX, dataPrefixGetHandler); + }); + + it('should result with fhandler function', () => { + expect(_getPrefixHandler(DATA_PREFIX)).toBe(dataPrefixGetHandler); + }); + }); +}); diff --git a/source/__tests__/utils.js b/source/__tests__/utils.js index e69de29..cff1142 100644 --- a/source/__tests__/utils.js +++ b/source/__tests__/utils.js @@ -0,0 +1,85 @@ +import { isIntKey, getValue, getSingleNode, getNodeList } from '../utils'; +import { ONodeAdapter, getSourceTree } from '../../fixtures'; + +describe('When using utils', () => { + let source; + + beforeEach(() => { + source = getSourceTree(); + }); + + describe('isIntKey()', () => { + it('should verify integer strings', () => { + expect(isIntKey(123)).toBe(true); + expect(isIntKey('123')).toBe(true); + expect(isIntKey('a123')).toBe(false); + expect(isIntKey('0xF0')).toBe(false); + expect(isIntKey('0x12')).toBe(false); + expect(isIntKey('123a')).toBe(false); + }); + }); + + describe('getValue()', () => { + beforeEach(() => { + jest.spyOn(ONodeAdapter, 'getChildrenByName'); + }); + + afterEach(() => { + ONodeAdapter.getChildrenByName.mockRestore(); + }); + + describe('When has child name', () => { + it('should result with child node', () => { + expect(getValue(source, ONodeAdapter, 'third')).toHaveLength(1); + expect(getValue(source, ONodeAdapter, 'third')[0]).toEqual( + expect.objectContaining({ + name: 'third', + data: { level: 1 }, + }), + ); + }); + }); + + describe('When has child name is undefined', () => { + it('should result with same node', () => { + expect(getValue(source, ONodeAdapter)).toBe(source); + }); + }); + }); + + describe('getSingleNode()', () => { + it('should result with child node', () => { + expect(getSingleNode(source, ONodeAdapter, 'third')).toEqual( + expect.objectContaining({ + name: 'third', + data: { level: 1 }, + }), + ); + }); + }); + + describe('When has child name is undefined', () => { + it('should result with same node', () => { + expect(getSingleNode(source, ONodeAdapter)).toBe(source); + }); + }); + + describe('getNodeList()', () => { + it('should result with child nodes list', () => { + expect(getNodeList(source, ONodeAdapter, 'third')).toHaveLength(1); + expect(getNodeList(source, ONodeAdapter, 'third')[0]).toEqual( + expect.objectContaining({ + name: 'third', + data: { level: 1 }, + }), + ); + }); + }); + + describe('When has child name is undefined', () => { + it('should result with one-item-list of same node', () => { + expect(getNodeList(source, ONodeAdapter)).toHaveLength(1); + expect(getNodeList(source, ONodeAdapter)[0]).toBe(source); + }); + }); +}); diff --git a/source/__tests__/wrapper.js b/source/__tests__/wrapper.js index e69de29..094374a 100644 --- a/source/__tests__/wrapper.js +++ b/source/__tests__/wrapper.js @@ -0,0 +1,115 @@ +import wrap from '../wrapper'; +import { ONode, ONodeAdapter, getSourceTree, valueOf } from '../../fixtures'; +import { addAugmentations, resetAugmentations } from '../augmentations'; +import coreAugmentations from '../augmentations/core'; + +describe('Using wrapper Proxy', () => { + let source; + let root; + + beforeEach(() => { + addAugmentations(coreAugmentations); + + source = getSourceTree(); + root = wrap(source, ONodeAdapter); + }); + + afterEach(() => { + resetAugmentations(); + }); + + describe('GET', () => { + describe('When getting child by name', () => { + it('should result with list of nodes', () => { + expect(valueOf(root.first)).toEqual([ + { name: 'first', data: { level: 1 } }, + ]); + }); + }); + describe('When no children found', () => { + it('should result with empty list to supress errors', () => { + expect(valueOf(root.unk34own.chil$dren.some_thing)).toEqual([]); + expect(valueOf(root.first.first.unk34own.chil$dren.some_thing)).toEqual( + [], + ); + }); + }); + + describe('When getting child by index', () => { + it('should result with list of nodes', () => { + expect(valueOf(root[0])).toEqual({ name: '#root', data: { level: 0 } }); + expect(valueOf(root.first[0])).toEqual({ + name: 'first', + data: { level: 1 }, + }); + expect(valueOf(root.first[1])).toBeNull(); + expect(valueOf(root.first.first.third[0])).toEqual({ + name: 'third', + data: { level: 3, index: 0 }, + }); + expect(valueOf(root.first.first.third[1])).toEqual({ + name: 'third', + data: { level: 3, index: 1 }, + }); + expect(valueOf(root.first.first.third[2])).toEqual({ + name: 'third', + data: { level: 3, index: 2 }, + }); + }); + }); + + describe('When getting descendant by name', () => { + it('should result with list of nodes', () => { + expect(valueOf(root.first.first.second)).toEqual([ + { name: 'second', data: { level: 3 } }, + ]); + }); + }); + + describe('When getting multiple descendants by name', () => { + it('should result with list of nodes', () => { + expect(valueOf(root.first.first.third)).toEqual([ + { name: 'third', data: { index: 0, level: 3 } }, + { name: 'third', data: { index: 1, level: 3 } }, + { name: 'third', data: { index: 2, level: 3 } }, + { name: 'third', data: { index: 3, level: 3 } }, + ]); + }); + }); + + describe('When requesting restricted properties', () => { + it('should return values as is', () => { + expect(root.constructor).toBe(ONode); + // results with unwrapped value, undefined + expect(root.prototype).toBeUndefined(); + }); + }); + }); + + describe('HAS', () => { + describe('When checking child by name', () => { + it('should result with TRUE for existing child', () => { + expect('first' in root).toBe(true); + expect(0 in root.first).toBe(true); + expect('first' in root.first).toBe(true); + expect('third' in root.first.first).toBe(true); + expect(3 in root.first.first.third).toBe(true); + }); + + it('should result with FALSE for non existing child', () => { + expect('last' in root).toBe(false); + expect(1 in root.first).toBe(false); + expect('something' in root.first).toBe(false); + expect(5 in root.first.first.third).toBe(false); + }); + }); + }); + + describe('APPLY', () => { + describe('When calling method of node', () => { + it('should result with calling method directly', () => { + expect(valueOf(root.first.normalMethod())).toEqual({ level: 1 }); + }); + }); + }); +}); diff --git a/source/augmentations/__tests__/core.js b/source/augmentations/__tests__/core.js index e69de29..cdeb165 100644 --- a/source/augmentations/__tests__/core.js +++ b/source/augmentations/__tests__/core.js @@ -0,0 +1,25 @@ +import { create } from '../../index'; +import { ONode, ONodeAdapter, getSourceTree } from '../../../fixtures'; + +describe('Core augmentations', () => { + let source; + let root; + + beforeEach(() => { + source = getSourceTree(); + root = create(source, ONodeAdapter); + }); + + describe('toString()', () => { + it('should return unwrapped source node', () => { + expect(root.first.toString()).toBe('[ONode name="first" {"level":1}]'); + }); + }); + + describe('valueOf()', () => { + it('should return unwrapped source node', () => { + expect(root.first.valueOf()[0]).toBeInstanceOf(ONode); + expect(root.first.valueOf()[0].name).toBe('first'); + }); + }); +}); diff --git a/source/augmentations/__tests__/index.js b/source/augmentations/__tests__/index.js new file mode 100644 index 0000000..13f9171 --- /dev/null +++ b/source/augmentations/__tests__/index.js @@ -0,0 +1,83 @@ +/* eslint-disable global-require */ +describe('Augmentations', () => { + let resetAugmentations; + let addAugmentations; + let hasAugmentation; + let getAugmentation; + let applyAugmentation; + + beforeEach(() => { + jest.resetModules(); + + ({ + resetAugmentations, + addAugmentations, + hasAugmentation, + getAugmentation, + applyAugmentation, + } = require('../index')); + }); + + const AUG1_NAME = 'augment1'; + const AUG1_HANDLER = (...args) => `AUG1: ${args.join(', ')}`; + + const AUG2_NAME = 'augment2'; + const AUG2_HANDLER = (...args) => `AUG2: ${args.join(', ')}`; + + it('should not have augmentation at beginning', () => { + expect(hasAugmentation(AUG1_NAME)).toBe(false); + expect(hasAugmentation(AUG2_NAME)).toBe(false); + }); + + describe('When register augmentations', () => { + beforeEach(() => { + addAugmentations({ + [AUG1_NAME]: AUG1_HANDLER, + [AUG2_NAME]: AUG2_HANDLER, + }); + }); + + it('should have added augmentations', () => { + expect(hasAugmentation(AUG1_NAME)).toBe(true); + expect(getAugmentation(AUG1_NAME)).toBe(AUG1_HANDLER); + expect(hasAugmentation(AUG2_NAME)).toBe(true); + expect(getAugmentation(AUG2_NAME)).toBe(AUG2_HANDLER); + }); + + describe('When augmenation applied', () => { + it('should be called with all arguments', () => { + expect(applyAugmentation(AUG1_NAME, 1, 2, 'three')).toBe( + 'AUG1: 1, 2, three', + ); + }); + }); + + describe('When augmentations reset', () => { + beforeEach(() => { + resetAugmentations(); + }); + + it('should not have augmentation', () => { + expect(hasAugmentation(AUG1_NAME)).toBe(false); + expect(getAugmentation(AUG1_NAME)).toBe(undefined); + expect(hasAugmentation(AUG2_NAME)).toBe(false); + expect(getAugmentation(AUG2_NAME)).toBe(undefined); + }); + }); + + describe('When augmentations replace', () => { + beforeEach(() => { + resetAugmentations({ + [AUG1_NAME]: AUG2_HANDLER, + }); + }); + + it('should have augmentations replaced', () => { + expect(hasAugmentation(AUG1_NAME)).toBe(true); + expect(getAugmentation(AUG1_NAME)).toBe(AUG2_HANDLER); + expect(hasAugmentation(AUG2_NAME)).toBe(false); + expect(getAugmentation(AUG2_NAME)).toBe(undefined); + }); + }); + }); +}); diff --git a/source/augmentations/__tests__/list.js b/source/augmentations/__tests__/list.js index e69de29..18a6778 100644 --- a/source/augmentations/__tests__/list.js +++ b/source/augmentations/__tests__/list.js @@ -0,0 +1,163 @@ +import { + create, + addAugmentations, + nodeAugmentations, + listAugmentations, +} from '../../index'; +import { ONodeAdapter, getSourceTree, valueOf } from '../../../fixtures'; + +describe('Node augmentations', () => { + let source; + let root; + + addAugmentations(nodeAugmentations); + addAugmentations(listAugmentations); + + beforeEach(() => { + source = getSourceTree(); + root = create(source, ONodeAdapter); + }); + + describe('length()', () => { + it('should result with length of a list', () => { + expect(root.length()).toBe(1); + expect(root.children().length()).toBe(6); + expect(root.first.first.third.length()).toBe(4); + }); + }); + + describe('at()', () => { + it('should result with single node ot of the list', () => { + expect(valueOf(root.at(0))).toEqual({ + data: { level: 0 }, + name: '#root', + }); + expect(valueOf(root.children().at(0))).toEqual({ + data: { level: 1 }, + name: 'first', + }); + expect(valueOf(root.children().at(5))).toEqual({ + data: { level: 1 }, + name: 'sixth', + }); + expect(valueOf(root.first.first.third.at(0))).toEqual({ + data: { index: 0, level: 3 }, + name: 'third', + }); + expect(valueOf(root.first.first.third.at(3))).toEqual({ + data: { index: 3, level: 3 }, + name: 'third', + }); + expect(valueOf(root.first.first.at(3000))).toEqual([]); + }); + }); + + describe('first()', () => { + it('should result with first node ot of the list', () => { + expect(valueOf(root.first())).toEqual({ + data: { level: 0 }, + name: '#root', + }); + expect(valueOf(root.children().first())).toEqual({ + data: { level: 1 }, + name: 'first', + }); + expect(valueOf(root.first.first.third.first())).toEqual({ + data: { index: 0, level: 3 }, + name: 'third', + }); + }); + }); + + describe('filter()', () => { + it('should return filtered list', () => { + expect(valueOf(root.filter(() => true))).toEqual([ + { data: { level: 0 }, name: '#root' }, + ]); + + expect(valueOf(root.filter(() => false))).toEqual([]); + + expect( + valueOf( + root.descendants().filter((item) => item.valueOf().name === 'third'), + ), + ).toEqual([ + { data: { level: 1 }, name: 'third' }, + { data: { level: 2 }, name: 'third' }, + { data: { index: 0, level: 3 }, name: 'third' }, + { data: { index: 1, level: 3 }, name: 'third' }, + { data: { index: 2, level: 3 }, name: 'third' }, + { data: { index: 3, level: 3 }, name: 'third' }, + { data: { level: 4 }, name: 'third' }, + ]); + + expect( + valueOf( + root.descendants().filter((item) => item.valueOf().data.level === 3), + ), + ).toEqual([ + { data: { level: 3 }, name: 'first' }, + { data: { level: 3 }, name: 'second' }, + { data: { index: 0, level: 3 }, name: 'third' }, + { data: { index: 1, level: 3 }, name: 'third' }, + { data: { index: 2, level: 3 }, name: 'third' }, + { data: { index: 3, level: 3 }, name: 'third' }, + { data: { level: 3 }, name: 'fourth' }, + { data: { level: 3, uniqueParam: '123-456' }, name: 'uniqueName' }, + { data: { level: 3 }, name: 'fifth' }, + { data: { level: 3 }, name: 'sixth' }, + ]); + }); + }); + + describe('map()', () => { + it('should return mapped list', () => { + expect( + valueOf( + root + .descendants() + .map((item) => (item.valueOf().data.level === 2 ? item : null)), + ).map((item) => item && item.valueOf()), + ).toEqual([ + null, + null, + null, + null, + null, + null, + { name: 'first', data: { level: 2 } }, + { name: 'second', data: { level: 2 } }, + { name: 'third', data: { level: 2 } }, + { name: 'fourth', data: { level: 2 } }, + { name: 'fifth', data: { level: 2 } }, + { name: 'sixth', data: { level: 2 } }, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + ]); + }); + }); + + describe('reduce()', () => { + it('should return reduced value', () => { + expect( + root + .descendants() + .reduce((total, item) => total + item.valueOf().data.level, 0), + ).toEqual(72); + }); + }); +}); diff --git a/source/augmentations/__tests__/node.js b/source/augmentations/__tests__/node.js index e69de29..a84a78e 100644 --- a/source/augmentations/__tests__/node.js +++ b/source/augmentations/__tests__/node.js @@ -0,0 +1,152 @@ +import { create, addAugmentations, nodeAugmentations } from '../../index'; +import { ONodeAdapter, getSourceTree, valueOf } from '../../../fixtures'; + +describe('Node augmentations', () => { + let source; + let root; + + addAugmentations(nodeAugmentations); + + beforeEach(() => { + source = getSourceTree(); + root = create(source, ONodeAdapter); + }); + + describe('children()', () => { + it('should result with direct children of the node', () => { + expect(valueOf(root.children())).toEqual([ + { name: 'first', data: { level: 1 } }, + { name: 'second', data: { level: 1 } }, + { name: 'third', data: { level: 1 } }, + { name: 'fourth', data: { level: 1 } }, + { name: 'fifth', data: { level: 1 } }, + { name: 'sixth', data: { level: 1 } }, + ]); + + expect(valueOf(root.first.first.children())).toEqual([ + { name: 'first', data: { level: 3 } }, + { name: 'second', data: { level: 3 } }, + { name: 'third', data: { index: 0, level: 3 } }, + { name: 'third', data: { index: 1, level: 3 } }, + { name: 'third', data: { index: 2, level: 3 } }, + { name: 'third', data: { index: 3, level: 3 } }, + { name: 'fourth', data: { level: 3 } }, + { + name: 'uniqueName', + data: { uniqueParam: '123-456', level: 3 }, + }, + { name: 'fifth', data: { level: 3 } }, + { name: 'sixth', data: { level: 3 } }, + ]); + + expect(valueOf(root.second.children())).toEqual([]); + }); + + describe('When name provided', () => { + it('should return children by name', () => { + expect(valueOf(root.children('second'))).toEqual([ + { name: 'second', data: { level: 1 } }, + ]); + + expect(valueOf(root.children('unknown'))).toEqual([]); + + expect(valueOf(root.first.first.children('third'))).toEqual([ + { name: 'third', data: { index: 0, level: 3 } }, + { name: 'third', data: { index: 1, level: 3 } }, + { name: 'third', data: { index: 2, level: 3 } }, + { name: 'third', data: { index: 3, level: 3 } }, + ]); + }); + }); + }); + + describe('descendants()', () => { + it('should result with all descendants of the node', () => { + expect(valueOf(root.first.first.descendants())).toEqual([ + { data: { level: 3 }, name: 'first' }, + { data: { level: 3 }, name: 'second' }, + { data: { index: 0, level: 3 }, name: 'third' }, + { data: { index: 1, level: 3 }, name: 'third' }, + { data: { index: 2, level: 3 }, name: 'third' }, + { data: { index: 3, level: 3 }, name: 'third' }, + { data: { level: 3 }, name: 'fourth' }, + { data: { level: 3, uniqueParam: '123-456' }, name: 'uniqueName' }, + { data: { level: 3 }, name: 'fifth' }, + { data: { level: 3 }, name: 'sixth' }, + { data: { level: 4 }, name: 'first' }, + { data: { level: 4 }, name: 'second' }, + { data: { level: 4 }, name: 'third' }, + { data: { level: 4 }, name: 'fourth' }, + { data: { level: 4 }, name: 'fifth' }, + { data: { level: 4 }, name: 'sixth' }, + ]); + + expect(valueOf(root.first.first.first.descendants())).toEqual([ + { name: 'first', data: { level: 4 } }, + { name: 'second', data: { level: 4 } }, + { name: 'third', data: { level: 4 } }, + { name: 'fourth', data: { level: 4 } }, + { name: 'fifth', data: { level: 4 } }, + { name: 'sixth', data: { level: 4 } }, + ]); + + expect(valueOf(root.first.first.third.descendants())).toEqual([]); + + expect(valueOf(root.second.descendants())).toEqual([]); + }); + + describe('When name provided', () => { + it('should return children by name', () => { + expect(valueOf(root.descendants('second'))).toEqual([ + { data: { level: 1 }, name: 'second' }, + { data: { level: 2 }, name: 'second' }, + { data: { level: 3 }, name: 'second' }, + { data: { level: 4 }, name: 'second' }, + ]); + + expect(valueOf(root.descendants('unknown'))).toEqual([]); + + expect(valueOf(root.first.first.descendants('third'))).toEqual([ + { data: { index: 0, level: 3 }, name: 'third' }, + { data: { index: 1, level: 3 }, name: 'third' }, + { data: { index: 2, level: 3 }, name: 'third' }, + { data: { index: 3, level: 3 }, name: 'third' }, + { data: { level: 4 }, name: 'third' }, + ]); + }); + }); + }); + + describe('childAt()', () => { + it('should return child by index', () => { + expect(valueOf(root.childAt(0))).toEqual({ + name: 'first', + data: { level: 1 }, + }); + expect(valueOf(root.childAt(3))).toEqual({ + name: 'fourth', + data: { level: 1 }, + }); + expect(valueOf(root.first.first.first.childAt(5))).toEqual({ + name: 'sixth', + data: { level: 4 }, + }); + }); + }); + + describe('root()', () => { + it('should result with parent node', () => { + expect(root.root().valueOf()).toBe(source); + expect(root.first.root().valueOf()).toBe(source); + expect(root.first.first.root().valueOf()).toBe(source); + }); + }); + + describe('parent()', () => { + it('should result with parent node', () => { + expect(root.parent()).toBeUndefined(); + expect(root.first.parent().valueOf()).toBe(source); + expect(root.first.first.parent().valueOf()).toBe(source.children[0]); + }); + }); +}); diff --git a/source/augmentations/core.js b/source/augmentations/core.js index 730943e..d03636f 100644 --- a/source/augmentations/core.js +++ b/source/augmentations/core.js @@ -4,5 +4,4 @@ const valueOf = (node) => node; export default { toString, valueOf, - [Symbol.toPrimitive]: (node) => node, }; diff --git a/source/augmentations/index.js b/source/augmentations/index.js index 6bfe241..1046e28 100644 --- a/source/augmentations/index.js +++ b/source/augmentations/index.js @@ -1,21 +1,20 @@ +import hasOwn from '@actualwave/has-own'; + let augmentations = {}; export const resetAugmentations = (augs = {}) => { augmentations = augs; }; -export const addAugmentations = (augs = {}) => { +export const addAugmentations = (augs) => { augmentations = { ...augmentations, ...augs, }; }; -export const hasAugmentation = (key) => ( - key - && typeof key === 'string' - && augmentations.hasOwnProperty(key) -); +export const hasAugmentation = (key) => + key && typeof key === 'string' && hasOwn(augmentations, key); export const getAugmentation = (key) => augmentations[key]; diff --git a/source/augmentations/list.js b/source/augmentations/list.js index f20a500..81daf8e 100644 --- a/source/augmentations/list.js +++ b/source/augmentations/list.js @@ -9,10 +9,8 @@ const length = (node, adapter) => { }; const at = (node, adapter, args, utils) => { - const [index] = args; - // return empty array, which will create empty wrapper for chained calls, - // this will make next calls errorless. - let result = []; + const [index = 0] = args; + let result; if (adapter.isList(node)) { const child = adapter.getNodeAt(node, index); @@ -20,9 +18,13 @@ const at = (node, adapter, args, utils) => { if (child) { result = child; } + } else if (!index) { + result = node; } - return utils.wrap(result, adapter); + // if nothing found return empty array, which will create empty wrapper for + // chained calls, this will make next calls errorless. + return utils.wrap(result || [], adapter); }; const first = (node, adapter, args, utils) => at(node, adapter, [0], utils); @@ -45,29 +47,26 @@ const filter = (node, adapter, [callback], utils) => { return utils.wrap(result, adapter); }; -const map = (node, adapter, [callback, wrapNodes = true], utils) => { +const map = (node, adapter, [callback], utils) => { // apply map on element collection - // if wrapNodes in FALSE, will generate normal Array with RAW results in it - // if wrapNodes in TRUE and all elements of resulting list are nodes, will - // generate wrapped list and put all result into it const list = adapter.toList(node); const listLength = adapter.getLength(list); const result = []; - let areNodes = true; - const wrappedNode = utils.wrap(list, adapter); + const wrappedList = utils.wrap(list, adapter); for (let index = 0; index < listLength; index += 1) { const child = adapter.getNodeAt(list, index); const childResult = callback( utils.wrap(child, adapter), index, - wrappedNode + wrappedList, ); - areNodes = areNodes && adapter.isNode(childResult); result.push(childResult); } - return wrapNodes && areNodes ? utils.wrap(result, adapter) : result; + // returns normal array because we don't know if all items in result are nodes + // and if they are, they will be likely already wrapped + return result; }; const reduce = (node, adapter, [callback, result], utils) => { @@ -80,10 +79,10 @@ const reduce = (node, adapter, [callback, result], utils) => { for (let index = 0; index < listLength; index += 1) { const child = adapter.getNodeAt(list, index); lastResult = callback( - result, + lastResult, utils.wrap(child, adapter), index, - wrappedNode + wrappedNode, ); } @@ -96,5 +95,5 @@ export default { first, filter, map, - reduce + reduce, }; diff --git a/source/augmentations/node.js b/source/augmentations/node.js index 9f5cd44..518a9fa 100644 --- a/source/augmentations/node.js +++ b/source/augmentations/node.js @@ -15,17 +15,22 @@ const children = (node, adapter, [childName], utils) => { * @internal */ const descendantsAll = (node, adapter, args, utils) => { - const result = []; + const children = []; // eslint-disable-line no-shadow + const descendants = []; const list = adapter.getChildren(node); const length = adapter.getLength(list, adapter); for (let index = 0; index < length; index += 1) { const child = list[index]; - result.push(child); - result.push.apply(result, descendantsAll(child, adapter, args, utils)); + children.push(child); + descendants.push.apply( + descendants, + descendantsAll(child, adapter, args, utils), + ); } - return result; + /* children go first, then other descendants */ + return [...children, ...descendants]; }; /** @@ -33,19 +38,25 @@ const descendantsAll = (node, adapter, args, utils) => { */ const descendantsByName = (node, adapter, args, utils) => { const [childName] = args; - const result = []; + const children = []; // eslint-disable-line no-shadow + const descendants = []; const list = adapter.getChildren(node); const length = adapter.getLength(list, adapter); for (let index = 0; index < length; index += 1) { const child = list[index]; if (adapter.getName(child) === childName) { - result.push(child); + children.push(child); } - result.push.apply(result, descendantsByName(child, adapter, args, utils)); + + descendants.push.apply( + descendants, + descendantsByName(child, adapter, args, utils), + ); } - return result; + /* children go first, then other descendants */ + return [...children, ...descendants]; }; const descendants = (node, adapter, args, utils) => { @@ -72,5 +83,5 @@ export default { descendants, childAt, root, - parent + parent, }; diff --git a/source/default-adapter.js b/source/default-adapter.js index 9dd28a6..e0587c8 100644 --- a/source/default-adapter.js +++ b/source/default-adapter.js @@ -1,4 +1,4 @@ -let defaultAdapter = null; +let defaultAdapter; export const setDefaultAdapter = (adapter) => { defaultAdapter = adapter; diff --git a/source/prefixes.js b/source/prefixes.js index f9eb9f4..6ee59fa 100644 --- a/source/prefixes.js +++ b/source/prefixes.js @@ -1,15 +1,15 @@ +import hasOwn from '@actualwave/has-own'; + const namePrefixes = {}; export const isValidPrefix = (prefix) => - typeof prefix === 'string' && - prefix.length === 1 && - namePrefixes.hasOwnProperty(prefix); + typeof prefix === 'string' && hasOwn(namePrefixes, prefix); export const isPrefixedKey = (key) => key && typeof key === 'string' && key.length > 1 && - namePrefixes.hasOwnProperty(key.charAt()); + hasOwn(namePrefixes, key.charAt()); export const getPrefixHandler = (key) => namePrefixes[key.charAt()]; diff --git a/source/stub-adapter.js b/source/stub-adapter.js deleted file mode 100644 index cd4aa02..0000000 --- a/source/stub-adapter.js +++ /dev/null @@ -1,26 +0,0 @@ -const fn = () => { - throw new Error('Method not implemented'); -}; - -const adapter = { - validateRoot: fn, - - // list methods - isList: fn, - toList: fn, - getLength: fn, - getNodeAt: fn, - - // node methods - isNode: fn, - toNode: fn, - getName: fn, - hasChild: fn, - getChildren: fn, - getChildrenByName: fn, - getChildAt: fn, - getNodeParent: fn, - getNodeRoot: fn -}; - -export default adapter; diff --git a/source/utils.js b/source/utils.js index e4a2f82..04f3d93 100644 --- a/source/utils.js +++ b/source/utils.js @@ -1,4 +1,8 @@ -export const isIntKey = (key) => (`${parseInt(key, 10)}` === key); +export const isIntKey = (key) => + // it is unsigned int + (typeof key === 'number' && key >>> 0 === key) || + // it is integer number string + `${parseInt(String(key), 10)}` === key; export const getValue = (node, adapter, childName = undefined) => { if (childName !== undefined) { @@ -8,16 +12,8 @@ export const getValue = (node, adapter, childName = undefined) => { return node; }; -export const getSingleNode = (node, adapter, childName = undefined) => { - const value = getValue(node, adapter, childName); +export const getSingleNode = (node, adapter, childName = undefined) => + adapter.toNode(getValue(node, adapter, childName)); - if (adapter.isList(value)) { - return adapter.getNodeAt(node); - } - - return value; -}; - -export const getNodeList = (node, adapter, childName = undefined) => { - return adapter.toList(getValue(node, adapter, childName)); -}; +export const getNodeList = (node, adapter, childName = undefined) => + adapter.toList(getValue(node, adapter, childName)); diff --git a/source/wrapper.js b/source/wrapper.js index 0175c1a..5b9438d 100644 --- a/source/wrapper.js +++ b/source/wrapper.js @@ -1,24 +1,21 @@ -import { - isIntKey, - getValue, - getSingleNode, - getNodeList, -} from './utils'; +import { isIntKey, getValue, getSingleNode, getNodeList } from './utils'; -import { - isPrefixedKey, - isValidPrefix, - getPrefixHandler, -} from './prefixes'; +import { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes'; -import { - hasAugmentation, - applyAugmentation, -} from './augmentations'; +import { hasAugmentation, applyAugmentation } from './augmentations'; let handlers; let utils; +const GET_RESTRICTED_NAMES = { + constructor: true, + prototype: true, + /* + call: true, + apply: true, + */ +}; + const createWalkerNode = (node, adapter, childName = undefined) => { function TreeWalker() { throw new Error('Should have been never called'); @@ -53,22 +50,37 @@ utils = { const get = ({ node, adapter, childName }, key) => { /* + if symbol, return node property if string childName used if starts with $, return attribute value else return wrapper with current single node and property childName if numeric index used, use node as parent and childName is undefined */ + if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) { + return node[key]; + } + if (isIntKey(key)) { - return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter); + return wrap( + adapter.getNodeAt(getNodeList(node, adapter, childName), key), + adapter, + ); } if (isPrefixedKey(key)) { const handler = getPrefixHandler(key); - return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils); + return handler( + getValue(node, adapter, childName), + adapter, + [key.substr(1)], + utils, + ); } + const result = getValue(node, adapter, childName); + // return wrap with node and childName - return wrap(getValue(node, adapter, childName), adapter, key); + return wrap(result, adapter, key); }; const has = ({ node, adapter, childName }, key) => { @@ -79,10 +91,11 @@ const has = ({ node, adapter, childName }, key) => { if (isPrefixedKey(key)) { // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1)); // don't know how to implement this, calling same handler as in GET seems overkill + // FIXME let user to register GET and optional SET/HAS handlers return true; } - return adapter.hasChild(getSingleNode(), key); + return adapter.hasChild(getSingleNode(node, adapter, childName), key); }; const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { @@ -92,9 +105,17 @@ const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { // this works only of childName === prefix, one char string // otherwise it should be passed into arguments + + // FIXME if GET always return result of prefixed property, means there are + // no cases when we get a wrapped node to APPLY trap with prefixed name. if (isValidPrefix(childName)) { const handler = getPrefixHandler(childName); - return handler(node, adapter, argumentsList, utils); + return handler( + node, + adapter, + [childName.substr(1), ...argumentsList], + utils, + ); } if (hasAugmentation(childName)) { @@ -103,6 +124,12 @@ const apply = ({ node, adapter, childName }, thisArg, argumentsList) => { return applyAugmentation(childName, node, adapter, argumentsList, utils); } + // in case of normal function being called out of the tree node + const targetNode = adapter.toNode(node); + if (typeof targetNode[childName] === 'function') { + return targetNode[childName](...argumentsList); + } + // FIXME might throw only in dev mode(needs implementation) throw new Error(`"${childName}" is not a callable object.`); }; @@ -114,4 +141,3 @@ handlers = { }; export default wrap; - diff --git a/stub-adapter.js b/stub-adapter.js new file mode 100644 index 0000000..09e5b0a --- /dev/null +++ b/stub-adapter.js @@ -0,0 +1,119 @@ +const fn = () => { + throw new Error('Method not implemented'); +}; + +/** + * @typedef {Object[]} List + */ + +/** + * List with single Node should be treated as Node + * @typedef {Object|List} Node + */ + +/** + * Name could be of any type, Proxy wrapper supports only String(even for array + * indexes) and Symbol. But augmentations may pass any type. + * @typedef {number|string|symbol} Name + */ + +/** + * @type {Adapter} + */ +const adapter = { + /** + * Prepare root node before using, called when root wrapper created. + * @param {Object} root + * @return {Object} + */ + validateRoot: () => fn(), + + // list methods + /** + * Check if any object is a list of nodes. + * @param {Object} list + * @return {Boolean} + */ + isList: fn, + /** + * Convert any object to list of nodes. + * @param {...Object} nodes + * @return {List} + */ + toList: fn, + /** + * Get length of node list or return 1 of single node. + * @param {Node} list + * @return {Number} + */ + getLength: fn, + /** + * Get node by index from list. + * @param {Node} node + * @param {Number} [index=0] + * @return {Object} + */ + getNodeAt: fn, + + // node methods + /** + * Is any object a node. + * @param {Object} node + * @return {Boolean} + */ + isNode: fn, + /** + * Convert any object to node, if list passed, should return first node + * available on the list. + * @param {Object} node + * @return {Node} + */ + toNode: fn, + /** + * Return name, key or value of the node. + * @param {Node} node + * @return {Name} + */ + getName: fn, + /** + * Check if list contains node with specified name. + * @param {Node} node + * @param {Name} [name] + * @return {Boolean} + */ + hasChild: fn, + /** + * Get list of children nodes. + * @param {Node} node + * @return {List} + */ + getChildren: fn, + /** + * Get children nodes with specified name. + * @param {Node} node + * @param {Name} name + * @return {List} + */ + getChildrenByName: fn, + /** + * Get child node by index. + * @param {List} node + * @param {Number} [index=0] + * @return {Node} + */ + getChildAt: fn, + /** + * Get parent node, if list, return parent node of first child. + * @param {Node} node + * @return {Node} + */ + getNodeParent: fn, + /** + * Get root node. + * @param {Node} node + * @return {Node} + */ + getNodeRoot: fn, +}; + +export default adapter; From ba471ea9beaf7b0a04ff69653df824e1533e4486 Mon Sep 17 00:00:00 2001 From: Oleg Galaburda Date: Mon, 20 Aug 2018 14:25:01 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 01318da..5d34f03 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # TreeWalker - -This is wireframe based on ES6 Proxies for making tree traversing APIs. -You may check ready to use implementation DOMWalker for better understanding. +[![Build Status](https://travis-ci.org/burdiuz/js-tree-walker.svg?branch=master)](https://travis-ci.org/burdiuz/js-tree-walker) [![Coverage Status](https://coveralls.io/repos/github/burdiuz/js-tree-walker/badge.svg?branch=master)](https://coveralls.io/github/burdiuz/js-tree-walker?branch=master) +This is wireframe based on ES6 Proxies for making tree traversing APIs. +You may check ready to use implementation DOMWalker for better understanding. Inspired by [E4X(ECMAScript for XML)](https://en.wikipedia.org/wiki/ECMAScript_for_XML) and its ActionScript 3 implementation. RIP. ## Installation @@ -25,22 +25,26 @@ but no methods can be called on them except * toString() -- to call `toString()` method on source node ## How it works -When you call `create()` function, you pass source data and adapter object. These two will be packed into [wrapper Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) which will be returned. -Proxy object will work with adapter(with its `getChildren()`, `getChildrenByName()` and other methods) to retrieve a list of child nodes with requested name. +When you call `create()` function, you pass source data and adapter object. These two will be packed into [wrapper Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). Proxy object works with adapter(with its `getChildren()`, `getChildrenByName()` and other methods) to retrieve a list of child nodes when requested by name or index. ``` const root = create(mySourceTreeData); const myDescendants = root.child.otherChild.descendant; +const myThirdChild = root.child[2]; +const jerries = myDescendants.jerry; ``` -With this code, on line 1, Proxy object for root node of the source tree is created. On line 2 three additional Proxies are created for `child`, `otherChild` and `descendant` node requests. When requesting a child node by name, it returns not one node but a list of all child nodes with same name, but when children requested off the list, Proxy will take first node from this list and return its children. So, if you have a list of 2 nodes where first does not have children and second has children +With this code, on line 1, Proxy object for root node of the source tree is created. On line 2 additional Proxies are created for `child`, `otherChild` and proxy for `descendant` nodes is stored in `myDescendants`. + +When requesting a child node by name, it returns not one node but a list of all child nodes with same name, but when children requested from the list(like `myDescendants.jerry`), Proxy will take first node from this list and return its children. +So, if you have a list of 2 nodes where first does not have children ``` const root = ; /** node structure - root - / \ - one one - / \ - two two + root + / \ +one[0] one[1] + / \ + two[0] two[1] */ const rootProxy = create(root, myAdapter); @@ -67,7 +71,7 @@ in this way you can request any descendants from any depth without worrying abou ## Usage - + To use TreeWalker, it should be supplied with two required components: 1. Source data - Tree data structure, that you want to work with 2. Adapter - Provides standardized API to work with source data @@ -80,9 +84,9 @@ import { create } from '@actualwave/tree-walker'; // root is a wrapped "source" node const root = create(source, myAdapter); ``` -After instantiating, you can access child nodes as properties and augmentations as methods. Its possible to have methods and nodes of same name, its because, when wrapper is created for child object, it stores parent node and name of child node. +After instantiating, you can access child nodes as properties and augmentations as methods. Its possible to have methods and nodes of same name, because, when wrapper is created for child object, it stores parent node and name of child node. - If request a property from wrapper, it will look for a node to return new wrapper with that node and name of the property: + If property is requested from wrapper, it will return new wrapper with that node and name of the property: ``` // stores { target: node, name: "parent" } const parent = node.parent; @@ -103,7 +107,7 @@ When requesting a child, wrapper uses `getChildren()` and `getChildrenByName()` const firstSibbling = sibblings[0]; ``` When requesting a child from wrapped list of nodes, wrapper will request children of first node from the list. - + > Adapter methods `toList()`, `getChildren()` and `getChildrenByName()` must always return list of nodes. In case of 0 nodes it should be empty list. Single node must have length 1 and, if requested, index 0 must return same node. If you wish to have specific node in a wrapper, you can request it by specifying index: @@ -177,13 +181,13 @@ Augmentations are simple functions which receive set of arguments and result wit addAugmentations({ children: (node, adapter, [childName], utils) => { let list; - + if (childName) { list = adapter.getChildrenByName(node, childName); } else { list = adapter.getChildren(node); } - + return utils.wrap(list, adapter); }, }}; From 009342ea024bf9aff7c6e41874bf2b717bc32c32 Mon Sep 17 00:00:00 2001 From: Oleg Galaburda Date: Mon, 20 Aug 2018 14:25:26 +0300 Subject: [PATCH 4/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d34f03..5b3b8d1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # TreeWalker -[![Build Status](https://travis-ci.org/burdiuz/js-tree-walker.svg?branch=master)](https://travis-ci.org/burdiuz/js-tree-walker) [![Coverage Status](https://coveralls.io/repos/github/burdiuz/js-tree-walker/badge.svg?branch=master)](https://coveralls.io/github/burdiuz/js-tree-walker?branch=master) +[![Build Status](https://travis-ci.org/burdiuz/js-tree-walker.svg?branch=master)](https://travis-ci.org/burdiuz/js-tree-walker) [![Coverage Status](https://coveralls.io/repos/github/burdiuz/js-tree-walker/badge.svg?branch=master)](https://coveralls.io/github/burdiuz/js-tree-walker?branch=master) + This is wireframe based on ES6 Proxies for making tree traversing APIs. You may check ready to use implementation DOMWalker for better understanding. Inspired by [E4X(ECMAScript for XML)](https://en.wikipedia.org/wiki/ECMAScript_for_XML) and its ActionScript 3 implementation. RIP. From f814ca85aad9b264b16e843ae363f0f6b422b7b5 Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Fri, 24 Aug 2018 01:18:14 +0300 Subject: [PATCH 5/5] add value() and string() to adapter, update docs --- dist/tree-walker.js | 4 +- dist/tree-walker.js.map | 2 +- dist/tree-walker.min.js | 2 +- dist/tree-walker.min.js.map | 2 +- example/onode-adapter.js | 2 + example/tree-walker.min.js | 2 +- example/tree-walker.min.js.map | 2 +- source/augmentations/__tests__/core.js | 51 ++++++++++++++++++++------ source/augmentations/core.js | 5 ++- stub-adapter.js | 12 ++++++ 10 files changed, 64 insertions(+), 20 deletions(-) diff --git a/dist/tree-walker.js b/dist/tree-walker.js index 29cbcc4..e219ad5 100644 --- a/dist/tree-walker.js +++ b/dist/tree-walker.js @@ -205,8 +205,8 @@ handlers = { apply }; -const toString = node => node.toString(); -const valueOf = node => node; +const toString = (node, adapter) => adapter.string ? adapter.string(node) : node.toString(); +const valueOf = (node, adapter) => adapter.value ? adapter.value(node) : node; var coreAugmentations = { toString, diff --git a/dist/tree-walker.js.map b/dist/tree-walker.js.map index 9d8dbfb..84f51bf 100644 --- a/dist/tree-walker.js.map +++ b/dist/tree-walker.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && hasOwn(augmentations, key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","hasOwn","isPrefixedKey","key","length","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","String","getValue","node","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","GET_RESTRICTED_NAMES","createWalkerNode","TreeWalker","wrap","isNode","isList","Proxy","get","getNodeAt","substr","result","has","hasChild","apply","thisArg","argumentsList","targetNode","toString","valueOf","children","list","getChildren","descendantsAll","descendants","getLength","index","child","push","descendantsByName","getName","childAt","getChildAt","root","getNodeRoot","parent","getNodeParent","at","first","filter","callback","listLength","wrappedNode","map","wrappedList","childResult","reduce","lastResult","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,cAAJ;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC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+B,cAAc1C,MAAMI,IAAN,CAAWiB,IAAX,EAAiBvD,OAAjB,CAApB;OACK,IAAI4D,QAAQ,CAAjB,EAAoBA,QAAQe,UAA5B,EAAwCf,SAAS,CAAjD,EAAoD;UAC5CC,QAAQ7D,QAAQ2C,SAAR,CAAkBY,IAAlB,EAAwBK,KAAxB,CAAd;iBACac,SACXO,UADW,EAEX/C,MAAMI,IAAN,CAAWuB,KAAX,EAAkB7D,OAAlB,CAFW,EAGX4D,KAHW,EAIXgB,WAJW,CAAb;;;SAQKK,UAAP;CAjBF;;AAoBA,WAAe;QAAA;IAAA;OAAA;QAAA;KAAA;;CAAf;;ACnFApD,iBAAiBqD,iBAAjB;;AAEA,MAAMC,SAAS,CAAChB,IAAD,EAAOnE,UAAUC,mBAAjB,KACbqC,KAAKtC,QAAQoF,YAAR,CAAqBjB,IAArB,CAAL,EAAiCnE,OAAjC,CADF;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"tree-walker.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) =>\r\n key && typeof key === 'string' && hasOwn(augmentations, key);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node, adapter) =>\n adapter.string ? adapter.string(node) : node.toString();\nconst valueOf = (node, adapter) =>\n adapter.value ? adapter.value(node) : node;\n\nexport default {\n toString,\n valueOf,\n};\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(\r\n descendants,\r\n descendantsAll(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","setDefaultAdapter","adapter","getDefaultAdapter","namePrefixes","isValidPrefix","prefix","hasOwn","isPrefixedKey","key","length","charAt","getPrefixHandler","setNamePrefix","handler","Error","isIntKey","parseInt","String","getValue","node","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","resetAugmentations","augs","addAugmentations","hasAugmentation","applyAugmentation","args","handlers","utils","GET_RESTRICTED_NAMES","createWalkerNode","TreeWalker","wrap","isNode","isList","Proxy","get","getNodeAt","substr","result","has","hasChild","apply","thisArg","argumentsList","targetNode","toString","string","valueOf","value","children","list","getChildren","descendantsAll","descendants","getLength","index","child","push","descendantsByName","getName","childAt","getChildAt","root","getNodeRoot","parent","getNodeParent","at","first","filter","callback","listLength","wrappedNode","map","wrappedList","childResult","reduce","lastResult","coreAugmentations","create","validateRoot"],"mappings":";;;;AAAA,IAAIA,cAAJ;;AAEA,MAAaC,oBAAqBC,OAAD,IAAa;mBAC3BA,OAAjB;CADK;AAGP,MAAaC,oBAAoB,MAAMH,cAAhC;;;;;;;;;;;ACLP;AAEA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;AAE9D,MAAM,MAAM,GAAG;EACb,CAAC,GAAG;EACJ,CAAC,MAAM,EAAE,QAAQ;EACjB,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ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,EAAwCf,SAAS,CAAjD,EAAoD;UAC5CC,QAAQ/D,QAAQ2C,SAAR,CAAkBc,IAAlB,EAAwBK,KAAxB,CAAd;iBACac,SACXO,UADW,EAEXjD,MAAMI,IAAN,CAAWyB,KAAX,EAAkB/D,OAAlB,CAFW,EAGX8D,KAHW,EAIXgB,WAJW,CAAb;;;SAQKK,UAAP;CAjBF;;AAoBA,WAAe;QAAA;IAAA;OAAA;QAAA;KAAA;;CAAf;;ACnFAtD,iBAAiBuD,iBAAjB;;AAEA,MAAMC,SAAS,CAAChB,IAAD,EAAOrE,UAAUC,mBAAjB,KACbqC,KAAKtC,QAAQsF,YAAR,CAAqBjB,IAArB,CAAL,EAAiCrE,OAAjC,CADF;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/tree-walker.min.js b/dist/tree-walker.min.js index 88dfafc..1078523 100644 --- a/dist/tree-walker.min.js +++ b/dist/tree-walker.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t;const r=()=>t;var o,n,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(o={exports:{}},o.exports),o.exports),s=(n=a)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;a.hasOwn;const i={},d=e=>"string"==typeof e&&s(i,e),l=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>"number"==typeof e&&e>>>0===e||`${parseInt(String(e),10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>t.toNode(u(e,t,r)),f=(e,t,r)=>t.toList(u(e,t,r));let h={};const w=e=>{h=Object.assign({},h,e)},y=e=>e&&"string"==typeof e&&s(h,e);let N,m;const A={constructor:!0,prototype:!0},b=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function o(){throw new Error("Should have been never called")}return o.node=e,o.childName=r,o.adapter=t,o})(e,t,r),N):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:f,wrap:b};N={get:({node:e,adapter:t,childName:r},o)=>{if("symbol"==typeof o||!0===A[o])return e[o];if(c(o))return b(t.getNodeAt(f(e,t,r),o),t);if(l(o))return p(o)(u(e,t,r),t,[o.substr(1)],m);const n=u(e,t,r);return b(n,t,o)},has:({node:e,adapter:t,childName:r},o)=>c(o)?!!t.getNodeAt(f(e,t,r),o):!!l(o)||t.hasChild(g(e,t,r),o),apply:({node:e,adapter:t,childName:r},o,n)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(d(r))return p(r)(e,t,[r.substr(1),...n],m);if(y(r))return((e,...t)=>h[e](...t))(r,e,t,n,m);const a=t.toNode(e);if("function"==typeof a[r])return a[r](...n);throw new Error(`"${r}" is not a callable object.`)}};var L={toString:e=>e.toString(),valueOf:e=>e};const v=(e,t,r,o)=>{const n=[],a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{const[n]=r,a=[],s=[],i=t.getChildren(e),d=t.getLength(i,t);for(let e=0;e{let n;return n=r?t.getChildrenByName(e,r):t.getChildren(e),o.wrap(n,t)},descendants:(e,t,r,o)=>{const[n]=r;return n?o.wrap(x(e,t,r,o),t):o.wrap(v(e,t,r,o),t)},childAt:(e,t,[r=0],o)=>o.wrap(t.getChildAt(e,r),t),root:(e,t,r,o)=>o.wrap(t.getNodeRoot(e),t),parent:(e,t,r,o)=>o.wrap(t.getNodeParent(e),t)};const P=(e,t,r,o)=>{const[n=0]=r;let a;if(t.isList(e)){const r=t.getNodeAt(e,n);r&&(a=r)}else n||(a=e);return o.wrap(a||[],t)};var C={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,o)=>P(e,t,[0],o),filter:(e,t,[r],o)=>{const n=t.toList(e),a=t.getLength(e),s=[],i=o.wrap(n,t);for(let e=0;e{const n=t.toList(e),a=t.getLength(n),s=[],i=o.wrap(n,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=o;const d=n.wrap(a,t);for(let e=0;eb(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=y,e.resetAugmentations=((e={})=>{h=e}),e.coreAugmentations=L,e.nodeAugmentations=O,e.listAugmentations=C,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=d,e.create=j,e.default=j,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t;const r=()=>t;var o,n,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(o={exports:{}},o.exports),o.exports),s=(n=a)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;a.hasOwn;const i={},l=e=>"string"==typeof e&&s(i,e),d=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>"number"==typeof e&&e>>>0===e||`${parseInt(String(e),10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>t.toNode(u(e,t,r)),f=(e,t,r)=>t.toList(u(e,t,r));let h={};const w=e=>{h=Object.assign({},h,e)},y=e=>e&&"string"==typeof e&&s(h,e);let N,m;const A={constructor:!0,prototype:!0},b=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function o(){throw new Error("Should have been never called")}return o.node=e,o.childName=r,o.adapter=t,o})(e,t,r),N):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:f,wrap:b};N={get:({node:e,adapter:t,childName:r},o)=>{if("symbol"==typeof o||!0===A[o])return e[o];if(c(o))return b(t.getNodeAt(f(e,t,r),o),t);if(d(o))return p(o)(u(e,t,r),t,[o.substr(1)],m);const n=u(e,t,r);return b(n,t,o)},has:({node:e,adapter:t,childName:r},o)=>c(o)?!!t.getNodeAt(f(e,t,r),o):!!d(o)||t.hasChild(g(e,t,r),o),apply:({node:e,adapter:t,childName:r},o,n)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(l(r))return p(r)(e,t,[r.substr(1),...n],m);if(y(r))return((e,...t)=>h[e](...t))(r,e,t,n,m);const a=t.toNode(e);if("function"==typeof a[r])return a[r](...n);throw new Error(`"${r}" is not a callable object.`)}};var v={toString:(e,t)=>t.string?t.string(e):e.toString(),valueOf:(e,t)=>t.value?t.value(e):e};const L=(e,t,r,o)=>{const n=[],a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{const[n]=r,a=[],s=[],i=t.getChildren(e),l=t.getLength(i,t);for(let e=0;e{let n;return n=r?t.getChildrenByName(e,r):t.getChildren(e),o.wrap(n,t)},descendants:(e,t,r,o)=>{const[n]=r;return n?o.wrap(x(e,t,r,o),t):o.wrap(L(e,t,r,o),t)},childAt:(e,t,[r=0],o)=>o.wrap(t.getChildAt(e,r),t),root:(e,t,r,o)=>o.wrap(t.getNodeRoot(e),t),parent:(e,t,r,o)=>o.wrap(t.getNodeParent(e),t)};const P=(e,t,r,o)=>{const[n=0]=r;let a;if(t.isList(e)){const r=t.getNodeAt(e,n);r&&(a=r)}else n||(a=e);return o.wrap(a||[],t)};var C={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,o)=>P(e,t,[0],o),filter:(e,t,[r],o)=>{const n=t.toList(e),a=t.getLength(e),s=[],i=o.wrap(n,t);for(let e=0;e{const n=t.toList(e),a=t.getLength(n),s=[],i=o.wrap(n,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=o;const l=n.wrap(a,t);for(let e=0;eb(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=y,e.resetAugmentations=((e={})=>{h=e}),e.coreAugmentations=v,e.nodeAugmentations=O,e.listAugmentations=C,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=l,e.create=j,e.default=j,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=tree-walker.min.js.map diff --git a/dist/tree-walker.min.js.map b/dist/tree-walker.min.js.map index 6c8ea90..5f999bb 100644 --- a/dist/tree-walker.min.js.map +++ b/dist/tree-walker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && hasOwn(augmentations, key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","isPrefixedKey","key","length","charAt","getPrefixHandler","isIntKey","parseInt","String","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","GET_RESTRICTED_NAMES","wrap","isNode","isList","Proxy","TreeWalker","Error","createWalkerNode","getNodeAt","handler","substr","result","hasChild","thisArg","argumentsList","args","applyAugmentation","targetNode","toString","descendantsAll","children","descendants","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrappedList","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,QAKSC,EAAoB,IAAMD,2BCHvCE,OAAOC,eAAeC,EAAS,cAAgBC,OAAO,IAEtD,MAAMC,EAAS,CACZC,GACD,CAACC,EAAQC,IACTC,QAAQF,GAAUD,EAAII,KAAKH,EAAQC,IAHtB,CAIbP,OAAOU,UAAUC,gBAEnBT,SAAiBE,EACjBF,UAAkBE,sICTlB,MAAMQ,KAEOC,EAAiBC,GACV,iBAAXA,GAAuBV,EAAOQ,EAAcE,GAExCC,EAAiBC,GAC5BA,GACe,iBAARA,GACPA,EAAIC,OAAS,GACbb,EAAOQ,EAAcI,EAAIE,UAEdC,EAAoBH,GAAQJ,EAAaI,EAAIE,UCb7CE,EAAYJ,GAEP,iBAARA,GAAoBA,IAAQ,IAAMA,MAEvCK,SAASC,OAAON,GAAM,QAAUA,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OAAOR,GACtBmD,EAAalD,EAAQsC,UAAUF,GAC/BX,KAEA2B,EAAcvC,EAAME,KAAKqB,EAAMpC,OAChC,IAAIuC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQxC,EAAQsB,UAAUc,EAAMG,GAChCc,EAAcJ,EAClBpC,EAAME,KAAKyB,EAAOxC,GAClBuC,EACAa,KAEKX,KAAKY,UAKP5B,UAGM,CAAC1B,EAAMC,GAAUiD,EAAUxB,GAASZ,WAE3CuB,EAAOpC,EAAQO,OAAOR,GACtBmD,EAAalD,EAAQsC,UAAUvC,OACjCuD,EAAa7B,QAEX0B,EAActC,EAAME,KAAKqB,EAAMpC,OAChC,IAAIuC,EAAQ,EAAGA,EAAQW,EAAYX,GAAS,EAAG,OAC5CC,EAAQxC,EAAQsB,UAAUc,EAAMG,KACzBU,EACXK,EACAzC,EAAME,KAAKyB,EAAOxC,GAClBuC,EACAY,UAIGG,IChFT7C,EAAiB8C,SAEXC,EAAS,CAACC,EAAMzD,EAAU1B,MAC9ByC,EAAKf,EAAQ0D,aAAaD,GAAOzD,uBTTDA,CAAAA,MACfA,wFICe,EAACU,UACjBA,sFFUW,EAACrB,EAAQkC,QACd,iBAAXlC,GAAyC,IAAlBA,EAAOG,aACjC,IAAI4B,MAAM,+CAGL/B,GAAUkC"} \ No newline at end of file +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) =>\r\n key && typeof key === 'string' && hasOwn(augmentations, key);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node, adapter) =>\n adapter.string ? adapter.string(node) : node.toString();\nconst valueOf = (node, adapter) =>\n adapter.value ? adapter.value(node) : node;\n\nexport default {\n toString,\n valueOf,\n};\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(\r\n descendants,\r\n descendantsAll(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","isPrefixedKey","key","length","charAt","getPrefixHandler","isIntKey","parseInt","String","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","GET_RESTRICTED_NAMES","wrap","isNode","isList","Proxy","TreeWalker","Error","createWalkerNode","getNodeAt","handler","substr","result","hasChild","thisArg","argumentsList","args","applyAugmentation","targetNode","string","toString","descendantsAll","children","descendants","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrappedList","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,QAKSC,EAAoB,IAAMD,2BCHvCE,OAAOC,eAAeC,EAAS,cAAgBC,OAAO,IAEtD,MAAMC,EAAS,CACZC,GACD,CAACC,EAAQC,IACTC,QAAQF,GAAUD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AXlC,GAAyC,IAAlBA,EAAOG,aACjC,IAAI4B,MAAM,+CAGL/B,GAAUkC"} \ No newline at end of file diff --git a/example/onode-adapter.js b/example/onode-adapter.js index 7efb435..d4777c6 100644 --- a/example/onode-adapter.js +++ b/example/onode-adapter.js @@ -24,6 +24,8 @@ getChildAt: (item, index = 0) => adapter.toNode(item).children[index], getNodeParent: (item) => adapter.toNode(item).parent, getNodeRoot: (item) => adapter.toNode(item).root, + valueOf: (item) => item.valueOf(), + toString: (item) => item.toString(), }; target.ONodeAdapter = adapter; diff --git a/example/tree-walker.min.js b/example/tree-walker.min.js index e466584..88dfafc 100644 --- a/example/tree-walker.min.js +++ b/example/tree-walker.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t=null;const r=()=>t;var n,o,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(n={exports:{}},n.exports),n.exports),s=(o=a)&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o;a.hasOwn;const i={},l=e=>"string"==typeof e&&1===e.length&&s(i,e),d=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>`${parseInt(e,10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>{const n=u(e,t,r);return t.isList(n)?t.getNodeAt(e):n},h=(e,t,r)=>t.toList(u(e,t,r));let f={};const w=(e={})=>{f=Object.assign({},f,e)},N=e=>e&&"string"==typeof e&&f.hasOwnProperty(e);let y,m;const A=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function n(){throw new Error("Should have been never called")}return n.node=e,n.childName=r,n.adapter=t,n})(e,t,r),y):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:h,wrap:A};y={get:({node:e,adapter:t,childName:r},n)=>{if(c(n))return A(t.getNodeAt(h(e,t,r),n),t);if(d(n))return p(n)(u(e,t,r),t,[n.substr(1)],m);return A(u(e,t,r),t,n)},has:({node:e,adapter:t,childName:r},n)=>c(n)?!!t.getNodeAt(h(e,t,r),n):!!d(n)||t.hasChild(g(),n),apply:({node:e,adapter:t,childName:r},n,o)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(l(r))return p(r)(e,t,o,m);if(N(r))return((e,...t)=>f[e](...t))(r,e,t,o,m);throw new Error(`"${r}" is not a callable object.`)}};var L={toString:e=>e.toString(),valueOf:e=>e,[Symbol.toPrimitive]:e=>e};const v=(e,t,r,n)=>{const o=[],a=t.getChildren(e),s=t.getLength(a,t);for(let e=0;e{const[o]=r,a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{let o;return o=r?t.getChildrenByName(e,r):t.getChildren(e),n.wrap(o,t)},descendants:(e,t,r,n)=>{const[o]=r;return o?n.wrap(b(e,t,r,n),t):n.wrap(v(e,t,r,n),t)},childAt:(e,t,[r=0],n)=>n.wrap(t.getChildAt(e,r),t),root:(e,t,r,n)=>n.wrap(t.getNodeRoot(e),t),parent:(e,t,r,n)=>n.wrap(t.getNodeParent(e),t)};const P=(e,t,r,n)=>{const[o]=r;let a=[];if(t.isList(e)){const r=t.getNodeAt(e,o);r&&(a=r)}return n.wrap(a,t)};var x={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,n)=>P(e,t,[0],n),filter:(e,t,[r],n)=>{const o=t.toList(e),a=t.getLength(e),s=[],i=n.wrap(o,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(a),i=[];let l=!0;const d=o.wrap(a,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=n;const l=o.wrap(a,t);for(let e=0;eA(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=N,e.resetAugmentations=((e={})=>{f=e}),e.coreAugmentations=L,e.nodeAugmentations=O,e.listAugmentations=x,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=l,e.create=C,e.default=C,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.TreeWalker={})}(this,function(e){"use strict";let t;const r=()=>t;var o,n,a=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(e=>(t,r)=>Boolean(t&&e.call(t,r)))(Object.prototype.hasOwnProperty);t.hasOwn=r,t.default=r}(o={exports:{}},o.exports),o.exports),s=(n=a)&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;a.hasOwn;const i={},d=e=>"string"==typeof e&&s(i,e),l=e=>e&&"string"==typeof e&&e.length>1&&s(i,e.charAt()),p=e=>i[e.charAt()],c=e=>"number"==typeof e&&e>>>0===e||`${parseInt(String(e),10)}`===e,u=(e,t,r)=>void 0!==r?t.getChildrenByName(e,r):e,g=(e,t,r)=>t.toNode(u(e,t,r)),f=(e,t,r)=>t.toList(u(e,t,r));let h={};const w=e=>{h=Object.assign({},h,e)},y=e=>e&&"string"==typeof e&&s(h,e);let N,m;const A={constructor:!0,prototype:!0},b=(e,t,r)=>t.isNode(e)||t.isList(e)?new Proxy(((e,t,r)=>{function o(){throw new Error("Should have been never called")}return o.node=e,o.childName=r,o.adapter=t,o})(e,t,r),N):e;m={isIntKey:c,getValue:u,getSingleNode:g,getNodeList:f,wrap:b};N={get:({node:e,adapter:t,childName:r},o)=>{if("symbol"==typeof o||!0===A[o])return e[o];if(c(o))return b(t.getNodeAt(f(e,t,r),o),t);if(l(o))return p(o)(u(e,t,r),t,[o.substr(1)],m);const n=u(e,t,r);return b(n,t,o)},has:({node:e,adapter:t,childName:r},o)=>c(o)?!!t.getNodeAt(f(e,t,r),o):!!l(o)||t.hasChild(g(e,t,r),o),apply:({node:e,adapter:t,childName:r},o,n)=>{if(void 0===r)throw new Error("Cannot call on TreeWalker Node");if(d(r))return p(r)(e,t,[r.substr(1),...n],m);if(y(r))return((e,...t)=>h[e](...t))(r,e,t,n,m);const a=t.toNode(e);if("function"==typeof a[r])return a[r](...n);throw new Error(`"${r}" is not a callable object.`)}};var L={toString:e=>e.toString(),valueOf:e=>e};const v=(e,t,r,o)=>{const n=[],a=[],s=t.getChildren(e),i=t.getLength(s,t);for(let e=0;e{const[n]=r,a=[],s=[],i=t.getChildren(e),d=t.getLength(i,t);for(let e=0;e{let n;return n=r?t.getChildrenByName(e,r):t.getChildren(e),o.wrap(n,t)},descendants:(e,t,r,o)=>{const[n]=r;return n?o.wrap(x(e,t,r,o),t):o.wrap(v(e,t,r,o),t)},childAt:(e,t,[r=0],o)=>o.wrap(t.getChildAt(e,r),t),root:(e,t,r,o)=>o.wrap(t.getNodeRoot(e),t),parent:(e,t,r,o)=>o.wrap(t.getNodeParent(e),t)};const P=(e,t,r,o)=>{const[n=0]=r;let a;if(t.isList(e)){const r=t.getNodeAt(e,n);r&&(a=r)}else n||(a=e);return o.wrap(a||[],t)};var C={length:(e,t)=>t.isList(e)?t.getLength(e):t.isNode(e)?1:0,at:P,first:(e,t,r,o)=>P(e,t,[0],o),filter:(e,t,[r],o)=>{const n=t.toList(e),a=t.getLength(e),s=[],i=o.wrap(n,t);for(let e=0;e{const n=t.toList(e),a=t.getLength(n),s=[],i=o.wrap(n,t);for(let e=0;e{const a=t.toList(e),s=t.getLength(e);let i=o;const d=n.wrap(a,t);for(let e=0;eb(t.validateRoot(e),t);e.setDefaultAdapter=(e=>{t=e}),e.getDefaultAdapter=r,e.addAugmentations=w,e.hasAugmentation=y,e.resetAugmentations=((e={})=>{h=e}),e.coreAugmentations=L,e.nodeAugmentations=O,e.listAugmentations=C,e.setNamePrefix=((e,t)=>{if("string"!=typeof e||1!==e.length)throw new Error("Name Prefix must be one character string.");i[e]=t}),e.isValidPrefix=d,e.create=j,e.default=j,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=tree-walker.min.js.map diff --git a/example/tree-walker.min.js.map b/example/tree-walker.min.js.map index 5f05788..6c8ea90 100644 --- a/example/tree-walker.min.js.map +++ b/example/tree-walker.min.js.map @@ -1 +1 @@ -{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter = null;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' &&\r\n prefix.length === 1 &&\r\n hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) => (`${parseInt(key, 10)}` === key);\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) => {\r\n const value = getValue(node, adapter, childName);\r\n\r\n if (adapter.isList(value)) {\r\n return adapter.getNodeAt(node);\r\n }\r\n\r\n return value;\r\n};\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) => {\r\n return adapter.toList(getValue(node, adapter, childName));\r\n};\r\n","let augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs = {}) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && augmentations.hasOwnProperty(key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n} from './utils';\r\n\r\nimport {\r\n isPrefixedKey,\r\n isValidPrefix,\r\n getPrefixHandler,\r\n} from './prefixes';\r\n\r\nimport {\r\n hasAugmentation,\r\n applyAugmentation,\r\n} from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (isIntKey(key)) {\r\n return wrap(adapter.getNodeAt(getNodeList(node, adapter, childName), key), adapter);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(getValue(node, adapter, childName), adapter, [key.substr(1)], utils);\r\n }\r\n\r\n // return wrap with node and childName\r\n return wrap(getValue(node, adapter, childName), adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(node, adapter, argumentsList, utils);\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n [Symbol.toPrimitive]: (node) => node,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n result.push(child);\r\n result.push.apply(result, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const result = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n result.push(child);\r\n }\r\n result.push.apply(result, descendantsByName(child, adapter, args, utils));\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index] = args;\r\n // return empty array, which will create empty wrapper for chained calls,\r\n // this will make next calls errorless.\r\n let result = [];\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback, wrapNodes = true], utils) => {\r\n // apply map on element collection\r\n // if wrapNodes in FALSE, will generate normal Array with RAW results in it\r\n // if wrapNodes in TRUE and all elements of resulting list are nodes, will\r\n // generate wrapped list and put all result into it\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n let areNodes = true;\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode\r\n );\r\n areNodes = areNodes && adapter.isNode(childResult);\r\n result.push(childResult);\r\n }\r\n\r\n return wrapNodes && areNodes ? utils.wrap(result, adapter) : result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n result,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","length","isPrefixedKey","key","charAt","getPrefixHandler","isIntKey","parseInt","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","isList","getNodeAt","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","wrap","isNode","Proxy","TreeWalker","Error","createWalkerNode","handler","substr","hasChild","thisArg","argumentsList","args","applyAugmentation","toString","Symbol","toPrimitive","descendantsAll","result","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrapNodes","areNodes","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAA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AGL7B,GAAU+B"} \ No newline at end of file +{"version":3,"file":"tree-walker.min.js","sources":["../source/default-adapter.js","../node_modules/@actualwave/has-own/has-own.js","../source/prefixes.js","../source/utils.js","../source/augmentations/index.js","../source/wrapper.js","../source/augmentations/core.js","../source/augmentations/node.js","../source/augmentations/list.js","../source/index.js"],"sourcesContent":["let defaultAdapter;\r\n\r\nexport const setDefaultAdapter = (adapter) => {\r\n defaultAdapter = adapter;\r\n};\r\nexport const getDefaultAdapter = () => defaultAdapter;\r\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nconst hasOwn = (\n (has) =>\n (target, property) =>\n Boolean(target && has.call(target, property))\n)(Object.prototype.hasOwnProperty);\n\nexports.hasOwn = hasOwn;\nexports.default = hasOwn;","import hasOwn from '@actualwave/has-own';\r\n\r\nconst namePrefixes = {};\r\n\r\nexport const isValidPrefix = (prefix) =>\r\n typeof prefix === 'string' && hasOwn(namePrefixes, prefix);\r\n\r\nexport const isPrefixedKey = (key) =>\r\n key &&\r\n typeof key === 'string' &&\r\n key.length > 1 &&\r\n hasOwn(namePrefixes, key.charAt());\r\n\r\nexport const getPrefixHandler = (key) => namePrefixes[key.charAt()];\r\n\r\nexport const setNamePrefix = (prefix, handler) => {\r\n if (typeof prefix !== 'string' || prefix.length !== 1) {\r\n throw new Error('Name Prefix must be one character string.');\r\n }\r\n\r\n namePrefixes[prefix] = handler;\r\n};\r\n","export const isIntKey = (key) =>\r\n // it is unsigned int\r\n (typeof key === 'number' && key >>> 0 === key) ||\r\n // it is integer number string\r\n `${parseInt(String(key), 10)}` === key;\r\n\r\nexport const getValue = (node, adapter, childName = undefined) => {\r\n if (childName !== undefined) {\r\n return adapter.getChildrenByName(node, childName);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport const getSingleNode = (node, adapter, childName = undefined) =>\r\n adapter.toNode(getValue(node, adapter, childName));\r\n\r\nexport const getNodeList = (node, adapter, childName = undefined) =>\r\n adapter.toList(getValue(node, adapter, childName));\r\n","import hasOwn from '@actualwave/has-own';\r\n\r\nlet augmentations = {};\r\n\r\nexport const resetAugmentations = (augs = {}) => {\r\n augmentations = augs;\r\n};\r\n\r\nexport const addAugmentations = (augs) => {\r\n augmentations = {\r\n ...augmentations,\r\n ...augs,\r\n };\r\n};\r\n\r\nexport const hasAugmentation = (key) => (\r\n key\r\n && typeof key === 'string'\r\n && hasOwn(augmentations, key)\r\n);\r\n\r\nexport const getAugmentation = (key) => augmentations[key];\r\n\r\nexport const applyAugmentation = (key, ...args) => augmentations[key](...args);\r\n","import { isIntKey, getValue, getSingleNode, getNodeList } from './utils';\r\n\r\nimport { isPrefixedKey, isValidPrefix, getPrefixHandler } from './prefixes';\r\n\r\nimport { hasAugmentation, applyAugmentation } from './augmentations';\r\n\r\nlet handlers;\r\nlet utils;\r\n\r\nconst GET_RESTRICTED_NAMES = {\r\n constructor: true,\r\n prototype: true,\r\n /*\r\n call: true,\r\n apply: true,\r\n */\r\n};\r\n\r\nconst createWalkerNode = (node, adapter, childName = undefined) => {\r\n function TreeWalker() {\r\n throw new Error('Should have been never called');\r\n }\r\n\r\n // can be single Node and NodeList with length >= 0\r\n // should it be always NodeList?\r\n TreeWalker.node = node;\r\n // childName always String/Symbol, Number's are being handled in proxy get wrapper\r\n // INFO \"name\" is RO property of Function object\r\n TreeWalker.childName = childName;\r\n TreeWalker.adapter = adapter;\r\n return TreeWalker;\r\n};\r\n\r\nconst wrap = (node, adapter, childName = undefined) => {\r\n if (!adapter.isNode(node) && !adapter.isList(node)) {\r\n return node;\r\n }\r\n\r\n return new Proxy(createWalkerNode(node, adapter, childName), handlers);\r\n};\r\n\r\n// eslint-disable-next-line\r\nutils = {\r\n isIntKey,\r\n getValue,\r\n getSingleNode,\r\n getNodeList,\r\n wrap,\r\n};\r\n\r\nconst get = ({ node, adapter, childName }, key) => {\r\n /*\r\n if symbol, return node property\r\n if string childName used\r\n if starts with $, return attribute value\r\n else return wrapper with current single node and property childName\r\n if numeric index used, use node as parent and childName is undefined\r\n */\r\n if (typeof key === 'symbol' || GET_RESTRICTED_NAMES[key] === true) {\r\n return node[key];\r\n }\r\n\r\n if (isIntKey(key)) {\r\n return wrap(\r\n adapter.getNodeAt(getNodeList(node, adapter, childName), key),\r\n adapter,\r\n );\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n const handler = getPrefixHandler(key);\r\n return handler(\r\n getValue(node, adapter, childName),\r\n adapter,\r\n [key.substr(1)],\r\n utils,\r\n );\r\n }\r\n\r\n const result = getValue(node, adapter, childName);\r\n\r\n // return wrap with node and childName\r\n return wrap(result, adapter, key);\r\n};\r\n\r\nconst has = ({ node, adapter, childName }, key) => {\r\n if (isIntKey(key)) {\r\n return !!adapter.getNodeAt(getNodeList(node, adapter, childName), key);\r\n }\r\n\r\n if (isPrefixedKey(key)) {\r\n // return adapter.hasAttribute(getSingleNode(node, adapter, childName), key.substr(1));\r\n // don't know how to implement this, calling same handler as in GET seems overkill\r\n // FIXME let user to register GET and optional SET/HAS handlers\r\n return true;\r\n }\r\n\r\n return adapter.hasChild(getSingleNode(node, adapter, childName), key);\r\n};\r\n\r\nconst apply = ({ node, adapter, childName }, thisArg, argumentsList) => {\r\n if (childName === undefined) {\r\n throw new Error('Cannot call on TreeWalker Node');\r\n }\r\n\r\n // this works only of childName === prefix, one char string\r\n // otherwise it should be passed into arguments\r\n\r\n // FIXME if GET always return result of prefixed property, means there are\r\n // no cases when we get a wrapped node to APPLY trap with prefixed name.\r\n if (isValidPrefix(childName)) {\r\n const handler = getPrefixHandler(childName);\r\n return handler(\r\n node,\r\n adapter,\r\n [childName.substr(1), ...argumentsList],\r\n utils,\r\n );\r\n }\r\n\r\n if (hasAugmentation(childName)) {\r\n // INFO cannot use target because it contains method's childName, not Node childName\r\n // call the function with saving context, so other augmentations are accessible via \"this\"\r\n return applyAugmentation(childName, node, adapter, argumentsList, utils);\r\n }\r\n\r\n // in case of normal function being called out of the tree node\r\n const targetNode = adapter.toNode(node);\r\n if (typeof targetNode[childName] === 'function') {\r\n return targetNode[childName](...argumentsList);\r\n }\r\n\r\n // FIXME might throw only in dev mode(needs implementation)\r\n throw new Error(`\"${childName}\" is not a callable object.`);\r\n};\r\n\r\nhandlers = {\r\n get,\r\n has,\r\n apply,\r\n};\r\n\r\nexport default wrap;\r\n","const toString = (node) => node.toString();\r\nconst valueOf = (node) => node;\r\n\r\nexport default {\r\n toString,\r\n valueOf,\r\n};\r\n","/* eslint-disable prefer-spread */\r\nconst children = (node, adapter, [childName], utils) => {\r\n let list;\r\n\r\n if (childName) {\r\n list = adapter.getChildrenByName(node, childName);\r\n } else {\r\n list = adapter.getChildren(node);\r\n }\r\n\r\n return utils.wrap(list, adapter);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsAll = (node, adapter, args, utils) => {\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n children.push(child);\r\n descendants.push.apply(descendants, descendantsAll(child, adapter, args, utils));\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst descendantsByName = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n const children = []; // eslint-disable-line no-shadow\r\n const descendants = [];\r\n const list = adapter.getChildren(node);\r\n const length = adapter.getLength(list, adapter);\r\n\r\n for (let index = 0; index < length; index += 1) {\r\n const child = list[index];\r\n if (adapter.getName(child) === childName) {\r\n children.push(child);\r\n }\r\n\r\n descendants.push.apply(\r\n descendants,\r\n descendantsByName(child, adapter, args, utils),\r\n );\r\n }\r\n\r\n /* children go first, then other descendants */\r\n return [...children, ...descendants];\r\n};\r\n\r\nconst descendants = (node, adapter, args, utils) => {\r\n const [childName] = args;\r\n\r\n if (childName) {\r\n return utils.wrap(descendantsByName(node, adapter, args, utils), adapter);\r\n }\r\n\r\n return utils.wrap(descendantsAll(node, adapter, args, utils), adapter);\r\n};\r\n\r\nconst childAt = (node, adapter, [index = 0], utils) =>\r\n utils.wrap(adapter.getChildAt(node, index), adapter);\r\n\r\nconst root = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeRoot(node), adapter);\r\n\r\nconst parent = (node, adapter, args, utils) =>\r\n utils.wrap(adapter.getNodeParent(node), adapter);\r\n\r\nexport default {\r\n children,\r\n descendants,\r\n childAt,\r\n root,\r\n parent,\r\n};\r\n","const length = (node, adapter) => {\r\n if (adapter.isList(node)) {\r\n return adapter.getLength(node);\r\n } else if (adapter.isNode(node)) {\r\n return 1;\r\n }\r\n\r\n return 0;\r\n};\r\n\r\nconst at = (node, adapter, args, utils) => {\r\n const [index = 0] = args;\r\n let result;\r\n\r\n if (adapter.isList(node)) {\r\n const child = adapter.getNodeAt(node, index);\r\n\r\n if (child) {\r\n result = child;\r\n }\r\n } else if (!index) {\r\n result = node;\r\n }\r\n\r\n // if nothing found return empty array, which will create empty wrapper for\r\n // chained calls, this will make next calls errorless.\r\n return utils.wrap(result || [], adapter);\r\n};\r\n\r\nconst first = (node, adapter, args, utils) => at(node, adapter, [0], utils);\r\n\r\nconst filter = (node, adapter, [callback], utils) => {\r\n // apply filter on element collection\r\n // always return wrapped list\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n const result = [];\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n if (callback(utils.wrap(child, adapter), index, wrappedNode)) {\r\n result.push(child);\r\n }\r\n }\r\n\r\n return utils.wrap(result, adapter);\r\n};\r\n\r\nconst map = (node, adapter, [callback], utils) => {\r\n // apply map on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(list);\r\n const result = [];\r\n\r\n const wrappedList = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n const childResult = callback(\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedList,\r\n );\r\n result.push(childResult);\r\n }\r\n\r\n // returns normal array because we don't know if all items in result are nodes\r\n // and if they are, they will be likely already wrapped\r\n return result;\r\n};\r\n\r\nconst reduce = (node, adapter, [callback, result], utils) => {\r\n // apply reduce on element collection\r\n const list = adapter.toList(node);\r\n const listLength = adapter.getLength(node);\r\n let lastResult = result;\r\n\r\n const wrappedNode = utils.wrap(list, adapter);\r\n for (let index = 0; index < listLength; index += 1) {\r\n const child = adapter.getNodeAt(list, index);\r\n lastResult = callback(\r\n lastResult,\r\n utils.wrap(child, adapter),\r\n index,\r\n wrappedNode,\r\n );\r\n }\r\n\r\n return lastResult;\r\n};\r\n\r\nexport default {\r\n length,\r\n at,\r\n first,\r\n filter,\r\n map,\r\n reduce,\r\n};\r\n","import { setDefaultAdapter, getDefaultAdapter } from './default-adapter';\nimport { setNamePrefix, isValidPrefix } from './prefixes';\nimport wrap from './wrapper';\nimport { addAugmentations, resetAugmentations, hasAugmentation } from './augmentations';\nimport coreAugmentations from './augmentations/core';\nimport nodeAugmentations from './augmentations/node';\nimport listAugmentations from './augmentations/list';\n\naddAugmentations(coreAugmentations);\n\nconst create = (root, adapter = getDefaultAdapter()) =>\n wrap(adapter.validateRoot(root), adapter);\n\nexport {\n setDefaultAdapter,\n getDefaultAdapter,\n\n addAugmentations,\n hasAugmentation,\n resetAugmentations,\n coreAugmentations,\n nodeAugmentations,\n listAugmentations,\n\n setNamePrefix,\n isValidPrefix,\n\n create,\n};\n\nexport default create;\n"],"names":["defaultAdapter","getDefaultAdapter","Object","defineProperty","exports","value","hasOwn","has","target","property","Boolean","call","prototype","hasOwnProperty","namePrefixes","isValidPrefix","prefix","isPrefixedKey","key","length","charAt","getPrefixHandler","isIntKey","parseInt","String","getValue","node","adapter","childName","undefined","getChildrenByName","getSingleNode","toNode","getNodeList","toList","augmentations","addAugmentations","augs","hasAugmentation","handlers","utils","GET_RESTRICTED_NAMES","wrap","isNode","isList","Proxy","TreeWalker","Error","createWalkerNode","getNodeAt","handler","substr","result","hasChild","thisArg","argumentsList","args","applyAugmentation","targetNode","toString","descendantsAll","children","descendants","list","getChildren","getLength","index","child","push","apply","descendantsByName","getName","getChildAt","getNodeRoot","getNodeParent","at","callback","listLength","wrappedNode","wrappedList","childResult","lastResult","coreAugmentations","create","root","validateRoot"],"mappings":"6LAAA,IAAIA,QAKSC,EAAoB,IAAMD,2BCHvCE,OAAOC,eAAeC,EAAS,cAAgBC,OAAO,IAEtD,MAAMC,EAAS,CACZC,GACD,CAACC,EAAQC,IACTC,QAAQF,GAAUD,EAAII,KAAKH,EAAQC,IAHtB,CAIbP,OAAOU,UAAUC,gBAEnBT,SAAiBE,EACjBF,UAAkBE,sICTlB,MAAMQ,KAEOC,EAAiBC,GACV,iBAAXA,GAAuBV,EAAOQ,EAAcE,GAExCC,EAAiBC,GAC5BA,GACe,iBAARA,GACPA,EAAIC,OAAS,GACbb,EAAOQ,EAAcI,EAAIE,UAEdC,EAAoBH,GAAQJ,EAAaI,EAAIE,UCb7CE,EAAYJ,GAEP,iBAARA,GAAoBA,IAAQ,IAAMA,MAEvCK,SAASC,OAAON,GAAM,QAAUA,EAExBO,EAAW,CAACC,EAAMC,EAASC,SACpBC,IAAdD,EACKD,EAAQG,kBAAkBJ,EAAME,GAGlCF,EAGIK,EAAgB,CAACL,EAAMC,EAASC,IAC3CD,EAAQK,OAAOP,EAASC,EAAMC,EAASC,IAE5BK,EAAc,CAACP,EAAMC,EAASC,IACzCD,EAAQO,OAAOT,EAASC,EAAMC,EAASC,IChBzC,IAAIO,WAMSC,EAAoBC,uBAE1BF,EACAE,IAIMC,EAAmBpB,GAC9BA,GACkB,iBAARA,GACPZ,EAAO6B,EAAejB,OCZvBqB,EACAC,EAEJ,MAAMC,gBACS,aACF,GAsBPC,EAAO,CAAChB,EAAMC,EAASC,IACtBD,EAAQgB,OAAOjB,IAAUC,EAAQiB,OAAOlB,GAItC,IAAImB,MApBY,EAAC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5CC,EAAQxC,EAAQsB,UAAUc,EAAMG,KACzBU,EACXK,EACAzC,EAAME,KAAKyB,EAAOxC,GAClBuC,EACAY,UAIGG,IChFT7C,EAAiB8C,SAEXC,EAAS,CAACC,EAAMzD,EAAU1B,MAC9ByC,EAAKf,EAAQ0D,aAAaD,GAAOzD,uBTTDA,CAAAA,MACfA,wFICe,EAACU,UACjBA,sFFUW,EAACrB,EAAQkC,QACd,iBAAXlC,GAAyC,IAAlBA,EAAOG,aACjC,IAAI4B,MAAM,+CAGL/B,GAAUkC"} \ No newline at end of file diff --git a/source/augmentations/__tests__/core.js b/source/augmentations/__tests__/core.js index cdeb165..2561566 100644 --- a/source/augmentations/__tests__/core.js +++ b/source/augmentations/__tests__/core.js @@ -5,21 +5,50 @@ describe('Core augmentations', () => { let source; let root; - beforeEach(() => { - source = getSourceTree(); - root = create(source, ONodeAdapter); - }); + describe('When adapter has methods', () => { + beforeEach(() => { + source = getSourceTree(); + root = create(source, { + ...ONodeAdapter, + string: () => 'ONode String', + value: () => 'ONode Value', + }); + }); + + describe('toString()', () => { + it('should return unwrapped source node', () => { + expect(root.first.toString()).toBe('ONode String'); + }); + }); - describe('toString()', () => { - it('should return unwrapped source node', () => { - expect(root.first.toString()).toBe('[ONode name="first" {"level":1}]'); + describe('valueOf()', () => { + it('should return unwrapped source node', () => { + expect(root.first.valueOf()).toBe('ONode Value'); + }); }); }); - describe('valueOf()', () => { - it('should return unwrapped source node', () => { - expect(root.first.valueOf()[0]).toBeInstanceOf(ONode); - expect(root.first.valueOf()[0].name).toBe('first'); + describe('When adapter does not have methods', () => { + beforeEach(() => { + source = getSourceTree(); + root = create(source, { + ...ONodeAdapter, + string: undefined, + value: undefined, + }); + }); + + describe('toString()', () => { + it('should return unwrapped source node', () => { + expect(root.first.toString()).toBe('[ONode name="first" {"level":1}]'); + }); + }); + + describe('valueOf()', () => { + it('should return unwrapped source node', () => { + expect(root.first.valueOf()[0]).toBeInstanceOf(ONode); + expect(root.first.valueOf()[0].name).toBe('first'); + }); }); }); }); diff --git a/source/augmentations/core.js b/source/augmentations/core.js index d03636f..d52ecae 100644 --- a/source/augmentations/core.js +++ b/source/augmentations/core.js @@ -1,5 +1,6 @@ -const toString = (node) => node.toString(); -const valueOf = (node) => node; +const toString = (node, adapter) => + adapter.string ? adapter.string(node) : node.toString(); +const valueOf = (node, adapter) => (adapter.value ? adapter.value(node) : node); export default { toString, diff --git a/stub-adapter.js b/stub-adapter.js index 09e5b0a..8dcdaf0 100644 --- a/stub-adapter.js +++ b/stub-adapter.js @@ -114,6 +114,18 @@ const adapter = { * @return {Node} */ getNodeRoot: fn, + /** + * Get root node. + * @param {Node|Node[]} node + * @return {Object} + */ + value: (item) => item, + /** + * Get root node. + * @param {Node|Node[]} node + * @return {String} + */ + string: (item) => item.toString(), }; export default adapter;