Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-e

Package Overview
Dependencies
Maintainers
10
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-e - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

3

package.json
{
"name": "json-e",
"version": "2.2.1",
"version": "2.3.0",
"description": "json parameterization module inspired from json-parameterization",

@@ -8,3 +8,2 @@ "main": "./src/index.js",

"test": "mocha test/*_test.js",
"prepublish": "npm test",
"build-demo": "cd demo && yarn && yarn build",

@@ -11,0 +10,0 @@ "start-demo": "cd demo && yarn && yarn start"

@@ -284,2 +284,28 @@ # [JSON-e](https://taskcluster.github.io/json-e)

### `$mergeDeep`
The `$mergeDeep` operator is like `$merge`, but it recurses into objects to
combine their contents property by property. Arrays are concatenated.
```yaml
context: {}
template:
$mergeDeep:
- task:
payload:
command: [a, b]
- task:
extra:
foo: bar
- task:
payload:
command: [c]
result:
task:
extra:
foo: bar
payload:
command: [a, b, c]
```
### `$sort`

@@ -511,2 +537,3 @@

* `str(x)` -- convert string, number, boolean, or array to string
* `lstrip(s)`, `rstrip(s)`, `strip(s)` -- strip whitespace from left, right, or both ends of a string
* `len(x)` -- length of a string or array

@@ -548,3 +575,3 @@

* Update the version, commit, and tag -- `npm patch` (or minor or major, depending)
* Update the version, commit, and tag -- `npm version patch` (or minor or major, depending)
* Push to release the JS version -- `git push && git push --tags`

@@ -551,0 +578,0 @@ * Release to PyPi:

@@ -100,2 +100,17 @@ var {BuiltinError} = require('./error');

define('strip', builtins, {
argumentTests: ['string'],
invoke: str => str.trim(),
});
define('rstrip', builtins, {
argumentTests: ['string'],
invoke: str => str.replace(/\s+$/, ''),
});
define('lstrip', builtins, {
argumentTests: ['string'],
invoke: str => str.replace(/^\s+/, ''),
});
// Miscellaneous

@@ -102,0 +117,0 @@ define('fromNow', builtins, {

@@ -164,2 +164,40 @@ var interpreter = require('./interpreter');

operators.$mergeDeep = (template, context) => {
let value = render(template['$mergeDeep'], context);
if (!isArray(value) || value.some(o => !isObject(o))) {
throw new TemplateError('$mergeDeep value must evaluate to an array of objects');
}
if (value.length === 0) {
return {};
}
// merge two values, preferring the right but concatenating lists and
// recursively merging objects
let merge = (l, r) => {
console.log(`merge(${JSON.stringify(l)}, ${JSON.stringify(r)})`);
if (isArray(l) && isArray(r)) {
return l.concat(r);
}
if (isObject(l) && isObject(r)) {
let res = Object.assign({}, l);
for (let p in r) { // eslint-disable-line taskcluster/no-for-in
if (p in l) {
res[p] = merge(l[p], r[p]);
console.log(`-> ${JSON.stringify(res[p])}`);
} else {
res[p] = r[p];
}
}
return res;
}
return r;
};
console.log(`merging ${JSON.stringify(value)}`);
// start with the first element of the list
return value.reduce(merge, value.shift());
return Object.assign({}, ...value);
};
operators.$reverse = (template, context) => {

@@ -166,0 +204,0 @@ let value = render(template['$reverse'], context);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc