diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..22d48fd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +sudo: false +notifications: + email: false +node_js: + - "6" + - "8" +cache: + directories: # Cache dependencies + - node_modules +script: + - npm test \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5142450 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,6 @@ +# Code of conduct + +**TL;DR**
+We expect folks that participate in both our online and [IRL](www.urbandictionary.com/define.php?term=IRL) communities to be kind and considerate of others at all times. + +Esri's official CoC text can be found at http://www.esri.com/events/code-of-conduct \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..084f8d1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing). \ No newline at end of file diff --git a/README.md b/README.md index 1ae4cdd..25d025d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,23 @@ -# Adlib +# adlib -A library for interpolating property values in JSON Objects. +[![npm version][npm-img]][npm-url] +[![build status][travis-img]][travis-url] +[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/adlib/master/LICENSE) -The Hub team uses this to create customized Web Maps, Hub Sites, Hub Pages and other types of items. +[npm-img]: https://img.shields.io/npm/v/adlib.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/adlib +[travis-img]: https://img.shields.io/travis/Esri/adlib/master.svg?style=flat-square +[travis-url]: https://travis-ci.org/Esri/adlib + +> A library for interpolating property values in JSON Objects. + +The [ArcGIS Hub](https://hub.arcgis.com) team uses adlib to create customized Web Maps, Hub Sites, Hub Pages and other items in ArcGIS Online. + +[Live Demo](https://arcgis.github.io/ember-arcgis-adlib-service/) # General Pattern -``` + +```js template: { val: '{{thing.val}}' }; @@ -30,7 +42,7 @@ If the `obj.prop` "path" in the settings object is a string, that string value i ## Multiple Strings A property of a template can have a value like `'The {{thing.animal}} was {{thing.color}}'`. When combined with a settings object that has the appropriate values, this will result in `The fox was brown`. -``` +```js let template = { value: 'The {{thing.animal}} was {{thing.color}}' }; @@ -43,10 +55,12 @@ let settings = { let result = adlib(template, settings); //> {value: 'The fox was red'} ``` + ## Objects + If the interpolated value is an object, it is returned. This allow us to graft trees of json together. -``` +```js let template = { value: '{{s.obj}}' }; @@ -64,7 +78,7 @@ let result = adlib(template, settings); ## Arrays If the interpolated value is an array, it is returned. Interpolation is also done within arrays. -``` +```js let template = { values: ['{{s.animal}}', 'fuzzy', '{{s.color}}'], names: '{{s.names}}' @@ -84,7 +98,7 @@ let result = adlib(template, settings); ## Transforms Adlib can apply transforms during the interpolation. The transform fn should have the following signature: `fn(key, value, settings)`. -``` +```js // Pattern // {{key:transformFnName}} @@ -100,18 +114,16 @@ let settings = { // key: s.animal.type // value: 'bear' // transformFnName: 'upcase' - ``` ### Notes About Transforms -- Transforms are ideally pure functions, and they **must** be sync functions! Promises are not supported. +- Transforms are ideally pure functions, and they **must** be sync functions! Promises are not supported. - Transform functions should be VERY resilient - we recommend unit testing them extensively - If your settings hash does not have an entry for the `key`, the `value` will be `null`. - ### Transforms -``` +```js let template = { value:'{{s.animal.type:upcase}}' }; @@ -135,7 +147,7 @@ let result = adlib(template, settings, transforms); ### Transforms using the Key A typical use-case for this is for translation. -``` +```js let template = { value:'{{s.animal.type:translate}}' }; @@ -163,7 +175,8 @@ let result = adlib(template, settings, transforms); By default, if the key is not found, `adlib` simply leaves the `{{key.path}}` in the output json. However, that can/will lead to problems when the json is consumed. The `optional` transform helps out in these scenarios. By default when `adlib` encounters something like: -``` + +```js { someProp: 'red' val: '{{key.path:optional}}' @@ -172,7 +185,7 @@ The `optional` transform helps out in these scenarios. By default when `adlib` e and `key.path` is `null` or `undefined`, the `val` property will simply be removed. -``` +```js { someProp: 'red' } @@ -180,7 +193,7 @@ and `key.path` is `null` or `undefined`, the `val` property will simply be remov The same thing works in arrays -``` +```js { someProp: 'red' vals: [ @@ -201,7 +214,7 @@ The same thing works in arrays However, there are times when simply removing the property/entry is not enough. Sometimes you need to "reach up" the object graph and remove a parent. This is where the `levelToRemove` comes in... -``` +```js let template = { someProp: 'red', operationalLayers: [ @@ -229,6 +242,7 @@ let settings = { operationalLayers: [] } ``` + ### levelToRemove | value | removes what | @@ -238,12 +252,11 @@ let settings = { | 2 | the grand-parent object/array | | ... | ... up the hiearchy | - ### Path Hierarchies Sometimes you may want to adlib a value using one of several possible data sources. You can specify each data source in a hierarchy of preference in the template -``` +```js let template = { dataset: { title: {{layer.name||item.title}}, @@ -268,15 +281,15 @@ let settings = { a: { weird: { xml: { - doc: '1505836376836' - } - } - } - } - } - } - } - } + doc: '1505836376836' + } + } + } + } + } + } + } + } } }, item: { @@ -298,8 +311,8 @@ let transforms = { toISO: function (key, val, settings) { if (isStringAndNotADateValue(val)) { return new Date(val).toISOString() - } - } + } + } } adlib(template, settings, transforms) @@ -325,7 +338,7 @@ We support returning strings ('RED', 'the red fox'), ints (23, 15), and floats ( **Note** Transforms can not be applied to the default value! Please see TODO.md for notes about changes required for this. -``` +```js let template = { msg: 'Site is at {{obj.mainUrl||obj.otherUrl||https://foo.bar?o=p&e=n}}' } @@ -336,3 +349,31 @@ let result = adlib(template, settings); // => returns // 'Site is at https://foo.bar?o=p&e=n' ``` + +### Local Development + +``` +npm install && npm test +``` + +### Contributing + +Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/Esri/contributing/blob/master/CONTRIBUTING.md). + +### License + +Copyright 2017 Esri + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +> http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +A copy of the license is available in the repository's [LICENSE](./LICENSE) file. diff --git a/docs/index.html b/docs/index.html index b3e656f..245f218 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,3 +1,4 @@ + @@ -22,9 +23,9 @@ @@ -36,6 +37,6 @@

Adlib: Json as Templates

- + diff --git a/docs/js/adlib.js b/docs/js/adlib.js deleted file mode 100644 index bb144b9..0000000 --- a/docs/js/adlib.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* adlib - v2.2.3 - Wed Feb 14 2018 15:58:24 GMT-0700 (MST) -* Copyright (c) 2018 Dave Bouwman / Esri -* Apache-2.0 -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.adlib = factory()); -}(this, (function () { 'use strict'; - -/** - * Return the value of a deep property, using a path. - */ -function getWithDefault (obj, path, defaultValue) { - if ( defaultValue === void 0 ) defaultValue = undefined; - - return path - .split('.') - .reduce(function (o, p) { return o ? o[p] : defaultValue; }, obj) -} - -/** - * Simply Map over the props of an object - */ -function mapValues (obj, fn) { - var keys = Object.keys(obj); - // console.info(`keys: ${keys}`); - var newObject = keys.reduce(function(acc, currentKey) { - // console.log(` acc: ${JSON.stringify(acc)} curKey: ${currentKey}`); - acc[currentKey] = fn(obj[currentKey], currentKey, obj); - return acc; - }, {}); - // console.info(` output: ${JSON.stringify(newObject)}`); - return newObject; -} - -/** - * Deep Map over the values in an object - */ -function isDate (v) { - return v instanceof Date - } - - function isFunction (v) { - return typeof v === 'function' - } - - function isObject (v) { - return typeof v === 'object' - } - - function isRegExp (v) { - return v instanceof RegExp - } - -function deepMapValues(object, callback, propertyPath, that) { - propertyPath = propertyPath || ''; - if(Array.isArray(object)){ - return object.map(deepMapValuesIteratee); - } - else if(object && isObject(object) && !isDate(object) && !isRegExp(object) && !isFunction(object)){ - return Object.assign({}, object, mapValues(object, deepMapValuesIteratee)); - } - else { - var output = callback(object, propertyPath); - return output; - } - - function deepMapValuesIteratee(value, key){ - var valuePath = propertyPath ? propertyPath + '.' + key : key; - return deepMapValues(value, callback, valuePath); - } -} - -/** - * The arborist is responsible for pruning trees with nodes/entries - * marked with `{{delete:NNN}}` - * - * There are multiple exports, mainly to allow for easy testing of the - * worker functions. Only `arborist` is meant to be used directy - */ -// import mapValues from 'lodash.mapvalues'; -function isObject$1 (v) { - return typeof v === 'object' -} - -/** - * Trim a tree decorated with `{{delete:NNN}}` - */ -function arborist (object, propertyPath) { - propertyPath = propertyPath || ''; - - if(Array.isArray(object)){ - // filter out any nulls... - var arrResults = object.map(iteratee).filter(function (entry) { - // need to ensure entry is actually NULL vs just falsey - return entry !== null && entry !== undefined; - }); - return pruneArray(arrResults); - - } if(object && isObject$1(object) ) { - - return pruneObject(mapValues(object, iteratee)); - - } else { - - return getPropertyValue(object, propertyPath); - } - - function iteratee(value, key){ - var valuePath = propertyPath ? propertyPath + '.' + key: key; - return arborist(value, valuePath); - } -} - -/** - * Prune an array - * For all the entries in the array... - * if the entry is a naked string and contains `{{delete:NNN}}` - * get maximum NNN value - * then - * if maxN === 0 - * return an empty array - * if maxN > 0 - * return `{{delete:maxN-1}}` - * else - * return array - */ -function pruneArray (arrResults) { - var res = arrResults; - // is any entry a string w/ {{delete}}? - var maxLevel = arrResults.reduce(function (maxLevel, e) { - if (isString$1(e) && hasDelete(e)) { - var lvl = getLevel(e); - if (lvl > maxLevel) { - maxLevel = lvl; - } - } - return maxLevel; - }, -1); - - if (maxLevel > -1) { - if (maxLevel === 0) { - res = []; - } else { - res = "{{delete:" + (maxLevel - 1) + "}}"; - } - } - - return res; -} - - -function pruneObject (objResults) { - // console.log(` pruneObject:: working on ${JSON.stringify(objResults)}`); - var startVal = {obj: {}, maxLevel: -1 }; - var res; - // cook a new clone object, and track the maxLevel - var reduction = Object.keys(objResults).reduce(function (acc, key) { - var val = objResults[key]; - if (isString$1(val) && hasDelete(val)) { - var lvl = getLevel(val); - if (lvl > acc.maxLevel) { - acc.maxLevel = lvl; - } - } else { - // only add the prop if it's not a `{{delete:NNN}}` - acc.obj[key] = val; - } - return acc; - }, startVal); - // if -1, we return entire object... - // if 0 we just remove the prop... - // if 1 we return undefined... - // if > 1 we return the deleteVal - if (reduction.maxLevel > 0 ) { - if (reduction.maxLevel === 1) { - res = undefined; - } else { - res = "{{delete:" + (reduction.maxLevel - 1) + "}}"; - } - } else { - res = reduction.obj; - } - - // console.log(` returning ${JSON.stringify(res)}`); - return res; -} - -/** - * Get a value for a property, handling the `{{delete:NNN}}` syntax - */ -function getPropertyValue (val){ - var output = val; - - if (typeof val === 'string') { - if (hasDelete(val)) { - output = getDeleteValue(val); - } - } - return output; -} - -/** - * Given a string with `{{delete:NNN}}` - * if NNN === 0 return undefined - * else return `{{delete:NNN - 1}}` - */ -function getDeleteValue (val) { - var output = val; - var level = getLevel(val); - if (level === 0) { - output = undefined; - } else { - output = "{{delete:" + level + "}}"; - } - return output; -} - -/** - * Extract the level from a `{{delete:NNN}}` - */ -function getLevel (value) { - return parseInt(value.replace(/{|}/g, '').split(':')[1]); -} - -/** - * Simple check if a value has `{{delete` in it - */ -function hasDelete (value) { - if (value && typeof value === 'string') { - return value.indexOf('{{delete') > -1; - } else { - return false; - } -} - -function isString$1 (v) { - return typeof v === 'string'; -} - -/** - * Optional Transform - * Supports a declarative syntax for optional template properties - * - * {{some.object.key:optional:2}} - * - * In this example, if defined, the value of `some.object.key` is used. - * If not defined, then the optional transform is utilized - * and a post-processing step is executed which will remove two parent levels - * from the output structure - */ - -function optional(key, value, settings, level) { - if ( level === void 0 ) level = 0; - - // console.log(`optional: ${key}, ${value}, ${level}`); - var val = value; - if (!value) { - val = "{{delete:" + level + "}}"; - } - return val; -} - -/** - * adlib.js - */ -function isString(v) { - return typeof v === 'string'; -} - -function _swap(parameter, settings, transforms) { - var value; - // console.info(`_swap: param: ${parameter}`); - // Parameters can optionally call transform functions - // e.g. "{{ipsum:translateLatin}}" - // so extract {{::}} - var transformCheck = parameter.split(':'); - if (transformCheck.length > 1) { - // we have a request to use a transform... - var key = transformCheck[0]; - var fn = transformCheck[1]; - // we default to using the value... - var param = null; - if (transformCheck[2]){ - param = transformCheck[2]; - } - if(transforms && transforms[fn] && typeof transforms[fn] === 'function') { - // get the value from the param - value = getWithDefault(settings, key); - // transform it... - value = transforms[fn](key, value, settings, param); - } else { - throw new Error(("Attempted to apply non-existant transform " + fn + " on " + key + " with params " + parameter)); - } - } else { - // we just get the value - value = getWithDefault(settings, parameter); - } - return value; -} - -/** - * Does a propertyPath exist on a target - */ -function _propertyPathExists (propertyPath, target) { - // remove any transforms - var cleanPath = propertyPath.split(':')[0]; - var value = getWithDefault(target, cleanPath, null); - if (value !== null && value !== undefined) { - return true; - } else { - return false; - } -} - -// Combine a Template with Settings -function adlib(template, settings, transforms) { - if ( transforms === void 0 ) transforms = null; - - transforms = transforms || {}; - if (transforms.optional) { - throw new Error('Please do not pass in an `optional` transform, adlib provides that interally.'); - } else { - transforms.optional = optional; - } - - var res = deepMapValues(template, function(templateValue, templatePath){ - // Only string templates - if (!isString(templateValue)) { - return templateValue; - } - - // When we match "{{layer.fields..}}" - var settingsValue; - var replaceValue = false; - - var handlebars = /{{[\w\.\:||&\/?=]*?}}/g; - var hbsEntries = templateValue.match(handlebars); - - if (hbsEntries && hbsEntries.length) { - // console.log(`Got a ${hbsEntries.length} handlebar entries...`); - var isStaticValue = false; - // iterate over the entries... - var values = hbsEntries.map(function (entry) { - // console.info(`Matched ${entry}...`); - // strip off the curlies... - var path = entry.replace(/{|}/g, ''); - // check for || which indicate a hiearchy - if (path.indexOf('||') > -1) { - var paths = path.split('||'); - var numberOfPaths = paths.length; - // here we check each option, in order, and return the first with a value in the hash, OR the last - path = paths.find(function (pathOption, idx) { - // console.info(`Checking to see if ${pathOption} is in settings hash...`); - var exists = _propertyPathExists(pathOption, settings); - if (!exists) { - if ((idx + 1) === numberOfPaths) { - // console.info(`Got to last entry, and still did not find anything... assuming ${pathOption} is a static value...`); - isStaticValue = true; - // check if we can convert this into a number... - if (!isNaN(pathOption)) { - pathOption = parseInt(pathOption); - } - return pathOption; - } else { - return false; - } - } else { - return pathOption; - } - }); - } - // setup the return value... - var result = { - key: entry, - value: path - }; - // if we have a valid object path, value comes from _swap - if (!isStaticValue) { - result.value = _swap(path, settings, transforms) || entry; - } - // console.info(`Value: ${JSON.stringify(result)}`); - return result; - }); - - values.forEach(function (v) { - // console.log(`Comparing ${templateValue} with ${v.key}`) - if (templateValue === v.key) { - // console.log(`template matches key, returning ${v.value}`); - // if the value is a string... - if (typeof v.value === 'string') { - // and it's numeric-ish - if(!isNaN(v.value)) { - // and has a . in it... - if (v.value.indexOf('.') > -1) { - // parse as a float... - v.value = parseFloat(v.value); - } else { - // parse as an int - v.value = parseInt(v.value); - } - } - } - settingsValue = v.value; - } else { - // a little extra regex dance to match the '||' because '|' - // is a Very Special Regex Character and we need to super - // escape them for the regex to work - // console.log(`KEY ${v.key}`); - // console.log(`TEMPLATE ${templateValue}`); - templateValue = templateValue.replace(v.key, v.value); - // console.log(`template did not match key, interpolating value ${v.value} into template to produce ${templateValue}`); - } - }); - - // if we have a value, let's return that... - if (settingsValue) { - // console.log(`We found a value so we return it ${settingsValue}`); - return settingsValue; - } else { - // console.log(`We did not find a value so we return the template ${templateValue}`); - // but if we don't, lets return the template itself - return templateValue; - } - } else { - // console.log(`We did not find a hbs match, so we return the template ${templateValue}`); - // no match, return the templateValue... - return templateValue; - } - }); - return arborist(res); -} - -return adlib; - -}))); -//# sourceMappingURL=adlib.js.map diff --git a/docs/js/adlib.js.map b/docs/js/adlib.js.map deleted file mode 100644 index a5d890a..0000000 --- a/docs/js/adlib.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"adlib.js","sources":["../lib/getWithDefault.js","../lib/mapValues.js","../lib/deepMap.js","../lib/optional-transform/arborist.js","../lib/optional-transform/optional.js","../lib/adlib.js"],"sourcesContent":["/**\n * Return the value of a deep property, using a path.\n */\nexport default function getWithDefault (obj, path, defaultValue = undefined) {\n return path\n .split('.')\n .reduce((o, p) => o ? o[p] : defaultValue, obj)\n}\n","/**\n * Simply Map over the props of an object\n */\nexport default function mapValues (obj, fn) {\n let keys = Object.keys(obj);\n // console.info(`keys: ${keys}`);\n var newObject = keys.reduce(function(acc, currentKey) {\n // console.log(` acc: ${JSON.stringify(acc)} curKey: ${currentKey}`);\n acc[currentKey] = fn(obj[currentKey], currentKey, obj);\n return acc;\n }, {});\n // console.info(` output: ${JSON.stringify(newObject)}`);\n return newObject;\n}\n","/**\n * Deep Map over the values in an object\n */\nimport mapValues from './mapValues';\n\n function isDate (v) {\n return v instanceof Date\n }\n\n function isFunction (v) {\n return typeof v === 'function'\n }\n\n function isObject (v) {\n return typeof v === 'object'\n }\n\n function isRegExp (v) {\n return v instanceof RegExp\n }\n\nexport default function deepMapValues(object, callback, propertyPath, that) {\n propertyPath = propertyPath || '';\n if(Array.isArray(object)){\n return object.map(deepMapValuesIteratee);\n }\n else if(object && isObject(object) && !isDate(object) && !isRegExp(object) && !isFunction(object)){\n return Object.assign({}, object, mapValues(object, deepMapValuesIteratee));\n }\n else {\n let output = callback(object, propertyPath);\n return output;\n }\n\n function deepMapValuesIteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key : key;\n return deepMapValues(value, callback, valuePath);\n }\n}\n","/**\n * The arborist is responsible for pruning trees with nodes/entries\n * marked with `{{delete:NNN}}`\n *\n * There are multiple exports, mainly to allow for easy testing of the\n * worker functions. Only `arborist` is meant to be used directy\n */\n// import mapValues from 'lodash.mapvalues';\nimport mapValues from '../mapValues';\n\nfunction isObject (v) {\n return typeof v === 'object'\n}\n\n/**\n * Trim a tree decorated with `{{delete:NNN}}`\n */\nexport function arborist (object, propertyPath) {\n propertyPath = propertyPath || '';\n\n if(Array.isArray(object)){\n // filter out any nulls...\n let arrResults = object.map(iteratee).filter((entry) => {\n // need to ensure entry is actually NULL vs just falsey\n return entry !== null && entry !== undefined;\n });\n return pruneArray(arrResults);\n\n } if(object && isObject(object) ) {\n\n return pruneObject(mapValues(object, iteratee));\n\n } else {\n\n return getPropertyValue(object, propertyPath);\n }\n\n function iteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key: key;\n return arborist(value, valuePath);\n }\n}\n\n/**\n * Prune an array\n * For all the entries in the array...\n * if the entry is a naked string and contains `{{delete:NNN}}`\n * get maximum NNN value\n * then\n * if maxN === 0\n * return an empty array\n * if maxN > 0\n * return `{{delete:maxN-1}}`\n * else\n * return array\n */\nexport function pruneArray (arrResults) {\n let res = arrResults;\n // is any entry a string w/ {{delete}}?\n let maxLevel = arrResults.reduce((maxLevel, e) => {\n if (isString(e) && hasDelete(e)) {\n let lvl = getLevel(e);\n if (lvl > maxLevel) {\n maxLevel = lvl;\n }\n }\n return maxLevel;\n }, -1);\n\n if (maxLevel > -1) {\n if (maxLevel === 0) {\n res = []\n } else {\n res = `{{delete:${maxLevel - 1}}}`;\n }\n }\n\n return res;\n}\n\n\nexport function pruneObject (objResults) {\n // console.log(` pruneObject:: working on ${JSON.stringify(objResults)}`);\n let startVal = {obj: {}, maxLevel: -1 };\n let res;\n // cook a new clone object, and track the maxLevel\n let reduction = Object.keys(objResults).reduce((acc, key) => {\n let val = objResults[key];\n if (isString(val) && hasDelete(val)) {\n let lvl = getLevel(val);\n if (lvl > acc.maxLevel) {\n acc.maxLevel = lvl;\n }\n } else {\n // only add the prop if it's not a `{{delete:NNN}}`\n acc.obj[key] = val;\n }\n return acc;\n }, startVal);\n // if -1, we return entire object...\n // if 0 we just remove the prop...\n // if 1 we return undefined...\n // if > 1 we return the deleteVal\n if (reduction.maxLevel > 0 ) {\n if (reduction.maxLevel === 1) {\n res = undefined;\n } else {\n res = `{{delete:${reduction.maxLevel - 1}}}`;\n }\n } else {\n res = reduction.obj;\n }\n\n // console.log(` returning ${JSON.stringify(res)}`);\n return res;\n}\n\n/**\n * Get a value for a property, handling the `{{delete:NNN}}` syntax\n */\nexport function getPropertyValue (val){\n let output = val;\n\n if (typeof val === 'string') {\n if (hasDelete(val)) {\n output = getDeleteValue(val);\n }\n }\n return output;\n}\n\n/**\n * Given a string with `{{delete:NNN}}`\n * if NNN === 0 return undefined\n * else return `{{delete:NNN - 1}}`\n */\nfunction getDeleteValue (val) {\n let output = val;\n let level = getLevel(val);\n if (level === 0) {\n output = undefined;\n } else {\n output = `{{delete:${level}}}`;\n }\n return output;\n}\n\n/**\n * Extract the level from a `{{delete:NNN}}`\n */\nfunction getLevel (value) {\n return parseInt(value.replace(/{|}/g, '').split(':')[1]);\n}\n\n/**\n * Simple check if a value has `{{delete` in it\n */\nfunction hasDelete (value) {\n if (value && typeof value === 'string') {\n return value.indexOf('{{delete') > -1;\n } else {\n return false;\n }\n}\n\nfunction isString (v) {\n return typeof v === 'string';\n}\n","/**\n * Optional Transform\n * Supports a declarative syntax for optional template properties\n *\n * {{some.object.key:optional:2}}\n *\n * In this example, if defined, the value of `some.object.key` is used.\n * If not defined, then the optional transform is utilized\n * and a post-processing step is executed which will remove two parent levels\n * from the output structure\n */\n\nexport default function optional(key, value, settings, level = 0) {\n // console.log(`optional: ${key}, ${value}, ${level}`);\n let val = value;\n if (!value) {\n val = `{{delete:${level}}}`;\n }\n return val;\n}\n","/**\n * adlib.js\n */\nimport getWithDefault from './getWithDefault';\nimport deepMapValues from './deepMap';\nimport {arborist} from './optional-transform/arborist';\nimport optionalTransform from './optional-transform/optional';\n\nfunction isString(v) {\n return typeof v === 'string';\n}\n\nfunction _swap(parameter, settings, transforms) {\n let value;\n // console.info(`_swap: param: ${parameter}`);\n // Parameters can optionally call transform functions\n // e.g. \"{{ipsum:translateLatin}}\"\n // so extract {{::}}\n let transformCheck = parameter.split(':');\n if (transformCheck.length > 1) {\n // we have a request to use a transform...\n let key = transformCheck[0];\n let fn = transformCheck[1];\n // we default to using the value...\n let param = null;\n if (transformCheck[2]){\n param = transformCheck[2];\n }\n if(transforms && transforms[fn] && typeof transforms[fn] === 'function') {\n // get the value from the param\n value = getWithDefault(settings, key);\n // transform it...\n value = transforms[fn](key, value, settings, param);\n } else {\n throw new Error(`Attempted to apply non-existant transform ${fn} on ${key} with params ${parameter}`);\n }\n } else {\n // we just get the value\n value = getWithDefault(settings, parameter);\n }\n return value;\n}\n\n/**\n * Does a propertyPath exist on a target\n */\nfunction _propertyPathExists (propertyPath, target) {\n // remove any transforms\n let cleanPath = propertyPath.split(':')[0];\n let value = getWithDefault(target, cleanPath, null);\n if (value !== null && value !== undefined) {\n return true;\n } else {\n return false;\n }\n}\n\n// Combine a Template with Settings\nexport default function adlib(template, settings, transforms = null) {\n transforms = transforms || {};\n if (transforms.optional) {\n throw new Error('Please do not pass in an `optional` transform, adlib provides that interally.');\n } else {\n transforms.optional = optionalTransform;\n }\n\n let res = deepMapValues(template, function(templateValue, templatePath){\n // Only string templates\n if (!isString(templateValue)) {\n return templateValue;\n }\n\n // When we match \"{{layer.fields..}}\"\n var settingsValue;\n var replaceValue = false;\n\n var handlebars = /{{[\\w\\.\\:||&\\/?=]*?}}/g;\n let hbsEntries = templateValue.match(handlebars);\n\n if (hbsEntries && hbsEntries.length) {\n // console.log(`Got a ${hbsEntries.length} handlebar entries...`);\n let isStaticValue = false;\n // iterate over the entries...\n let values = hbsEntries.map((entry) => {\n // console.info(`Matched ${entry}...`);\n // strip off the curlies...\n let path = entry.replace(/{|}/g, '');\n // check for || which indicate a hiearchy\n if (path.indexOf('||') > -1) {\n var paths = path.split('||');\n let numberOfPaths = paths.length;\n // here we check each option, in order, and return the first with a value in the hash, OR the last\n path = paths.find((pathOption, idx) => {\n // console.info(`Checking to see if ${pathOption} is in settings hash...`);\n let exists = _propertyPathExists(pathOption, settings);\n if (!exists) {\n if ((idx + 1) === numberOfPaths) {\n // console.info(`Got to last entry, and still did not find anything... assuming ${pathOption} is a static value...`);\n isStaticValue = true;\n // check if we can convert this into a number...\n if (!isNaN(pathOption)) {\n pathOption = parseInt(pathOption);\n }\n return pathOption;\n } else {\n return false;\n }\n } else {\n return pathOption;\n }\n });\n }\n // setup the return value...\n let result = {\n key: entry,\n value: path\n }\n // if we have a valid object path, value comes from _swap\n if (!isStaticValue) {\n result.value = _swap(path, settings, transforms) || entry;\n }\n // console.info(`Value: ${JSON.stringify(result)}`);\n return result;\n });\n\n values.forEach((v) => {\n // console.log(`Comparing ${templateValue} with ${v.key}`)\n if (templateValue === v.key) {\n // console.log(`template matches key, returning ${v.value}`);\n // if the value is a string...\n if (typeof v.value === 'string') {\n // and it's numeric-ish\n if(!isNaN(v.value)) {\n // and has a . in it...\n if (v.value.indexOf('.') > -1) {\n // parse as a float...\n v.value = parseFloat(v.value);\n } else {\n // parse as an int\n v.value = parseInt(v.value);\n }\n }\n }\n settingsValue = v.value;\n } else {\n // a little extra regex dance to match the '||' because '|'\n // is a Very Special Regex Character and we need to super\n // escape them for the regex to work\n // console.log(`KEY ${v.key}`);\n // console.log(`TEMPLATE ${templateValue}`);\n templateValue = templateValue.replace(v.key, v.value);\n // console.log(`template did not match key, interpolating value ${v.value} into template to produce ${templateValue}`);\n }\n });\n\n // if we have a value, let's return that...\n if (settingsValue) {\n // console.log(`We found a value so we return it ${settingsValue}`);\n return settingsValue;\n } else {\n // console.log(`We did not find a value so we return the template ${templateValue}`);\n // but if we don't, lets return the template itself\n return templateValue;\n }\n } else {\n // console.log(`We did not find a hbs match, so we return the template ${templateValue}`);\n // no match, return the templateValue...\n return templateValue;\n }\n });\n return arborist(res);\n}\n"],"names":["let","isObject","isString","optionalTransform"],"mappings":";;;;;;;;;;;AAAA;;;AAGA,AAAe,SAAS,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,YAAwB,EAAE;6CAAd,GAAG,SAAS;;EACzE,OAAO,IAAI;KACR,KAAK,CAAC,GAAG,CAAC;KACV,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,EAAE,SAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,GAAA,EAAE,GAAG,CAAC;CAClD;;ACPD;;;AAGA,AAAe,SAAS,SAAS,EA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AAE,UAAU,CAAC,IAAI,KAAK,CAAC;SAC3D;;QAED,OAAO,MAAM,CAAC;OACf,CAAC,CAAC;;MAEH,MAAM,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE;;QAEjB,IAAI,aAAa,KAAK,CAAC,CAAC,GAAG,EAAE;;;UAG3B,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;;YAE/B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;;cAElB,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;;gBAE7B,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;eAC/B,MAAM;;gBAEL,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;eAC7B;aACF;WACF;UACD,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC;SACzB,MAAM;;;;;;UAML,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;;SAEvD;OACF,CAAC,CAAC;;;MAGH,IAAI,aAAa,EAAE;;QAEjB,OAAO,aAAa,CAAC;OACtB,MAAM;;;QAGL,OAAO,aAAa,CAAC;OACtB;KACF,MAAM;;;MAGL,OAAO,aAAa,CAAC;KACtB;GACF,CAAC,CAAC;EACH,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;CACtB;;;;"} \ No newline at end of file diff --git a/docs/js/adlib.min.js b/docs/js/adlib.min.js deleted file mode 100644 index e245497..0000000 --- a/docs/js/adlib.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.adlib=e()}(this,function(){"use strict";function n(n,e,t){return void 0===t&&(t=void 0),e.split(".").reduce(function(n,e){return n?n[e]:t},n)}function e(n,e){return Object.keys(n).reduce(function(t,r){return t[r]=e(n[r],r,n),t},{})}function t(n){return n instanceof Date}function r(n){return"function"==typeof n}function u(n){return"object"==typeof n}function i(n){return n instanceof RegExp}function o(n,f,a,l){function c(n,e){return o(n,f,a?a+"."+e:e)}if(a=a||"",Array.isArray(n))return n.map(c);if(!n||!u(n)||t(n)||i(n)||r(n)){return f(n,a)}return Object.assign({},n,e(n,c))}function f(n){return"object"==typeof n}function a(n,t){function r(n,e){return a(n,t?t+"."+e:e)}if(t=t||"",Array.isArray(n)){return l(n.map(r).filter(function(n){return null!==n&&void 0!==n}))}return n&&f(n)?c(e(n,r)):v(n)}function l(n){var e=n,t=n.reduce(function(n,e){if(y(e)&&d(e)){var t=s(e);t>n&&(n=t)}return n},-1);return t>-1&&(e=0===t?[]:"{{delete:"+(t-1)+"}}"),e}function c(n){var e={obj:{},maxLevel:-1},t=Object.keys(n).reduce(function(e,t){var r=n[t];if(y(r)&&d(r)){var u=s(r);u>e.maxLevel&&(e.maxLevel=u)}else e.obj[t]=r;return e},e);return t.maxLevel>0?1===t.maxLevel?void 0:"{{delete:"+(t.maxLevel-1)+"}}":t.obj}function v(n){var e=n;return"string"==typeof n&&d(n)&&(e=p(n)),e}function p(n){var e=s(n);return 0===e?void 0:"{{delete:"+e+"}}"}function s(n){return parseInt(n.replace(/{|}/g,"").split(":")[1])}function d(n){return!(!n||"string"!=typeof n)&&n.indexOf("{{delete")>-1}function y(n){return"string"==typeof n}function m(n,e,t,r){void 0===r&&(r=0);var u=e;return e||(u="{{delete:"+r+"}}"),u}function g(n){return"string"==typeof n}function x(e,t,r){var u,i=e.split(":");if(i.length>1){var o=i[0],f=i[1],a=null;if(i[2]&&(a=i[2]),!r||!r[f]||"function"!=typeof r[f])throw new Error("Attempted to apply non-existant transform "+f+" on "+o+" with params "+e);u=n(t,o),u=r[f](o,u,t,a)}else u=n(t,e);return u}function b(e,t){var r=e.split(":")[0],u=n(t,r,null);return null!==u&&void 0!==u}function h(n,e,t){if(void 0===t&&(t=null),t=t||{},t.optional)throw new Error("Please do not pass in an `optional` transform, adlib provides that interally.");return t.optional=m,a(o(n,function(n,r){if(!g(n))return n;var u,i=/{{[\w\.\:||&\/?=]*?}}/g,o=n.match(i);if(o&&o.length){var f=!1;return o.map(function(n){var r=n.replace(/{|}/g,"");if(r.indexOf("||")>-1){var u=r.split("||"),i=u.length;r=u.find(function(n,t){return b(n,e)?n:t+1===i&&(f=!0,isNaN(n)||(n=parseInt(n)),n)})}var o={key:n,value:r};return f||(o.value=x(r,e,t)||n),o}).forEach(function(e){n===e.key?("string"==typeof e.value&&(isNaN(e.value)||(e.value.indexOf(".")>-1?e.value=parseFloat(e.value):e.value=parseInt(e.value))),u=e.value):n=n.replace(e.key,e.value)}),u||n}return n}))}return h}); -//# sourceMappingURL=adlib.min.js.map diff --git a/docs/js/adlib.min.js.map b/docs/js/adlib.min.js.map deleted file mode 100644 index 92ff0e8..0000000 --- a/docs/js/adlib.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"adlib.js","sources":["../lib/getWithDefault.js","../lib/mapValues.js","../lib/deepMap.js","../lib/optional-transform/arborist.js","../lib/optional-transform/optional.js","../lib/adlib.js"],"sourcesContent":["/**\n * Return the value of a deep property, using a path.\n */\nexport default function getWithDefault (obj, path, defaultValue = undefined) {\n return path\n .split('.')\n .reduce((o, p) => o ? o[p] : defaultValue, obj)\n}\n","/**\n * Simply Map over the props of an object\n */\nexport default function mapValues (obj, fn) {\n let keys = Object.keys(obj);\n // console.info(`keys: ${keys}`);\n var newObject = keys.reduce(function(acc, currentKey) {\n // console.log(` acc: ${JSON.stringify(acc)} curKey: ${currentKey}`);\n acc[currentKey] = fn(obj[currentKey], currentKey, obj);\n return acc;\n }, {});\n // console.info(` output: ${JSON.stringify(newObject)}`);\n return newObject;\n}\n","/**\n * Deep Map over the values in an object\n */\nimport mapValues from './mapValues';\n\n function isDate (v) {\n return v instanceof Date\n }\n\n function isFunction (v) {\n return typeof v === 'function'\n }\n\n function isObject (v) {\n return typeof v === 'object'\n }\n\n function isRegExp (v) {\n return v instanceof RegExp\n }\n\nexport default function deepMapValues(object, callback, propertyPath, that) {\n propertyPath = propertyPath || '';\n if(Array.isArray(object)){\n return object.map(deepMapValuesIteratee);\n }\n else if(object && isObject(object) && !isDate(object) && !isRegExp(object) && !isFunction(object)){\n return Object.assign({}, object, mapValues(object, deepMapValuesIteratee));\n }\n else {\n let output = callback(object, propertyPath);\n return output;\n }\n\n function deepMapValuesIteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key : key;\n return deepMapValues(value, callback, valuePath);\n }\n}\n","/**\n * The arborist is responsible for pruning trees with nodes/entries\n * marked with `{{delete:NNN}}`\n *\n * There are multiple exports, mainly to allow for easy testing of the\n * worker functions. Only `arborist` is meant to be used directy\n */\n// import mapValues from 'lodash.mapvalues';\nimport mapValues from '../mapValues';\n\nfunction isObject (v) {\n return typeof v === 'object'\n}\n\n/**\n * Trim a tree decorated with `{{delete:NNN}}`\n */\nexport function arborist (object, propertyPath) {\n propertyPath = propertyPath || '';\n\n if(Array.isArray(object)){\n // filter out any nulls...\n let arrResults = object.map(iteratee).filter((entry) => {\n // need to ensure entry is actually NULL vs just falsey\n return entry !== null && entry !== undefined;\n });\n return pruneArray(arrResults);\n\n } if(object && isObject(object) ) {\n\n return pruneObject(mapValues(object, iteratee));\n\n } else {\n\n return getPropertyValue(object, propertyPath);\n }\n\n function iteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key: key;\n return arborist(value, valuePath);\n }\n}\n\n/**\n * Prune an array\n * For all the entries in the array...\n * if the entry is a naked string and contains `{{delete:NNN}}`\n * get maximum NNN value\n * then\n * if maxN === 0\n * return an empty array\n * if maxN > 0\n * return `{{delete:maxN-1}}`\n * else\n * return array\n */\nexport function pruneArray (arrResults) {\n let res = arrResults;\n // is any entry a string w/ {{delete}}?\n let maxLevel = arrResults.reduce((maxLevel, e) => {\n if (isString(e) && hasDelete(e)) {\n let lvl = getLevel(e);\n if (lvl > maxLevel) {\n maxLevel = lvl;\n }\n }\n return maxLevel;\n }, -1);\n\n if (maxLevel > -1) {\n if (maxLevel === 0) {\n res = []\n } else {\n res = `{{delete:${maxLevel - 1}}}`;\n }\n }\n\n return res;\n}\n\n\nexport function pruneObject (objResults) {\n // console.log(` pruneObject:: working on ${JSON.stringify(objResults)}`);\n let startVal = {obj: {}, maxLevel: -1 };\n let res;\n // cook a new clone object, and track the maxLevel\n let reduction = Object.keys(objResults).reduce((acc, key) => {\n let val = objResults[key];\n if (isString(val) && hasDelete(val)) {\n let lvl = getLevel(val);\n if (lvl > acc.maxLevel) {\n acc.maxLevel = lvl;\n }\n } else {\n // only add the prop if it's not a `{{delete:NNN}}`\n acc.obj[key] = val;\n }\n return acc;\n }, startVal);\n // if -1, we return entire object...\n // if 0 we just remove the prop...\n // if 1 we return undefined...\n // if > 1 we return the deleteVal\n if (reduction.maxLevel > 0 ) {\n if (reduction.maxLevel === 1) {\n res = undefined;\n } else {\n res = `{{delete:${reduction.maxLevel - 1}}}`;\n }\n } else {\n res = reduction.obj;\n }\n\n // console.log(` returning ${JSON.stringify(res)}`);\n return res;\n}\n\n/**\n * Get a value for a property, handling the `{{delete:NNN}}` syntax\n */\nexport function getPropertyValue (val){\n let output = val;\n\n if (typeof val === 'string') {\n if (hasDelete(val)) {\n output = getDeleteValue(val);\n }\n }\n return output;\n}\n\n/**\n * Given a string with `{{delete:NNN}}`\n * if NNN === 0 return undefined\n * else return `{{delete:NNN - 1}}`\n */\nfunction getDeleteValue (val) {\n let output = val;\n let level = getLevel(val);\n if (level === 0) {\n output = undefined;\n } else {\n output = `{{delete:${level}}}`;\n }\n return output;\n}\n\n/**\n * Extract the level from a `{{delete:NNN}}`\n */\nfunction getLevel (value) {\n return parseInt(value.replace(/{|}/g, '').split(':')[1]);\n}\n\n/**\n * Simple check if a value has `{{delete` in it\n */\nfunction hasDelete (value) {\n if (value && typeof value === 'string') {\n return value.indexOf('{{delete') > -1;\n } else {\n return false;\n }\n}\n\nfunction isString (v) {\n return typeof v === 'string';\n}\n","/**\n * Optional Transform\n * Supports a declarative syntax for optional template properties\n *\n * {{some.object.key:optional:2}}\n *\n * In this example, if defined, the value of `some.object.key` is used.\n * If not defined, then the optional transform is utilized\n * and a post-processing step is executed which will remove two parent levels\n * from the output structure\n */\n\nexport default function optional(key, value, settings, level = 0) {\n // console.log(`optional: ${key}, ${value}, ${level}`);\n let val = value;\n if (!value) {\n val = `{{delete:${level}}}`;\n }\n return val;\n}\n","/**\n * adlib.js\n */\nimport getWithDefault from './getWithDefault';\nimport deepMapValues from './deepMap';\nimport {arborist} from './optional-transform/arborist';\nimport optionalTransform from './optional-transform/optional';\n\nfunction isString(v) {\n return typeof v === 'string';\n}\n\nfunction _swap(parameter, settings, transforms) {\n let value;\n // console.info(`_swap: param: ${parameter}`);\n // Parameters can optionally call transform functions\n // e.g. \"{{ipsum:translateLatin}}\"\n // so extract {{::}}\n let transformCheck = parameter.split(':');\n if (transformCheck.length > 1) {\n // we have a request to use a transform...\n let key = transformCheck[0];\n let fn = transformCheck[1];\n // we default to using the value...\n let param = null;\n if (transformCheck[2]){\n param = transformCheck[2];\n }\n if(transforms && transforms[fn] && typeof transforms[fn] === 'function') {\n // get the value from the param\n value = getWithDefault(settings, key);\n // transform it...\n value = transforms[fn](key, value, settings, param);\n } else {\n throw new Error(`Attempted to apply non-existant transform ${fn} on ${key} with params ${parameter}`);\n }\n } else {\n // we just get the value\n value = getWithDefault(settings, parameter);\n }\n return value;\n}\n\n/**\n * Does a propertyPath exist on a target\n */\nfunction _propertyPathExists (propertyPath, target) {\n // remove any transforms\n let cleanPath = propertyPath.split(':')[0];\n let value = getWithDefault(target, cleanPath, null);\n if (value !== null && value !== undefined) {\n return true;\n } else {\n return false;\n }\n}\n\n// Combine a Template with Settings\nexport default function adlib(template, settings, transforms = null) {\n transforms = transforms || {};\n if (transforms.optional) {\n throw new Error('Please do not pass in an `optional` transform, adlib provides that interally.');\n } else {\n transforms.optional = optionalTransform;\n }\n\n let res = deepMapValues(template, function(templateValue, templatePath){\n // Only string templates\n if (!isString(templateValue)) {\n return templateValue;\n }\n\n // When we match \"{{layer.fields..}}\"\n var settingsValue;\n var replaceValue = false;\n\n var handlebars = /{{[\\w\\.\\:||&\\/?=]*?}}/g;\n let hbsEntries = templateValue.match(handlebars);\n\n if (hbsEntries && hbsEntries.length) {\n // console.log(`Got a ${hbsEntries.length} handlebar entries...`);\n let isStaticValue = false;\n // iterate over the entries...\n let values = hbsEntries.map((entry) => {\n // console.info(`Matched ${entry}...`);\n // strip off the curlies...\n let path = entry.replace(/{|}/g, '');\n // check for || which indicate a hiearchy\n if (path.indexOf('||') > -1) {\n var paths = path.split('||');\n let numberOfPaths = paths.length;\n // here we check each option, in order, and return the first with a value in the hash, OR the last\n path = paths.find((pathOption, idx) => {\n // console.info(`Checking to see if ${pathOption} is in settings hash...`);\n let exists = _propertyPathExists(pathOption, settings);\n if (!exists) {\n if ((idx + 1) === numberOfPaths) {\n // console.info(`Got to last entry, and still did not find anything... assuming ${pathOption} is a static value...`);\n isStaticValue = true;\n // check if we can convert this into a number...\n if (!isNaN(pathOption)) {\n pathOption = parseInt(pathOption);\n }\n return pathOption;\n } else {\n return false;\n }\n } else {\n return pathOption;\n }\n });\n }\n // setup the return value...\n let result = {\n key: entry,\n value: path\n }\n // if we have a valid object path, value comes from _swap\n if (!isStaticValue) {\n result.value = _swap(path, settings, transforms) || entry;\n }\n // console.info(`Value: ${JSON.stringify(result)}`);\n return result;\n });\n\n values.forEach((v) => {\n // console.log(`Comparing ${templateValue} with ${v.key}`)\n if (templateValue === v.key) {\n // console.log(`template matches key, returning ${v.value}`);\n // if the value is a string...\n if (typeof v.value === 'string') {\n // and it's numeric-ish\n if(!isNaN(v.value)) {\n // and has a . in it...\n if (v.value.indexOf('.') > -1) {\n // parse as a float...\n v.value = parseFloat(v.value);\n } else {\n // parse as an int\n v.value = parseInt(v.value);\n }\n }\n }\n settingsValue = v.value;\n } else {\n // a little extra regex dance to match the '||' because '|'\n // is a Very Special Regex Character and we need to super\n // escape them for the regex to work\n // console.log(`KEY ${v.key}`);\n // console.log(`TEMPLATE ${templateValue}`);\n templateValue = templateValue.replace(v.key, v.value);\n // console.log(`template did not match key, interpolating value ${v.value} into template to produce ${templateValue}`);\n }\n });\n\n // if we have a value, let's return that...\n if (settingsValue) {\n // console.log(`We found a value so we return it ${settingsValue}`);\n return settingsValue;\n } else {\n // console.log(`We did not find a value so we return the template ${templateValue}`);\n // but if we don't, lets return the template itself\n return templateValue;\n }\n } else {\n // console.log(`We did not find a hbs match, so we return the template ${templateValue}`);\n // no match, return the templateValue...\n return templateValue;\n }\n });\n return arborist(res);\n}\n"],"names":["getWithDefault","obj","path","defaultValue","undefined","split","reduce","o","p","mapValues","fn","Object","keys","acc","currentKey","isDate","v","Date","isFunction","isObject","isRegExp","RegExp","deepMapValues","object","callback","propertyPath","that","deepMapValuesIteratee","value","key","Array","isArray","map","assign","arborist","iteratee","pruneArray","filter","entry","pruneObject","getPropertyValue","arrResults","let","res","maxLevel","e","isString","hasDelete","lvl","getLevel","objResults","startVal","reduction","val","output","getDeleteValue","level","parseInt","replace","indexOf","optional","settings","_swap","parameter","transforms","transformCheck","length","param","Error","_propertyPathExists","target","cleanPath","adlib","template","optionalTransform","templateValue","templatePath","settingsValue","handlebars","hbsEntries","match","isStaticValue","paths","numberOfPaths","find","pathOption","idx","isNaN","result","forEach","parseFloat"],"mappings":"gLAGA,SAAwBA,GAAgBC,EAAKC,EAAMC,GACjD,0BADgEC,IACzDF,EACJG,MAAM,KACNC,OAAO,SAACC,EAAGC,SAAMD,GAAIA,EAAEC,GAAKL,GAAcF,GCH/C,QAAwBQ,GAAWR,EAAKS,GAStC,MARWC,QAAOC,KAAKX,GAEFK,OAAO,SAASO,EAAKC,GAGxC,MADAD,GAAIC,GAAcJ,EAAGT,EAAIa,GAAaA,EAAYb,GAC3CY,OCNX,QAEUE,GAAQC,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b,GAAEY,QAEP2D,MAAMvE,EAAEY,SAENZ,EAAEY,MAAM+B,QAAQ,MAAQ,EAE1B3C,EAAEY,MAAQ8D,WAAW1E,EAAEY,OAGvBZ,EAAEY,MAAQ6B,SAASzC,EAAEY,SAI3BiD,EAAgB7D,EAAEY,OAOlB+C,EAAgBA,EAAcjB,QAAQ1C,EAAEa,IAAKb,EAAEY,SAM/CiD,GAMKF,EAKT,MAAOA"} \ No newline at end of file diff --git a/docs/js/adlib.umd.js b/docs/js/adlib.umd.js deleted file mode 100644 index eab6172..0000000 --- a/docs/js/adlib.umd.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* adlib - v2.2.3 - Wed Feb 14 2018 15:58:23 GMT-0700 (MST) -* Copyright (c) 2018 Dave Bouwman / Esri -* Apache-2.0 -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.adlib = factory()); -}(this, (function () { 'use strict'; - -/** - * Return the value of a deep property, using a path. - */ -function getWithDefault (obj, path, defaultValue) { - if ( defaultValue === void 0 ) defaultValue = undefined; - - return path - .split('.') - .reduce(function (o, p) { return o ? o[p] : defaultValue; }, obj) -} - -/** - * Simply Map over the props of an object - */ -function mapValues (obj, fn) { - var keys = Object.keys(obj); - // console.info(`keys: ${keys}`); - var newObject = keys.reduce(function(acc, currentKey) { - // console.log(` acc: ${JSON.stringify(acc)} curKey: ${currentKey}`); - acc[currentKey] = fn(obj[currentKey], currentKey, obj); - return acc; - }, {}); - // console.info(` output: ${JSON.stringify(newObject)}`); - return newObject; -} - -/** - * Deep Map over the values in an object - */ -function isDate (v) { - return v instanceof Date - } - - function isFunction (v) { - return typeof v === 'function' - } - - function isObject (v) { - return typeof v === 'object' - } - - function isRegExp (v) { - return v instanceof RegExp - } - -function deepMapValues(object, callback, propertyPath, that) { - propertyPath = propertyPath || ''; - if(Array.isArray(object)){ - return object.map(deepMapValuesIteratee); - } - else if(object && isObject(object) && !isDate(object) && !isRegExp(object) && !isFunction(object)){ - return Object.assign({}, object, mapValues(object, deepMapValuesIteratee)); - } - else { - var output = callback(object, propertyPath); - return output; - } - - function deepMapValuesIteratee(value, key){ - var valuePath = propertyPath ? propertyPath + '.' + key : key; - return deepMapValues(value, callback, valuePath); - } -} - -/** - * The arborist is responsible for pruning trees with nodes/entries - * marked with `{{delete:NNN}}` - * - * There are multiple exports, mainly to allow for easy testing of the - * worker functions. Only `arborist` is meant to be used directy - */ -// import mapValues from 'lodash.mapvalues'; -function isObject$1 (v) { - return typeof v === 'object' -} - -/** - * Trim a tree decorated with `{{delete:NNN}}` - */ -function arborist (object, propertyPath) { - propertyPath = propertyPath || ''; - - if(Array.isArray(object)){ - // filter out any nulls... - var arrResults = object.map(iteratee).filter(function (entry) { - // need to ensure entry is actually NULL vs just falsey - return entry !== null && entry !== undefined; - }); - return pruneArray(arrResults); - - } if(object && isObject$1(object) ) { - - return pruneObject(mapValues(object, iteratee)); - - } else { - - return getPropertyValue(object, propertyPath); - } - - function iteratee(value, key){ - var valuePath = propertyPath ? propertyPath + '.' + key: key; - return arborist(value, valuePath); - } -} - -/** - * Prune an array - * For all the entries in the array... - * if the entry is a naked string and contains `{{delete:NNN}}` - * get maximum NNN value - * then - * if maxN === 0 - * return an empty array - * if maxN > 0 - * return `{{delete:maxN-1}}` - * else - * return array - */ -function pruneArray (arrResults) { - var res = arrResults; - // is any entry a string w/ {{delete}}? - var maxLevel = arrResults.reduce(function (maxLevel, e) { - if (isString$1(e) && hasDelete(e)) { - var lvl = getLevel(e); - if (lvl > maxLevel) { - maxLevel = lvl; - } - } - return maxLevel; - }, -1); - - if (maxLevel > -1) { - if (maxLevel === 0) { - res = []; - } else { - res = "{{delete:" + (maxLevel - 1) + "}}"; - } - } - - return res; -} - - -function pruneObject (objResults) { - // console.log(` pruneObject:: working on ${JSON.stringify(objResults)}`); - var startVal = {obj: {}, maxLevel: -1 }; - var res; - // cook a new clone object, and track the maxLevel - var reduction = Object.keys(objResults).reduce(function (acc, key) { - var val = objResults[key]; - if (isString$1(val) && hasDelete(val)) { - var lvl = getLevel(val); - if (lvl > acc.maxLevel) { - acc.maxLevel = lvl; - } - } else { - // only add the prop if it's not a `{{delete:NNN}}` - acc.obj[key] = val; - } - return acc; - }, startVal); - // if -1, we return entire object... - // if 0 we just remove the prop... - // if 1 we return undefined... - // if > 1 we return the deleteVal - if (reduction.maxLevel > 0 ) { - if (reduction.maxLevel === 1) { - res = undefined; - } else { - res = "{{delete:" + (reduction.maxLevel - 1) + "}}"; - } - } else { - res = reduction.obj; - } - - // console.log(` returning ${JSON.stringify(res)}`); - return res; -} - -/** - * Get a value for a property, handling the `{{delete:NNN}}` syntax - */ -function getPropertyValue (val){ - var output = val; - - if (typeof val === 'string') { - if (hasDelete(val)) { - output = getDeleteValue(val); - } - } - return output; -} - -/** - * Given a string with `{{delete:NNN}}` - * if NNN === 0 return undefined - * else return `{{delete:NNN - 1}}` - */ -function getDeleteValue (val) { - var output = val; - var level = getLevel(val); - if (level === 0) { - output = undefined; - } else { - output = "{{delete:" + level + "}}"; - } - return output; -} - -/** - * Extract the level from a `{{delete:NNN}}` - */ -function getLevel (value) { - return parseInt(value.replace(/{|}/g, '').split(':')[1]); -} - -/** - * Simple check if a value has `{{delete` in it - */ -function hasDelete (value) { - if (value && typeof value === 'string') { - return value.indexOf('{{delete') > -1; - } else { - return false; - } -} - -function isString$1 (v) { - return typeof v === 'string'; -} - -/** - * Optional Transform - * Supports a declarative syntax for optional template properties - * - * {{some.object.key:optional:2}} - * - * In this example, if defined, the value of `some.object.key` is used. - * If not defined, then the optional transform is utilized - * and a post-processing step is executed which will remove two parent levels - * from the output structure - */ - -function optional(key, value, settings, level) { - if ( level === void 0 ) level = 0; - - // console.log(`optional: ${key}, ${value}, ${level}`); - var val = value; - if (!value) { - val = "{{delete:" + level + "}}"; - } - return val; -} - -/** - * adlib.js - */ -function isString(v) { - return typeof v === 'string'; -} - -function _swap(parameter, settings, transforms) { - var value; - // console.info(`_swap: param: ${parameter}`); - // Parameters can optionally call transform functions - // e.g. "{{ipsum:translateLatin}}" - // so extract {{::}} - var transformCheck = parameter.split(':'); - if (transformCheck.length > 1) { - // we have a request to use a transform... - var key = transformCheck[0]; - var fn = transformCheck[1]; - // we default to using the value... - var param = null; - if (transformCheck[2]){ - param = transformCheck[2]; - } - if(transforms && transforms[fn] && typeof transforms[fn] === 'function') { - // get the value from the param - value = getWithDefault(settings, key); - // transform it... - value = transforms[fn](key, value, settings, param); - } else { - throw new Error(("Attempted to apply non-existant transform " + fn + " on " + key + " with params " + parameter)); - } - } else { - // we just get the value - value = getWithDefault(settings, parameter); - } - return value; -} - -/** - * Does a propertyPath exist on a target - */ -function _propertyPathExists (propertyPath, target) { - // remove any transforms - var cleanPath = propertyPath.split(':')[0]; - var value = getWithDefault(target, cleanPath, null); - if (value !== null && value !== undefined) { - return true; - } else { - return false; - } -} - -// Combine a Template with Settings -function adlib(template, settings, transforms) { - if ( transforms === void 0 ) transforms = null; - - transforms = transforms || {}; - if (transforms.optional) { - throw new Error('Please do not pass in an `optional` transform, adlib provides that interally.'); - } else { - transforms.optional = optional; - } - - var res = deepMapValues(template, function(templateValue, templatePath){ - // Only string templates - if (!isString(templateValue)) { - return templateValue; - } - - // When we match "{{layer.fields..}}" - var settingsValue; - var replaceValue = false; - - var handlebars = /{{[\w\.\:||&\/?=]*?}}/g; - var hbsEntries = templateValue.match(handlebars); - - if (hbsEntries && hbsEntries.length) { - // console.log(`Got a ${hbsEntries.length} handlebar entries...`); - var isStaticValue = false; - // iterate over the entries... - var values = hbsEntries.map(function (entry) { - // console.info(`Matched ${entry}...`); - // strip off the curlies... - var path = entry.replace(/{|}/g, ''); - // check for || which indicate a hiearchy - if (path.indexOf('||') > -1) { - var paths = path.split('||'); - var numberOfPaths = paths.length; - // here we check each option, in order, and return the first with a value in the hash, OR the last - path = paths.find(function (pathOption, idx) { - // console.info(`Checking to see if ${pathOption} is in settings hash...`); - var exists = _propertyPathExists(pathOption, settings); - if (!exists) { - if ((idx + 1) === numberOfPaths) { - // console.info(`Got to last entry, and still did not find anything... assuming ${pathOption} is a static value...`); - isStaticValue = true; - // check if we can convert this into a number... - if (!isNaN(pathOption)) { - pathOption = parseInt(pathOption); - } - return pathOption; - } else { - return false; - } - } else { - return pathOption; - } - }); - } - // setup the return value... - var result = { - key: entry, - value: path - }; - // if we have a valid object path, value comes from _swap - if (!isStaticValue) { - result.value = _swap(path, settings, transforms) || entry; - } - // console.info(`Value: ${JSON.stringify(result)}`); - return result; - }); - - values.forEach(function (v) { - // console.log(`Comparing ${templateValue} with ${v.key}`) - if (templateValue === v.key) { - // console.log(`template matches key, returning ${v.value}`); - // if the value is a string... - if (typeof v.value === 'string') { - // and it's numeric-ish - if(!isNaN(v.value)) { - // and has a . in it... - if (v.value.indexOf('.') > -1) { - // parse as a float... - v.value = parseFloat(v.value); - } else { - // parse as an int - v.value = parseInt(v.value); - } - } - } - settingsValue = v.value; - } else { - // a little extra regex dance to match the '||' because '|' - // is a Very Special Regex Character and we need to super - // escape them for the regex to work - // console.log(`KEY ${v.key}`); - // console.log(`TEMPLATE ${templateValue}`); - templateValue = templateValue.replace(v.key, v.value); - // console.log(`template did not match key, interpolating value ${v.value} into template to produce ${templateValue}`); - } - }); - - // if we have a value, let's return that... - if (settingsValue) { - // console.log(`We found a value so we return it ${settingsValue}`); - return settingsValue; - } else { - // console.log(`We did not find a value so we return the template ${templateValue}`); - // but if we don't, lets return the template itself - return templateValue; - } - } else { - // console.log(`We did not find a hbs match, so we return the template ${templateValue}`); - // no match, return the templateValue... - return templateValue; - } - }); - return arborist(res); -} - -return adlib; - -}))); -//# sourceMappingURL=adlib.umd.js.map diff --git a/docs/js/adlib.umd.js.map b/docs/js/adlib.umd.js.map deleted file mode 100644 index 91ee3c7..0000000 --- a/docs/js/adlib.umd.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"adlib.umd.js","sources":["../lib/getWithDefault.js","../lib/mapValues.js","../lib/deepMap.js","../lib/optional-transform/arborist.js","../lib/optional-transform/optional.js","../lib/adlib.js"],"sourcesContent":["/**\n * Return the value of a deep property, using a path.\n */\nexport default function getWithDefault (obj, path, defaultValue = undefined) {\n return path\n .split('.')\n .reduce((o, p) => o ? o[p] : defaultValue, obj)\n}\n","/**\n * Simply Map over the props of an object\n */\nexport default function mapValues (obj, fn) {\n let keys = Object.keys(obj);\n // console.info(`keys: ${keys}`);\n var newObject = keys.reduce(function(acc, currentKey) {\n // console.log(` acc: ${JSON.stringify(acc)} curKey: ${currentKey}`);\n acc[currentKey] = fn(obj[currentKey], currentKey, obj);\n return acc;\n }, {});\n // console.info(` output: ${JSON.stringify(newObject)}`);\n return newObject;\n}\n","/**\n * Deep Map over the values in an object\n */\nimport mapValues from './mapValues';\n\n function isDate (v) {\n return v instanceof Date\n }\n\n function isFunction (v) {\n return typeof v === 'function'\n }\n\n function isObject (v) {\n return typeof v === 'object'\n }\n\n function isRegExp (v) {\n return v instanceof RegExp\n }\n\nexport default function deepMapValues(object, callback, propertyPath, that) {\n propertyPath = propertyPath || '';\n if(Array.isArray(object)){\n return object.map(deepMapValuesIteratee);\n }\n else if(object && isObject(object) && !isDate(object) && !isRegExp(object) && !isFunction(object)){\n return Object.assign({}, object, mapValues(object, deepMapValuesIteratee));\n }\n else {\n let output = callback(object, propertyPath);\n return output;\n }\n\n function deepMapValuesIteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key : key;\n return deepMapValues(value, callback, valuePath);\n }\n}\n","/**\n * The arborist is responsible for pruning trees with nodes/entries\n * marked with `{{delete:NNN}}`\n *\n * There are multiple exports, mainly to allow for easy testing of the\n * worker functions. Only `arborist` is meant to be used directy\n */\n// import mapValues from 'lodash.mapvalues';\nimport mapValues from '../mapValues';\n\nfunction isObject (v) {\n return typeof v === 'object'\n}\n\n/**\n * Trim a tree decorated with `{{delete:NNN}}`\n */\nexport function arborist (object, propertyPath) {\n propertyPath = propertyPath || '';\n\n if(Array.isArray(object)){\n // filter out any nulls...\n let arrResults = object.map(iteratee).filter((entry) => {\n // need to ensure entry is actually NULL vs just falsey\n return entry !== null && entry !== undefined;\n });\n return pruneArray(arrResults);\n\n } if(object && isObject(object) ) {\n\n return pruneObject(mapValues(object, iteratee));\n\n } else {\n\n return getPropertyValue(object, propertyPath);\n }\n\n function iteratee(value, key){\n var valuePath = propertyPath ? propertyPath + '.' + key: key;\n return arborist(value, valuePath);\n }\n}\n\n/**\n * Prune an array\n * For all the entries in the array...\n * if the entry is a naked string and contains `{{delete:NNN}}`\n * get maximum NNN value\n * then\n * if maxN === 0\n * return an empty array\n * if maxN > 0\n * return `{{delete:maxN-1}}`\n * else\n * return array\n */\nexport function pruneArray (arrResults) {\n let res = arrResults;\n // is any entry a string w/ {{delete}}?\n let maxLevel = arrResults.reduce((maxLevel, e) => {\n if (isString(e) && hasDelete(e)) {\n let lvl = getLevel(e);\n if (lvl > maxLevel) {\n maxLevel = lvl;\n }\n }\n return maxLevel;\n }, -1);\n\n if (maxLevel > -1) {\n if (maxLevel === 0) {\n res = []\n } else {\n res = `{{delete:${maxLevel - 1}}}`;\n }\n }\n\n return res;\n}\n\n\nexport function pruneObject (objResults) {\n // console.log(` pruneObject:: working on ${JSON.stringify(objResults)}`);\n let startVal = {obj: {}, maxLevel: -1 };\n let res;\n // cook a new clone object, and track the maxLevel\n let reduction = Object.keys(objResults).reduce((acc, key) => {\n let val = objResults[key];\n if (isString(val) && hasDelete(val)) {\n let lvl = getLevel(val);\n if (lvl > acc.maxLevel) {\n acc.maxLevel = lvl;\n }\n } else {\n // only add the prop if it's not a `{{delete:NNN}}`\n acc.obj[key] = val;\n }\n return acc;\n }, startVal);\n // if -1, we return entire object...\n // if 0 we just remove the prop...\n // if 1 we return undefined...\n // if > 1 we return the deleteVal\n if (reduction.maxLevel > 0 ) {\n if (reduction.maxLevel === 1) {\n res = undefined;\n } else {\n res = `{{delete:${reduction.maxLevel - 1}}}`;\n }\n } else {\n res = reduction.obj;\n }\n\n // console.log(` returning ${JSON.stringify(res)}`);\n return res;\n}\n\n/**\n * Get a value for a property, handling the `{{delete:NNN}}` syntax\n */\nexport function getPropertyValue (val){\n let output = val;\n\n if (typeof val === 'string') {\n if (hasDelete(val)) {\n output = getDeleteValue(val);\n }\n }\n return output;\n}\n\n/**\n * Given a string with `{{delete:NNN}}`\n * if NNN === 0 return undefined\n * else return `{{delete:NNN - 1}}`\n */\nfunction getDeleteValue (val) {\n let output = val;\n let level = getLevel(val);\n if (level === 0) {\n output = undefined;\n } else {\n output = `{{delete:${level}}}`;\n }\n return output;\n}\n\n/**\n * Extract the level from a `{{delete:NNN}}`\n */\nfunction getLevel (value) {\n return parseInt(value.replace(/{|}/g, '').split(':')[1]);\n}\n\n/**\n * Simple check if a value has `{{delete` in it\n */\nfunction hasDelete (value) {\n if (value && typeof value === 'string') {\n return value.indexOf('{{delete') > -1;\n } else {\n return false;\n }\n}\n\nfunction isString (v) {\n return typeof v === 'string';\n}\n","/**\n * Optional Transform\n * Supports a declarative syntax for optional template properties\n *\n * {{some.object.key:optional:2}}\n *\n * In this example, if defined, the value of `some.object.key` is used.\n * If not defined, then the optional transform is utilized\n * and a post-processing step is executed which will remove two parent levels\n * from the output structure\n */\n\nexport default function optional(key, value, settings, level = 0) {\n // console.log(`optional: ${key}, ${value}, ${level}`);\n let val = value;\n if (!value) {\n val = `{{delete:${level}}}`;\n }\n return val;\n}\n","/**\n * adlib.js\n */\nimport getWithDefault from './getWithDefault';\nimport deepMapValues from './deepMap';\nimport {arborist} from './optional-transform/arborist';\nimport optionalTransform from './optional-transform/optional';\n\nfunction isString(v) {\n return typeof v === 'string';\n}\n\nfunction _swap(parameter, settings, transforms) {\n let value;\n // console.info(`_swap: param: ${parameter}`);\n // Parameters can optionally call transform functions\n // e.g. \"{{ipsum:translateLatin}}\"\n // so extract {{::}}\n let transformCheck = parameter.split(':');\n if (transformCheck.length > 1) {\n // we have a request to use a transform...\n let key = transformCheck[0];\n let fn = transformCheck[1];\n // we default to using the value...\n let param = null;\n if (transformCheck[2]){\n param = transformCheck[2];\n }\n if(transforms && transforms[fn] && typeof transforms[fn] === 'function') {\n // get the value from the param\n value = getWithDefault(settings, key);\n // transform it...\n value = transforms[fn](key, value, settings, param);\n } else {\n throw new Error(`Attempted to apply non-existant transform ${fn} on ${key} with params ${parameter}`);\n }\n } else {\n // we just get the value\n value = getWithDefault(settings, parameter);\n }\n return value;\n}\n\n/**\n * Does a propertyPath exist on a target\n */\nfunction _propertyPathExists (propertyPath, target) {\n // remove any transforms\n let cleanPath = propertyPath.split(':')[0];\n let value = getWithDefault(target, cleanPath, null);\n if (value !== null && value !== undefined) {\n return true;\n } else {\n return false;\n }\n}\n\n// Combine a Template with Settings\nexport default function adlib(template, settings, transforms = null) {\n transforms = transforms || {};\n if (transforms.optional) {\n throw new Error('Please do not pass in an `optional` transform, adlib provides that interally.');\n } else {\n transforms.optional = optionalTransform;\n }\n\n let res = deepMapValues(template, function(templateValue, templatePath){\n // Only string templates\n if (!isString(templateValue)) {\n return templateValue;\n }\n\n // When we match \"{{layer.fields..}}\"\n var settingsValue;\n var replaceValue = false;\n\n var handlebars = /{{[\\w\\.\\:||&\\/?=]*?}}/g;\n let hbsEntries = templateValue.match(handlebars);\n\n if (hbsEntries && hbsEntries.length) {\n // console.log(`Got a ${hbsEntries.length} handlebar entries...`);\n let isStaticValue = false;\n // iterate over the entries...\n let values = hbsEntries.map((entry) => {\n // console.info(`Matched ${entry}...`);\n // strip off the curlies...\n let path = entry.replace(/{|}/g, '');\n // check for || which indicate a hiearchy\n if (path.indexOf('||') > -1) {\n var paths = path.split('||');\n let numberOfPaths = paths.length;\n // here we check each option, in order, and return the first with a value in the hash, OR the last\n path = paths.find((pathOption, idx) => {\n // console.info(`Checking to see if ${pathOption} is in settings hash...`);\n let exists = _propertyPathExists(pathOption, settings);\n if (!exists) {\n if ((idx + 1) === numberOfPaths) {\n // console.info(`Got to last entry, and still did not find anything... assuming ${pathOption} is a static value...`);\n isStaticValue = true;\n // check if we can convert this into a number...\n if (!isNaN(pathOption)) {\n pathOption = parseInt(pathOption);\n }\n return pathOption;\n } else {\n return false;\n }\n } else {\n return pathOption;\n }\n });\n }\n // setup the return value...\n let result = {\n key: entry,\n value: path\n }\n // if we have a valid object path, value comes from _swap\n if (!isStaticValue) {\n result.value = _swap(path, settings, transforms) || entry;\n }\n // console.info(`Value: ${JSON.stringify(result)}`);\n return result;\n });\n\n values.forEach((v) => {\n // console.log(`Comparing ${templateValue} with ${v.key}`)\n if (templateValue === v.key) {\n // console.log(`template matches key, returning ${v.value}`);\n // if the value is a string...\n if (typeof v.value === 'string') {\n // and it's numeric-ish\n if(!isNaN(v.value)) {\n // and has a . in it...\n if (v.value.indexOf('.') > -1) {\n // parse as a float...\n v.value = parseFloat(v.value);\n } else {\n // parse as an int\n v.value = parseInt(v.value);\n }\n }\n }\n settingsValue = v.value;\n } else {\n // a little extra regex dance to match the '||' because '|'\n // is a Very Special Regex Character and we need to super\n // escape them for the regex to work\n // console.log(`KEY ${v.key}`);\n // console.log(`TEMPLATE ${templateValue}`);\n templateValue = templateValue.replace(v.key, v.value);\n // console.log(`template did not match key, interpolating value ${v.value} into template to produce ${templateValue}`);\n }\n });\n\n // if we have a value, let's return that...\n if (settingsValue) {\n // console.log(`We found a value so we return it ${settingsValue}`);\n return settingsValue;\n } else {\n // console.log(`We did not find a value so we return the template ${templateValue}`);\n // but if we don't, lets return the template itself\n return templateValue;\n }\n } else {\n // console.log(`We did not find a hbs match, so we return the template ${templateValue}`);\n // no match, return the templateValue...\n return templateValue;\n }\n });\n return arborist(res);\n}\n"],"names":["let","isObject","isString","optionalTransform"],"mappings":";;;;;;;;;;;AAAA;;;AAGA,AAAe,SAAS,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,YAAwB,EAAE;6CAAd,GAAG,SAAS;;EACzE,OAAO,IAAI;KACR,KAAK,CAAC,GAAG,CAAC;KACV,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,EAAE,SAA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EAAE,IAAI;SACZ,CAAA;;QAED,IAAI,CAAC,aAAa,EAAE;UAClB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,KAAK,CAAC;SAC3D;;QAED,OAAO,MAAM,CAAC;OACf,CAAC,CAAC;;MAEH,MAAM,CAAC,OAAO,CAAC,UAAC,CAAC,EAAE;;QAEjB,IAAI,aAAa,KAAK,CAAC,CAAC,GAAG,EAAE;;;UAG3B,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;;YAE/B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;;cAElB,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;;gBAE7B,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;eAC/B,MAAM;;gBAEL,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;eAC7B;aACF;WACF;UACD,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC;SACzB,MAAM;;;;;;UAML,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;;SAEvD;OACF,CAAC,CAAC;;;MAGH,IAAI,aAAa,EAAE;;QAEjB,OAAO,aAAa,CAAC;OACtB,MAAM;;;QAGL,OAAO,aAAa,CAAC;OACtB;KACF,MAAM;;;MAGL,OAAO,aAAa,CAAC;KACtB;GACF,CAAC,CAAC;EACH,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;CACtB;;;;"} \ No newline at end of file diff --git a/lib/adlib.js b/lib/adlib.js index 0cf4c60..2a92919 100644 --- a/lib/adlib.js +++ b/lib/adlib.js @@ -1,6 +1,14 @@ -/** - * adlib.js - */ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + import getWithDefault from './getWithDefault'; import deepMapValues from './deepMap'; import {arborist} from './optional-transform/arborist'; diff --git a/lib/deepMap.js b/lib/deepMap.js index c57a81c..e248bc1 100644 --- a/lib/deepMap.js +++ b/lib/deepMap.js @@ -1,3 +1,14 @@ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + /** * Deep Map over the values in an object */ diff --git a/lib/getWithDefault.js b/lib/getWithDefault.js index c2fe0b7..9ab9512 100644 --- a/lib/getWithDefault.js +++ b/lib/getWithDefault.js @@ -1,3 +1,14 @@ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + /** * Return the value of a deep property, using a path. */ diff --git a/lib/mapValues.js b/lib/mapValues.js index 760e151..07d8640 100644 --- a/lib/mapValues.js +++ b/lib/mapValues.js @@ -1,3 +1,14 @@ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + /** * Simply Map over the props of an object */ diff --git a/lib/optional-transform/arborist.js b/lib/optional-transform/arborist.js index d7a9394..4c74c8d 100644 --- a/lib/optional-transform/arborist.js +++ b/lib/optional-transform/arborist.js @@ -1,3 +1,14 @@ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + /** * The arborist is responsible for pruning trees with nodes/entries * marked with `{{delete:NNN}}` diff --git a/lib/optional-transform/optional.js b/lib/optional-transform/optional.js index b0b1aec..4492207 100644 --- a/lib/optional-transform/optional.js +++ b/lib/optional-transform/optional.js @@ -1,3 +1,14 @@ +/* Copyright 2017 Esri + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ + /** * Optional Transform * Supports a declarative syntax for optional template properties diff --git a/package-lock.json b/package-lock.json index 4a0497c..53820e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "adlib", - "version": "1.1.1", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -10,9 +10,9 @@ "integrity": "sha512-UlzeWnrIjacUSFL2Az1sX2vtROL5efRbB+caZc/js6HiYCKWhITb9qiCnJLcLGDYCX0wmfN2WSEj9E1tDb+j7Q==" }, "acorn": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", - "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz", + "integrity": "sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==", "dev": true }, "acorn-jsx": { @@ -209,9 +209,9 @@ "dev": true }, "assertion-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", - "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async-each": { @@ -232,11 +232,11 @@ "babel-register": "6.26.0", "babel-runtime": "6.26.0", "chokidar": "1.7.0", - "commander": "2.12.2", + "commander": "2.14.1", "convert-source-map": "1.5.1", "fs-readdir-recursive": "1.1.0", "glob": "7.1.2", - "lodash": "4.17.4", + "lodash": "4.17.5", "output-file-sync": "1.1.2", "path-is-absolute": "1.0.1", "slash": "1.0.0", @@ -262,7 +262,7 @@ "dev": true, "requires": { "babel-code-frame": "6.26.0", - "babel-generator": "6.26.0", + "babel-generator": "6.26.1", "babel-helpers": "6.24.1", "babel-messages": "6.23.0", "babel-register": "6.26.0", @@ -274,7 +274,7 @@ "convert-source-map": "1.5.1", "debug": "2.6.9", "json5": "0.5.1", - "lodash": "4.17.4", + "lodash": "4.17.5", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", "private": "0.1.8", @@ -283,9 +283,9 @@ } }, "babel-generator": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz", - "integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=", + "version": "6.26.1", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", + "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "dev": true, "requires": { "babel-messages": "6.23.0", @@ -293,7 +293,7 @@ "babel-types": "6.26.0", "detect-indent": "4.0.0", "jsesc": "1.3.0", - "lodash": "4.17.4", + "lodash": "4.17.5", "source-map": "0.5.7", "trim-right": "1.0.1" } @@ -341,7 +341,7 @@ "babel-helper-function-name": "6.24.1", "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "babel-helper-explode-assignable-expression": { @@ -418,7 +418,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "babel-helper-remap-async-to-generator": { @@ -631,7 +631,7 @@ "babel-template": "6.26.0", "babel-traverse": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "babel-plugin-transform-es2015-classes": { @@ -1004,7 +1004,7 @@ "babel-runtime": "6.26.0", "core-js": "2.5.3", "home-or-tmp": "2.0.0", - "lodash": "4.17.4", + "lodash": "4.17.5", "mkdirp": "0.5.1", "source-map-support": "0.4.18" } @@ -1029,7 +1029,7 @@ "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "babel-traverse": { @@ -1046,7 +1046,7 @@ "debug": "2.6.9", "globals": "9.18.0", "invariant": "2.2.2", - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "babel-types": { @@ -1057,7 +1057,7 @@ "requires": { "babel-runtime": "6.26.0", "esutils": "2.0.2", - "lodash": "4.17.4", + "lodash": "4.17.5", "to-fast-properties": "1.0.3" } }, @@ -1088,7 +1088,7 @@ "requires": { "ansi-align": "2.0.0", "camelcase": "4.1.0", - "chalk": "2.3.0", + "chalk": "2.3.1", "cli-boxes": "1.0.0", "string-width": "2.1.1", "term-size": "1.2.0", @@ -1111,20 +1111,20 @@ } }, "chalk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", - "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz", + "integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.5.0" + "supports-color": "5.2.0" } }, "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, "is-fullwidth-code-point": { @@ -1153,20 +1153,20 @@ } }, "supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.2.0.tgz", + "integrity": "sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q==", "dev": true, "requires": { - "has-flag": "2.0.0" + "has-flag": "3.0.0" } } } }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -1184,23 +1184,6 @@ "repeat-element": "1.1.2" } }, - "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", - "dev": true, - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - } - } - }, "browser-stdout": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", @@ -1279,7 +1262,7 @@ "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", "dev": true, "requires": { - "assertion-error": "1.0.2", + "assertion-error": "1.1.0", "deep-eql": "0.1.3", "type-detect": "1.0.0" } @@ -1395,9 +1378,9 @@ "dev": true }, "commander": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", - "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==", "dev": true }, "concat-map": { @@ -1413,7 +1396,7 @@ "dev": true, "requires": { "inherits": "2.0.3", - "readable-stream": "2.3.3", + "readable-stream": "2.3.4", "typedarray": "0.0.6" } }, @@ -1426,7 +1409,7 @@ "chalk": "0.5.1", "commander": "2.6.0", "date-fns": "1.29.0", - "lodash": "4.17.4", + "lodash": "4.17.5", "rx": "2.3.24", "spawn-command": "0.0.2-1", "supports-color": "3.2.3", @@ -1536,7 +1519,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "date-fns": { @@ -1625,7 +1608,7 @@ "is-path-in-cwd": "1.0.0", "object-assign": "4.1.1", "pify": "2.3.0", - "pinkie-promise": "2.0.2", + "pinkie-promise": "2.0.1", "rimraf": "2.6.2" } }, @@ -1684,9 +1667,9 @@ } }, "es5-ext": { - "version": "0.10.37", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", - "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", + "version": "0.10.38", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", + "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", "dev": true, "requires": { "es6-iterator": "2.0.3", @@ -1700,7 +1683,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-symbol": "3.1.1" } }, @@ -1711,7 +1694,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", @@ -1725,7 +1708,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -1738,7 +1721,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "es6-weak-map": { @@ -1748,7 +1731,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } @@ -1783,7 +1766,7 @@ "debug": "2.6.9", "doctrine": "2.1.0", "escope": "3.6.0", - "espree": "3.5.2", + "espree": "3.5.3", "esquery": "1.0.0", "estraverse": "4.2.0", "esutils": "2.0.2", @@ -1794,11 +1777,11 @@ "imurmurhash": "0.1.4", "inquirer": "0.12.0", "is-my-json-valid": "2.17.1", - "is-resolvable": "1.0.1", + "is-resolvable": "1.1.0", "js-yaml": "3.10.0", "json-stable-stringify": "1.0.1", "levn": "0.3.0", - "lodash": "4.17.4", + "lodash": "4.17.5", "mkdirp": "0.5.1", "natural-compare": "1.4.0", "optionator": "0.8.2", @@ -1875,12 +1858,12 @@ "dev": true }, "espree": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", - "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.3.tgz", + "integrity": "sha512-Zy3tAJDORxQZLl2baguiRU1syPERAIg0L+JB2MWorORgTu/CplzvxS9WWA7Xh4+Q+eOQihNs/1o1Xep8cvCxWQ==", "dev": true, "requires": { - "acorn": "5.3.0", + "acorn": "5.4.1", "acorn-jsx": "3.0.1" } }, @@ -1934,7 +1917,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "exec-sh": { @@ -2027,9 +2010,9 @@ "dev": true }, "filesize": { - "version": "3.5.11", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.5.11.tgz", - "integrity": "sha512-ZH7loueKBoDb7yG9esn1U+fgq7BzlzW6NRi5/rMdxIZ05dj7GFD/Xc5rq2CDt5Yq86CyfSYVyx4242QQNZbx1g==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.0.tgz", + "integrity": "sha512-g5OWtoZWcPI56js1DFhIEqyG9tnu/7sG3foHwgS9KGYFMfsYguI3E+PRVCmtmE96VajQIEMRU2OhN+ME589Gdw==", "dev": true }, "fill-range": { @@ -2873,14 +2856,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -2891,6 +2866,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -3080,7 +3063,7 @@ "glob": "7.1.2", "object-assign": "4.1.1", "pify": "2.3.0", - "pinkie-promise": "2.0.2" + "pinkie-promise": "2.0.1" } }, "graceful-fs": { @@ -3196,7 +3179,7 @@ "cli-cursor": "1.0.2", "cli-width": "2.2.0", "figures": "1.7.0", - "lodash": "4.17.4", + "lodash": "4.17.5", "readline2": "1.0.1", "run-async": "0.1.0", "rx-lite": "3.1.2", @@ -3393,9 +3376,9 @@ } }, "is-resolvable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.1.tgz", - "integrity": "sha512-y5CXYbzvB3jTnWAZH1Nl7ykUWb6T3BcTs56HUruwBf8MhF56n1HWqhDWnVFo8GHrUPDgvUUNVhrc2U8W7iqz5g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-stream": { @@ -3518,9 +3501,9 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._baseassign": { @@ -3658,7 +3641,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -3929,18 +3912,18 @@ "dev": true }, "pinkie": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.5.tgz", - "integrity": "sha512-9fAxS/+I3fBLBLJpZkuUTa1nY78BDWiP4Z8NFebaBCt3NuInv31J4YrljAaktsJ5QodyQ1qyr5EdBzTITF1cxw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", "dev": true }, "pinkie-promise": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.2.tgz", - "integrity": "sha512-GqWLUZ/LAOXVNpPziRxV07Y2kT0h7rGYR2sBMT0toq4JaYw9UezW1jnzjurmrrm7D2PSGCwfJi/T1gInurqHPQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "2.0.5" + "pinkie": "2.0.4" } }, "pluralize": { @@ -3968,9 +3951,9 @@ "dev": true }, "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4027,15 +4010,15 @@ } }, "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.4.tgz", + "integrity": "sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ==", "dev": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", "isarray": "1.0.0", - "process-nextick-args": "1.0.7", + "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", "string_decoder": "1.0.3", "util-deprecate": "1.0.2" @@ -4050,7 +4033,7 @@ "requires": { "graceful-fs": "4.1.11", "minimatch": "3.0.4", - "readable-stream": "2.3.3", + "readable-stream": "2.3.4", "set-immediate-shim": "1.0.1" } }, @@ -4267,12 +4250,12 @@ } }, "rollup-plugin-commonjs": { - "version": "8.2.6", - "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.6.tgz", - "integrity": "sha512-qK0+uhktmnAgZkHkqFuajNmPw93fjrO7+CysDaxWE5jrUR9XSlSvuao5ZJP+XizxA8weakhgYYBtbVz9SGBpjA==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.3.0.tgz", + "integrity": "sha512-PYs3OiYgENFYEmI3vOEm5nrp3eY90YZqd5vGmQqeXmhJsAWFIrFdROCvOasqJ1HgeTvqyYo9IGXnFDyoboNcgQ==", "dev": true, "requires": { - "acorn": "5.3.0", + "acorn": "5.4.1", "estree-walker": "0.5.1", "magic-string": "0.22.4", "resolve": "1.5.0", @@ -4323,17 +4306,16 @@ "boxen": "1.3.0", "colors": "1.1.2", "deep-assign": "2.0.0", - "filesize": "3.5.11", + "filesize": "3.6.0", "gzip-size": "3.0.0" } }, "rollup-plugin-node-resolve": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.0.tgz", - "integrity": "sha1-i4l8TDAw1QASd7BRSyXSygloPuA=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.2.tgz", + "integrity": "sha512-ZwmMip/yqw6cmDQJuCQJ1G7gw2z11iGUtQNFYrFZHmqadRHU+OZGC3nOXwXu+UTvcm5lzDspB1EYWrkTgPWybw==", "dev": true, "requires": { - "browser-resolve": "1.11.2", "builtin-modules": "1.1.1", "is-module": "1.0.0", "resolve": "1.5.0" @@ -4463,15 +4445,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -4494,6 +4467,15 @@ "function-bind": "1.1.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -4536,7 +4518,7 @@ "ajv": "4.11.8", "ajv-keywords": "1.5.1", "chalk": "1.1.3", - "lodash": "4.17.4", + "lodash": "4.17.5", "slice-ansi": "0.0.4", "string-width": "2.1.1" }, diff --git a/package.json b/package.json index 4758962..c64f019 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,13 @@ "init": "mkdir dist", "clean": "rm -rf dist", "build": "rollup -c profiles/dev.js", - "build:release": "rollup -c profiles/umd.js && rollup -c profiles/prod.js && rollup -c profiles/dev.js && cp ./dist/* ./docs/js", + "build:release": "rollup -c profiles/umd.js && rollup -c profiles/prod.js && rollup -c profiles/dev.js", "test": "node test/duct.js", "test:compiled": "mocha test/*.spec.js" }, "repository": { "type": "git", - "url": "git+https://github.com/ArcGIS/adlib.git" + "url": "git+https://github.com/Esri/adlib.git" }, "keywords": [ "arcgis", @@ -38,7 +38,7 @@ ], "license": "Apache-2.0", "bugs": { - "url": "https://github.com/ArcGIS/adlib/issues" + "url": "https://github.com/Esri/adlib/issues" }, "homepage": "https://arcgis.github.io/ember-arcgis-adlib-service", "@std/esm": {