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

json-e

Package Overview
Dependencies
Maintainers
7
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 3.0.0 to 3.0.1

src/index.d.ts

9

package.json
{
"name": "json-e",
"version": "3.0.0",
"version": "3.0.1",
"description": "json parameterization module inspired from json-parameterization",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"scripts": {

@@ -22,8 +23,8 @@ "lint": "eslint src/*.js test/*.js",

"dependencies": {
"json-stable-stringify": "^1.0.1"
"json-stable-stringify-without-jsonify": "^1.0.1"
},
"devDependencies": {
"assume": "^1.5.2",
"assume": "^2.0.0",
"browserify": "^14.5.0",
"eslint-config-taskcluster": "^3.0.0",
"eslint": "^5.12.1",
"mocha": "^4.0.1",

@@ -30,0 +31,0 @@ "source-map-support": "^0.5.0",

@@ -69,3 +69,3 @@ * [Full documentation](https://taskcluster.github.io/json-e)

JSON-e is distributed as a CommonJS package is not designed to be included
directly in a browser with `<script>`. Instead, it must be incorproated using a
directly in a browser with `<script>`. Instead, it must be incorporated using a
tool that understands CommonJS such as Webpack. See

@@ -75,6 +75,35 @@ [Neutrino](https://neutrino.js.org/) for an easy, configuration-free way to

## TypeScript
The JS module is installed with either of
```shell
npm install --save json-e
yarn add json-e
```
Note: Type definitions are included with this package, so there's no need of seperate
`@types/..` installation.
As 'json-e' is a CommonJS module, the package must be imported like this [(more..)](https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require) for type definitions to work properly:
```typescript
import jsone = require('json-e');
var template = {a: {$eval: "foo.bar"}};
var context = {foo: {bar: "zoo"}};
console.log(jsone(template, context));
// -> { a: 'zoo' }
```
## Python
The Python distribution exposes a `render` function:
The Python distribution is installed with
```shell
pip install json-e
```
The distribution exposes a `render` function:
```python

@@ -126,4 +155,6 @@ import jsone

## CLI
## Third-Party Integrations
### rjsone
You can use the 3rd party package [rjsone](https://wryun.github.io/rjsone/) to template

@@ -133,3 +164,11 @@ JSON-e from the command line, passing templates/contexts as files or arguments and using

### Bazel
You can use 3rd party [Bazel rule](https://github.com/atlassian/bazel-tools/tree/master/rjsone) to invoke
rjsone (see above) from Bazel build files.
### Terraform
The [jsone Terraform provider](https://github.com/taskcluster/terraform-provider-jsone) allows use of JSON-e for templating objects within Terraform.
# Language Reference

@@ -298,3 +337,3 @@

The available units are `day`, `hour`, and `minute`, for all of which a plural
The available units are `day`, `hour`, `minute`, and `second`, for all of which a plural
is also accepted.

@@ -351,3 +390,3 @@

can then be merged internally to give the resulting object with later keys overwriting
the previous ones.Otherwise the expression becomes invalid for the $map operator
the previous ones. Otherwise the expression becomes invalid for the $map operator.

@@ -370,3 +409,9 @@ ```yaml

The `$match` operator is not dissimilar to pattern matching operators. It gets an object, in which every key is a string expression(s) to evaluate to `true` or `false` based on the context. The result will be an array of things (all types are supported) that were values corresponding to the keys that were evaluated to `true`. The order of the things in the array will be arbitrary. If there are no matches, the result is an empty array.
The `$match` operator is not dissimilar to pattern matching operators.
It gets an object, in which every key is a string expression(s) to
evaluate to `true` or `false` based on the context. The result will
be an array of things (all types are supported) that were values
corresponding to the keys that were evaluated to `true`. The order of
the things in the array will be arbitrary. If there are no matches,
the result is an empty array.

@@ -479,7 +524,7 @@ ```yaml

Expression are given in a simple Python- or JavaScript-like expression
language. Its data types are limited to JSON types plus function objects.
language. Its data types are limited to JSON types plus function objects.
### Literals
Literals are similar to those for JSON. Numeric literals only accept integer
Literals are similar to those for JSON. Numeric literals only accept integer
and decimal notation. Strings do not support any kind of escaping. The use of

@@ -523,3 +568,3 @@ `\n` and `\t` in the example below depends on the YAML parser to expand the

context: {x: 'quick', z: 'sort'}
reslut: ['quick', 'sort', 'quicksort']
result: ['quick', 'sort', 'quicksort']
```

@@ -574,3 +619,3 @@

Boolean operations use C- and Javascript-style symbls `||`, `&&`, and `!`:
Boolean operations use C- and Javascript-style symbols `||`, `&&`, and `!`:

@@ -587,3 +632,3 @@ ```yaml

syntax or with dot syntax. Unlike Javascript, `obj.prop` is an error if `obj`
does not have `prop`, while `obj['prop']` will evaulate to `null`.
does not have `prop`, while `obj['prop']` will evaluate to `null`.

@@ -590,0 +635,0 @@ ```yaml

@@ -129,3 +129,3 @@ var {BuiltinError} = require('./error');

invoke: x => {
for (type of ['string', 'number', 'boolean', 'array', 'object', 'function']) {
for (let type of ['string', 'number', 'boolean', 'array', 'object', 'function']) {
if (types[type](x)) {

@@ -132,0 +132,0 @@ return type;

var interpreter = require('./interpreter');
var fromNow = require('./from-now');
var assert = require('assert');
var stringify = require('json-stable-stringify');
var stringify = require('json-stable-stringify-without-jsonify');
var {
isString, isNumber, isBool,
isArray, isObject, isFunction,
isArray, isObject,
isTruthy,

@@ -24,3 +23,3 @@ } = require('./type-utils');

}
};
}

@@ -157,3 +156,3 @@ let flattenDeep = (a) => {

operators.$map = (template, context) => {
EACH_RE = 'each\\(([a-zA-Z_][a-zA-Z0-9_]*)(,\\s*([a-zA-Z_][a-zA-Z0-9_]*))?\\)';
const EACH_RE = 'each\\(([a-zA-Z_][a-zA-Z0-9_]*)(,\\s*([a-zA-Z_][a-zA-Z0-9_]*))?\\)';
checkUndefinedProperties(template, ['\\$map', EACH_RE]);

@@ -280,3 +279,3 @@ let value = render(template['$map'], context);

operators.$sort = (template, context) => {
BY_RE = 'by\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)';
const BY_RE = 'by\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)';
checkUndefinedProperties(template, ['\\$sort', BY_RE]);

@@ -283,0 +282,0 @@ let value = render(template['$sort'], context);

@@ -6,3 +6,3 @@ /*

var PrattParser = require('./prattparser');
var {isString, isNumber, isInteger, isBool,
var {isString, isNumber, isInteger,
isArray, isObject, isFunction, isTruthy} = require('./type-utils');

@@ -152,8 +152,2 @@ var {InterpreterError} = require('./error');

let testLogicalOperand = (operator, operand) => {
if (!isBool(operand)) {
throw expectationError(`infix: ${operator}`, `boolean ${operator} boolean`);
}
};
let prefixRules = {};

@@ -359,2 +353,2 @@ let infixRules = {};

infixRules,
});
});

@@ -7,3 +7,2 @@ /*

var Tokenizer = require('./tokenizer');
var assert = require('assert');
var {isString} = require('./type-utils');

@@ -40,3 +39,5 @@ var {SyntaxError, TemplateError} = require('./error');

if (infixRules.hasOwnProperty(kind)) {
assert(this._precedenceMap[kind], `token '${kind}' must have a precedence`);
if (!this._precedenceMap[kind]) {
throw new Error(`token '${kind}' must have a precedence`);
}
}

@@ -76,3 +77,3 @@ }

}
};
}

@@ -147,2 +148,2 @@ class Context {

// Export PrattParser
module.exports = PrattParser;
module.exports = PrattParser;

@@ -1,2 +0,1 @@

var assert = require('assert');
var {SyntaxError} = require('./error');

@@ -32,2 +31,12 @@

/**
* Custom implementation of `assert` to avoid pulling in a
* polyfill on browsers
*/
const assert = prop => {
if (!prop) {
throw new Error('Token configuration is invalid');
}
};
class Tokenizer {

@@ -34,0 +43,0 @@ constructor(options = {}) {

Sorry, the diff of this file is not supported yet

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