mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-22 21:37:49 +00:00
push all website files
This commit is contained in:
110
website/functions/node_modules/stringifier/CHANGELOG.md
generated
vendored
Normal file
110
website/functions/node_modules/stringifier/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
## [1.4.0](https://github.com/twada/stringifier/releases/tag/v1.4.0) (2018-08-23)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* prop name whitelist now works with non-enumerable properties like Error's ([fcb518ef](https://github.com/twada/stringifier/commit/fcb518eff7a20a8dba98ff3356eb8edbb30a093a))
|
||||
|
||||
|
||||
## [1.3.0](https://github.com/twada/stringifier/releases/tag/v1.3.0) (2016-05-25)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* [Consolidate ponyfills into core-js](https://github.com/twada/stringifier/pull/6)
|
||||
|
||||
|
||||
### [1.2.1](https://github.com/twada/stringifier/releases/tag/v1.2.1) (2015-10-26)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **stringifier:**
|
||||
* [stringify sparse arrays correctly](https://github.com/twada/stringifier/pull/5)
|
||||
|
||||
|
||||
## [1.2.0](https://github.com/twada/stringifier/releases/tag/v1.2.0) (2015-07-10)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **stringifier:**
|
||||
* [support native ES6 Symbol](https://github.com/twada/stringifier/pull/3)
|
||||
|
||||
|
||||
## [1.1.0](https://github.com/twada/stringifier/releases/tag/v1.1.0) (2015-04-27)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **stringifier:**
|
||||
* use ponyfills for older browsers ([ea4e3f67](https://github.com/twada/stringifier/commit/ea4e3f673592fce8c57b49362100dc888038024e))
|
||||
* ship npm module with built bundle for browsers ([afdbd850](https://github.com/twada/stringifier/commit/afdbd850de3be0e5d40d3b574b4c0940ce2b5144))
|
||||
|
||||
|
||||
### [1.0.1](https://github.com/twada/stringifier/releases/tag/v1.0.1) (2015-02-14)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **stringifier:** introduce safeKey filter to skip unsafe property access ([67a9fa72](https://github.com/twada/stringifier/commit/67a9fa725c7602f948772f4f5f5a74806809ee34))
|
||||
|
||||
|
||||
## [1.0.0](https://github.com/twada/stringifier/releases/tag/v1.0.0) (2014-11-09)
|
||||
|
||||
|
||||
#### Features
|
||||
|
||||
* **stringifier:** absorb `handlers` argument into `options.handlers` ([0b073f53](https://github.com/twada/stringifier/commit/0b073f535eb0e99e97938c6101d8d2086f53a1df))
|
||||
|
||||
|
||||
#### Breaking Changes
|
||||
|
||||
* Now `handlers` are moved to `options.handlers`. `handlers` argument is no more.
|
||||
|
||||
- changed `stringifier(options, handlers)` to `stringifier(options)`
|
||||
- changed `stringifier.stringify(val, options, handlers)` to `stringifier.stringify(val, options)`
|
||||
|
||||
To migrate, change your code from the following:
|
||||
|
||||
```
|
||||
var stringifier = require('stringifier');
|
||||
var stringify = stringifier(options, handlers);
|
||||
console.log(stringify(anyVar));
|
||||
```
|
||||
|
||||
To:
|
||||
|
||||
```
|
||||
var stringifier = require('stringifier');
|
||||
options.handlers = handlers;
|
||||
var stringify = stringifier(options);
|
||||
console.log(stringify(anyVar));
|
||||
```
|
||||
|
||||
And
|
||||
|
||||
```
|
||||
var stringify = require('stringifier').stringify;
|
||||
console.log(stringify(anyVar, options, handlers));
|
||||
```
|
||||
|
||||
To:
|
||||
|
||||
```
|
||||
var stringify = require('stringifier').stringify;
|
||||
options.handlers = handlers;
|
||||
console.log(stringify(anyVar, options));
|
||||
```
|
||||
|
||||
([0b073f53](https://github.com/twada/stringifier/commit/0b073f535eb0e99e97938c6101d8d2086f53a1df))
|
||||
|
||||
|
||||
### [0.1.2](https://github.com/twada/stringifier/releases/tag/v0.1.2) (2014-10-27)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **stringifier:** do not truncate if string length is short enough ([2d22e44e](https://github.com/twada/stringifier/commit/2d22e44e15ea8c3eb5aae70dc6067de9b1878115))
|
||||
|
||||
|
535
website/functions/node_modules/stringifier/README.md
generated
vendored
Normal file
535
website/functions/node_modules/stringifier/README.md
generated
vendored
Normal file
@@ -0,0 +1,535 @@
|
||||
stringifier
|
||||
================================
|
||||
|
||||
Yet another stringify function.
|
||||
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![NPM package][npm-image]][npm-url]
|
||||
[![Bower package][bower-image]][bower-url]
|
||||
[![License][license-image]][license-url]
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
---------------------------------------
|
||||
|
||||
`stringifier` is a function like `JSON.stringify` but intended to be more customizable. For example,
|
||||
|
||||
- Max depth for recursive object tree traversal
|
||||
- Per-type output customization
|
||||
- Circular reference handling
|
||||
|
||||
|
||||
Pull-requests, issue reports and patches are always welcomed. `stringifier` is a spin-off product of [power-assert](https://github.com/power-assert-js/power-assert) project.
|
||||
|
||||
|
||||
API
|
||||
---------------------------------------
|
||||
|
||||
|
||||
### stringifier(options)
|
||||
|
||||
`require('stringifier')` exports single function `stringifier` that accepts `options` as optional parameters and returns configured function for stringify. This is the comprehensive usage.
|
||||
|
||||
```javascript
|
||||
var stringifier = require('stringifier');
|
||||
var stringify = stringifier(options);
|
||||
console.log(stringify(anyVar));
|
||||
```
|
||||
|
||||
|
||||
### stringifier.stringify(val, options)
|
||||
|
||||
For more simplified usage, `stringifier` has a function `stringify`, that simply takes target object/value and returns stringified result string. `stringifier.stringify` accepts `options` as optional parameter too.
|
||||
|
||||
```javascript
|
||||
var stringify = require('stringifier').stringify;
|
||||
console.log(stringify(anyVar));
|
||||
```
|
||||
|
||||
|
||||
INSTALL
|
||||
---------------------------------------
|
||||
|
||||
### via npm
|
||||
|
||||
Install
|
||||
|
||||
$ npm install --save stringifier
|
||||
|
||||
Use
|
||||
|
||||
```javascript
|
||||
var stringify = require('stringifier').stringify;
|
||||
console.log(stringify(anyVar));
|
||||
```
|
||||
|
||||
#### use stringifier npm module on browser
|
||||
|
||||
`stringifier` function is exported
|
||||
|
||||
<script type="text/javascript" src="./path/to/node_modules/stringifier/build/stringifier.js"></script>
|
||||
|
||||
|
||||
### via bower
|
||||
|
||||
Install
|
||||
|
||||
$ bower install --save stringifier
|
||||
|
||||
Load (`stringifier` function is exported)
|
||||
|
||||
<script type="text/javascript" src="./path/to/bower_components/stringifier/build/stringifier.js"></script>
|
||||
|
||||
Use
|
||||
|
||||
```javascript
|
||||
console.log(stringifier.stringify(anyVar));
|
||||
```
|
||||
|
||||
|
||||
EXAMPLE
|
||||
---------------------------------------
|
||||
|
||||
For given context,
|
||||
|
||||
```javascript
|
||||
var stringifier = require('stringifier'),
|
||||
assert = require('assert');
|
||||
|
||||
function Student (name, age, gender) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
var AnonStudent = function(name, age, gender) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.gender = gender;
|
||||
};
|
||||
|
||||
var student = new Student('tom', 10, 'M');
|
||||
var anonStudent = new AnonStudent('mary', 9, 'F');
|
||||
|
||||
var values = [
|
||||
'string',
|
||||
[null, undefined],
|
||||
{
|
||||
primitives: [true, false, -5, 98.6],
|
||||
specific: {
|
||||
regex: /^not/,
|
||||
numbers: [NaN, Infinity, -Infinity]
|
||||
},
|
||||
userDefined: [
|
||||
student,
|
||||
anonStudent
|
||||
]
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
|
||||
#### default single-line output
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier();
|
||||
console.log(stringify(values));
|
||||
```
|
||||
result:
|
||||
|
||||
```javascript
|
||||
["string",[null,undefined],Object{primitives:[true,false,-5,98.6],specific:Object{regex:/^not/,numbers:[NaN,Infinity,-Infinity]},userDefined:[Student{name:"tom",age:10,gender:"M"},@Anonymous{name:"mary",age:9,gender:"F"}]}]
|
||||
```
|
||||
|
||||
|
||||
#### pretty printing with indentation
|
||||
|
||||
Use `indent` option for pretty printing. Using four spaces for indentation in this case.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({indent: ' '});
|
||||
console.log(stringify(values));
|
||||
```
|
||||
|
||||
result:
|
||||
|
||||
```javascript
|
||||
[
|
||||
"string",
|
||||
[
|
||||
null,
|
||||
undefined
|
||||
],
|
||||
Object{
|
||||
primitives: [
|
||||
true,
|
||||
false,
|
||||
-5,
|
||||
98.6
|
||||
],
|
||||
specific: Object{
|
||||
regex: /^not/,
|
||||
numbers: [
|
||||
NaN,
|
||||
Infinity,
|
||||
-Infinity
|
||||
]
|
||||
},
|
||||
userDefined: [
|
||||
Student{
|
||||
name: "tom",
|
||||
age: 10,
|
||||
gender: "M"
|
||||
},
|
||||
@Anonymous{
|
||||
name: "mary",
|
||||
age: 9,
|
||||
gender: "F"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
#### depth limitation
|
||||
|
||||
Use `maxDepth` option to stringify at most specified levels.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({maxDepth: 3, indent: ' '});
|
||||
console.log(stringify(values));
|
||||
```
|
||||
|
||||
result:
|
||||
|
||||
```javascript
|
||||
[
|
||||
"string",
|
||||
[
|
||||
null,
|
||||
undefined
|
||||
],
|
||||
Object{
|
||||
primitives: [
|
||||
true,
|
||||
false,
|
||||
-5,
|
||||
98.6
|
||||
],
|
||||
specific: Object{
|
||||
regex: /^not/,
|
||||
numbers: #Array#
|
||||
},
|
||||
userDefined: [
|
||||
#Student#,
|
||||
#@Anonymous#
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
#### anonymous class label
|
||||
|
||||
Use `anonymous` option to specify alternate type name for anonymous constructors.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({anonymous: 'ANON'});
|
||||
assert(stringify(anonStudent) === 'ANON{name:"mary",age:9,gender:"F"}');
|
||||
```
|
||||
|
||||
|
||||
#### omit specific property from output
|
||||
|
||||
Customize `options.handlers`
|
||||
|
||||
```javascript
|
||||
var stringify;
|
||||
|
||||
// property whitelist and reordering
|
||||
stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object(null, ['gender', 'age'])
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{gender:"M",age:10}');
|
||||
|
||||
// blacklist by property name
|
||||
stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object(function (kvp) {
|
||||
return ['age', 'gender'].indexOf(kvp.key) === -1;
|
||||
})
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{name:"tom"}');
|
||||
|
||||
// blacklist by property value
|
||||
stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object(function (kvp) {
|
||||
return kvp.value !== 'M';
|
||||
})
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{name:"tom",age:10}');
|
||||
|
||||
// whitelist by property value
|
||||
stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object(function (kvp) {
|
||||
return typeName(kvp.value) === 'string';
|
||||
})
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{name:"tom",gender:"M"}');
|
||||
```
|
||||
|
||||
|
||||
#### truncate property value
|
||||
|
||||
Return number from object predicate
|
||||
|
||||
```javascript
|
||||
stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object(function (kvp) {
|
||||
if (kvp.key === 'name') {
|
||||
return 3;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{name:"to..(snip),age:10,gender:"M"}');
|
||||
```
|
||||
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
---------------------------------------
|
||||
|
||||
### options
|
||||
|
||||
|
||||
#### options.maxDepth
|
||||
Type: `number`
|
||||
Default value: `null`
|
||||
|
||||
Max depth for recursive Object tree traversal
|
||||
|
||||
|
||||
#### options.indent
|
||||
Type: `String`
|
||||
Default value: `null`
|
||||
|
||||
string value for indentation.
|
||||
If this value is not empty, stringified result may contain multiple lines.
|
||||
|
||||
|
||||
#### options.lineSeparator
|
||||
Type: `String`
|
||||
Default value: `'\n'`
|
||||
|
||||
string value for line-separator.
|
||||
Makes sense only if `options.indent` is not empty.
|
||||
|
||||
|
||||
#### options.anonymous
|
||||
Type: `String`
|
||||
Default value: `'@Anonymous'`
|
||||
|
||||
Type name string alternative for displaying Object created by anonymous constructor
|
||||
|
||||
|
||||
#### options.circular
|
||||
Type: `String`
|
||||
Default value: `'#@Circular#'`
|
||||
|
||||
Alternative string for displaying Circular reference
|
||||
|
||||
|
||||
#### options.snip
|
||||
Type: `String`
|
||||
Default value: `'..(snip)'`
|
||||
|
||||
For displaying truncated string
|
||||
|
||||
|
||||
#### options.handlers
|
||||
|
||||
`options.handlers` is a object where property names are type names (string, number, ...) and values are per-type stringify strategy functions. Various strategies are defined in `stringifier.strategies`, and default strategies are defined as follows.
|
||||
|
||||
```javascript
|
||||
var s = require('./strategies');
|
||||
function defaultHandlers () {
|
||||
return {
|
||||
'null': s.always('null'),
|
||||
'undefined': s.always('undefined'),
|
||||
'function': s.prune(),
|
||||
'string': s.json(),
|
||||
'boolean': s.json(),
|
||||
'number': s.number(),
|
||||
'symbol': s.toStr(),
|
||||
'RegExp': s.toStr(),
|
||||
'String': s.newLike(),
|
||||
'Boolean': s.newLike(),
|
||||
'Number': s.newLike(),
|
||||
'Date': s.newLike(),
|
||||
'Array': s.array(),
|
||||
'Object': s.object(),
|
||||
'Error': s.object(null, ['message', 'code']),
|
||||
'@default': s.object()
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
If unknown type is detected, strategy function registered by `'@default'` key will be used.
|
||||
|
||||
|
||||
### strategies
|
||||
|
||||
For given `Student` pseudo-class and a `stringifier`,
|
||||
|
||||
```javascript
|
||||
var stringifier = require('stringifier'),
|
||||
s = stringifier.strategies,
|
||||
assert = require('assert'),
|
||||
|
||||
function Student (name, age, gender) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
var student = new Student('tom', 10, 'M');
|
||||
```
|
||||
|
||||
#### always
|
||||
|
||||
`always` strategy always returns passed constant (In this case, `'foo'`).
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.always('foo')
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'foo');
|
||||
```
|
||||
|
||||
#### json
|
||||
|
||||
`json` strategy applies `JSON.stringify` to input value then return the result string.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.json()
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === '{"name":"tom","age":10,"gender":"M"}');
|
||||
```
|
||||
|
||||
#### toStr
|
||||
|
||||
`toStr` strategy calls `toString()` to input value then return the result string.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.toStr()
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === '[object Object]');
|
||||
```
|
||||
|
||||
#### prune
|
||||
|
||||
`prune` strategy does not serialize target value but returns target type name surrounded by `#`.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.prune()
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === '#Student#');
|
||||
```
|
||||
|
||||
#### newLike
|
||||
|
||||
`newLike` strategy emulates "new constructor call pattern".
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.newLike()
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'new Student({"name":"tom","age":10,"gender":"M"})');
|
||||
```
|
||||
|
||||
#### object
|
||||
|
||||
`object` strategy stringifies target object recursively and decorate object literal-like syntax with its type name. `object` is a default strategy for objects, and any other unknown types.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Student': s.object()
|
||||
}
|
||||
});
|
||||
assert(stringify(student) === 'Student{name:"tom",age:10,gender:"M"}');
|
||||
```
|
||||
|
||||
#### array
|
||||
|
||||
`array` strategy is an array specific stringification strategy, and is a default strategy for arrays.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Array': s.array()
|
||||
}
|
||||
});
|
||||
assert(stringify(['foo', 'bar', 'baz']) === '["foo","bar","baz"]');
|
||||
```
|
||||
|
||||
#### number
|
||||
|
||||
`number` strategy is a number specific stringification strategy, and is a default strategy for number. `number` strategy also provides `NaN`,`Infinity` and `-Infinity` handling.
|
||||
|
||||
```javascript
|
||||
var stringify = stringifier({
|
||||
handlers: {
|
||||
'Array': s.array(),
|
||||
'number': s.number()
|
||||
}
|
||||
});
|
||||
assert(stringify([NaN, 0, Infinity, -0, -Infinity]) === '[NaN,0,Infinity,0,-Infinity]');
|
||||
```
|
||||
|
||||
|
||||
AUTHOR
|
||||
---------------------------------------
|
||||
* [Takuto Wada](https://github.com/twada)
|
||||
|
||||
|
||||
LICENSE
|
||||
---------------------------------------
|
||||
Licensed under the [MIT](https://twada.mit-license.org/2014-2018) license.
|
||||
|
||||
|
||||
[travis-url]: https://travis-ci.org/twada/stringifier
|
||||
[travis-image]: https://secure.travis-ci.org/twada/stringifier.svg?branch=master
|
||||
|
||||
[npm-url]: https://npmjs.org/package/stringifier
|
||||
[npm-image]: https://badge.fury.io/js/stringifier.svg
|
||||
|
||||
[bower-url]: https://badge.fury.io/bo/stringifier
|
||||
[bower-image]: https://badge.fury.io/bo/stringifier.svg
|
||||
|
||||
[license-url]: https://twada.mit-license.org/2014-2018
|
||||
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg
|
1591
website/functions/node_modules/stringifier/build/stringifier.js
generated
vendored
Normal file
1591
website/functions/node_modules/stringifier/build/stringifier.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
112
website/functions/node_modules/stringifier/index.js
generated
vendored
Normal file
112
website/functions/node_modules/stringifier/index.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* stringifier
|
||||
*
|
||||
* https://github.com/twada/stringifier
|
||||
*
|
||||
* Copyright (c) 2014-2018 Takuto Wada
|
||||
* Licensed under the MIT license.
|
||||
* https://twada.mit-license.org/2014-2018
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var traverse = require('traverse');
|
||||
var typeName = require('type-name');
|
||||
var assign = require('core-js/library/fn/object/assign');
|
||||
var endsWith = require('core-js/library/fn/string/ends-with');
|
||||
var s = require('./strategies');
|
||||
|
||||
function defaultHandlers () {
|
||||
return {
|
||||
'null': s.always('null'),
|
||||
'undefined': s.always('undefined'),
|
||||
'function': s.prune(),
|
||||
'string': s.json(),
|
||||
'boolean': s.json(),
|
||||
'number': s.number(),
|
||||
'symbol': s.toStr(),
|
||||
'RegExp': s.toStr(),
|
||||
'String': s.newLike(),
|
||||
'Boolean': s.newLike(),
|
||||
'Number': s.newLike(),
|
||||
'Date': s.newLike(),
|
||||
'Array': s.array(),
|
||||
'Object': s.object(),
|
||||
'Error': s.object(null, ['message', 'code']),
|
||||
'@default': s.object()
|
||||
};
|
||||
}
|
||||
|
||||
function defaultOptions () {
|
||||
return {
|
||||
maxDepth: null,
|
||||
indent: null,
|
||||
anonymous: '@Anonymous',
|
||||
circular: '#@Circular#',
|
||||
snip: '..(snip)',
|
||||
lineSeparator: '\n',
|
||||
typeFun: typeName
|
||||
};
|
||||
}
|
||||
|
||||
function createStringifier (customOptions) {
|
||||
var options = assign({}, defaultOptions(), customOptions);
|
||||
var handlers = assign({}, defaultHandlers(), options.handlers);
|
||||
return function stringifyAny (push, x) {
|
||||
var context = this;
|
||||
var handler = handlerFor(context.node, options, handlers);
|
||||
var currentPath = '/' + context.path.join('/');
|
||||
var customization = handlers[currentPath];
|
||||
var acc = {
|
||||
context: context,
|
||||
options: options,
|
||||
handlers: handlers,
|
||||
push: push
|
||||
};
|
||||
if (typeName(customization) === 'function') {
|
||||
handler = customization;
|
||||
} else if (typeName(customization) === 'number') {
|
||||
handler = s.flow.compose(s.filters.truncate(customization),handler);
|
||||
} else if (context.parent && typeName(context.parent.node) === 'Array' && !(context.key in context.parent.node)) {
|
||||
// sparse arrays
|
||||
handler = s.always('');
|
||||
}
|
||||
handler(acc, x);
|
||||
return push;
|
||||
};
|
||||
}
|
||||
|
||||
function handlerFor (val, options, handlers) {
|
||||
var tname = options.typeFun(val);
|
||||
if (typeName(handlers[tname]) === 'function') {
|
||||
return handlers[tname];
|
||||
}
|
||||
if (endsWith(tname, 'Error')) {
|
||||
return handlers['Error'];
|
||||
}
|
||||
return handlers['@default'];
|
||||
}
|
||||
|
||||
function walk (val, reducer) {
|
||||
var buffer = [];
|
||||
var push = function (str) {
|
||||
buffer.push(str);
|
||||
};
|
||||
traverse(val).reduce(reducer, push);
|
||||
return buffer.join('');
|
||||
}
|
||||
|
||||
function stringify (val, options) {
|
||||
return walk(val, createStringifier(options));
|
||||
}
|
||||
|
||||
function stringifier (options) {
|
||||
return function (val) {
|
||||
return walk(val, createStringifier(options));
|
||||
};
|
||||
}
|
||||
|
||||
stringifier.stringify = stringify;
|
||||
stringifier.strategies = s;
|
||||
stringifier.defaultOptions = defaultOptions;
|
||||
stringifier.defaultHandlers = defaultHandlers;
|
||||
module.exports = stringifier;
|
86
website/functions/node_modules/stringifier/package.json
generated
vendored
Normal file
86
website/functions/node_modules/stringifier/package.json
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"_from": "stringifier@^1.3.0",
|
||||
"_id": "stringifier@1.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-cNsMOqqrcbLcHTXEVmkw9y0fwDwkdgtZwlfyolzpQDoAE1xdNGhQhxBUfiDvvZIKl1hnUEgMv66nHwtMz3OjPw==",
|
||||
"_location": "/stringifier",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "stringifier@^1.3.0",
|
||||
"name": "stringifier",
|
||||
"escapedName": "stringifier",
|
||||
"rawSpec": "^1.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/power-assert-renderer-comparison",
|
||||
"/power-assert-renderer-diagram"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/stringifier/-/stringifier-1.4.0.tgz",
|
||||
"_shasum": "d704581567f4526265d00ed8ecb354a02c3fec28",
|
||||
"_spec": "stringifier@^1.3.0",
|
||||
"_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\power-assert-renderer-comparison",
|
||||
"author": {
|
||||
"name": "Takuto Wada",
|
||||
"email": "takuto.wada@gmail.com",
|
||||
"url": "https://github.com/twada"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/twada/stringifier/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"core-js": "^2.0.0",
|
||||
"traverse": "^0.6.6",
|
||||
"type-name": "^2.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Yet another stringify function",
|
||||
"devDependencies": {
|
||||
"browserify": "^13.0.0",
|
||||
"del": "^2.0.2",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-derequire": "^2.1.0",
|
||||
"gulp-dereserve": "^0.2.1",
|
||||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-mocha-phantomjs": "^0.11.0",
|
||||
"gulp-util": "^3.0.6",
|
||||
"gulp-webserver": "^0.9.1",
|
||||
"licensify": "^3.1.0",
|
||||
"mocha": "^2.3.3",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
},
|
||||
"files": [
|
||||
"CHANGELOG.md",
|
||||
"README.md",
|
||||
"index.js",
|
||||
"strategies.js",
|
||||
"build/stringifier.js",
|
||||
"package.json"
|
||||
],
|
||||
"homepage": "https://github.com/twada/stringifier",
|
||||
"keywords": [
|
||||
"stringify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "stringifier",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/twada/stringifier.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bower": "bower install --config.interactive=false",
|
||||
"build": "npm prune && npm dedupe && gulp bundle",
|
||||
"es6": "./test/travis_es6.sh",
|
||||
"lint": "jshint index.js strategies.js",
|
||||
"preversion": "npm test",
|
||||
"test": "npm run es6 && gulp test",
|
||||
"unit": "npm run es6 && gulp unit",
|
||||
"version": "npm run build && git add -A build"
|
||||
},
|
||||
"version": "1.4.0"
|
||||
}
|
413
website/functions/node_modules/stringifier/strategies.js
generated
vendored
Normal file
413
website/functions/node_modules/stringifier/strategies.js
generated
vendored
Normal file
@@ -0,0 +1,413 @@
|
||||
'use strict';
|
||||
|
||||
var typeName = require('type-name');
|
||||
var forEach = require('core-js/library/fn/array/for-each');
|
||||
var arrayFilter = require('core-js/library/fn/array/filter');
|
||||
var reduceRight = require('core-js/library/fn/array/reduce-right');
|
||||
var indexOf = require('core-js/library/fn/array/index-of');
|
||||
var slice = Array.prototype.slice;
|
||||
var END = {};
|
||||
var ITERATE = {};
|
||||
|
||||
// arguments should end with end or iterate
|
||||
function compose () {
|
||||
var filters = slice.apply(arguments);
|
||||
return reduceRight(filters, function(right, left) {
|
||||
return left(right);
|
||||
});
|
||||
}
|
||||
|
||||
// skip children
|
||||
function end () {
|
||||
return function (acc, x) {
|
||||
acc.context.keys = [];
|
||||
return END;
|
||||
};
|
||||
}
|
||||
|
||||
// iterate children
|
||||
function iterate () {
|
||||
return function (acc, x) {
|
||||
return ITERATE;
|
||||
};
|
||||
}
|
||||
|
||||
function filter (predicate) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
var toBeIterated;
|
||||
var isIteratingArray = (typeName(x) === 'Array');
|
||||
if (typeName(predicate) === 'function') {
|
||||
toBeIterated = [];
|
||||
forEach(acc.context.keys, function (key) {
|
||||
var indexOrKey = isIteratingArray ? parseInt(key, 10) : key;
|
||||
var kvp = {
|
||||
key: indexOrKey,
|
||||
value: x[key]
|
||||
};
|
||||
var decision = predicate(kvp);
|
||||
if (decision) {
|
||||
toBeIterated.push(key);
|
||||
}
|
||||
if (typeName(decision) === 'number') {
|
||||
truncateByKey(decision, key, acc);
|
||||
}
|
||||
if (typeName(decision) === 'function') {
|
||||
customizeStrategyForKey(decision, key, acc);
|
||||
}
|
||||
});
|
||||
acc.context.keys = toBeIterated;
|
||||
}
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function customizeStrategyForKey (strategy, key, acc) {
|
||||
acc.handlers[currentPath(key, acc)] = strategy;
|
||||
}
|
||||
|
||||
function truncateByKey (size, key, acc) {
|
||||
acc.handlers[currentPath(key, acc)] = size;
|
||||
}
|
||||
|
||||
function currentPath (key, acc) {
|
||||
var pathToCurrentNode = [''].concat(acc.context.path);
|
||||
if (typeName(key) !== 'undefined') {
|
||||
pathToCurrentNode.push(key);
|
||||
}
|
||||
return pathToCurrentNode.join('/');
|
||||
}
|
||||
|
||||
function allowedKeys (orderedWhiteList) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
var isIteratingArray = (typeName(x) === 'Array');
|
||||
if (!isIteratingArray && typeName(orderedWhiteList) === 'Array') {
|
||||
acc.context.keys = arrayFilter(orderedWhiteList, function (propKey) {
|
||||
return x.hasOwnProperty(propKey);
|
||||
});
|
||||
}
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function safeKeys () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
if (typeName(x) !== 'Array') {
|
||||
acc.context.keys = arrayFilter(acc.context.keys, function (propKey) {
|
||||
// Error handling for unsafe property access.
|
||||
// For example, on PhantomJS,
|
||||
// accessing HTMLInputElement.selectionEnd causes TypeError
|
||||
try {
|
||||
var val = x[propKey];
|
||||
return true;
|
||||
} catch (e) {
|
||||
// skip unsafe key
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function arrayIndicesToKeys () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
if (typeName(x) === 'Array' && 0 < x.length) {
|
||||
var indices = Array(x.length);
|
||||
for(var i = 0; i < x.length; i += 1) {
|
||||
indices[i] = String(i); // traverse uses strings as keys
|
||||
}
|
||||
acc.context.keys = indices;
|
||||
}
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function when (guard, then) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
var kvp = {
|
||||
key: acc.context.key,
|
||||
value: x
|
||||
};
|
||||
if (guard(kvp, acc)) {
|
||||
return then(acc, x);
|
||||
}
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function truncate (size) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
var orig = acc.push;
|
||||
var ret;
|
||||
acc.push = function (str) {
|
||||
var savings = str.length - size;
|
||||
var truncated;
|
||||
if (savings <= size) {
|
||||
orig.call(acc, str);
|
||||
} else {
|
||||
truncated = str.substring(0, size);
|
||||
orig.call(acc, truncated + acc.options.snip);
|
||||
}
|
||||
};
|
||||
ret = next(acc, x);
|
||||
acc.push = orig;
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function constructorName () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
var name = acc.options.typeFun(x);
|
||||
if (name === '') {
|
||||
name = acc.options.anonymous;
|
||||
}
|
||||
acc.push(name);
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function always (str) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.push(str);
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function optionValue (key) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.push(acc.options[key]);
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function json (replacer) {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.push(JSON.stringify(x, replacer));
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function toStr () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.push(x.toString());
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function decorateArray () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.context.before(function (node) {
|
||||
acc.push('[');
|
||||
});
|
||||
acc.context.after(function (node) {
|
||||
afterAllChildren(this, acc.push, acc.options);
|
||||
acc.push(']');
|
||||
});
|
||||
acc.context.pre(function (val, key) {
|
||||
beforeEachChild(this, acc.push, acc.options);
|
||||
});
|
||||
acc.context.post(function (childContext) {
|
||||
afterEachChild(childContext, acc.push);
|
||||
});
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function decorateObject () {
|
||||
return function (next) {
|
||||
return function (acc, x) {
|
||||
acc.context.before(function (node) {
|
||||
acc.push('{');
|
||||
});
|
||||
acc.context.after(function (node) {
|
||||
afterAllChildren(this, acc.push, acc.options);
|
||||
acc.push('}');
|
||||
});
|
||||
acc.context.pre(function (val, key) {
|
||||
beforeEachChild(this, acc.push, acc.options);
|
||||
acc.push(sanitizeKey(key) + (acc.options.indent ? ': ' : ':'));
|
||||
});
|
||||
acc.context.post(function (childContext) {
|
||||
afterEachChild(childContext, acc.push);
|
||||
});
|
||||
return next(acc, x);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function sanitizeKey (key) {
|
||||
return /^[A-Za-z_]+$/.test(key) ? key : JSON.stringify(key);
|
||||
}
|
||||
|
||||
function afterAllChildren (context, push, options) {
|
||||
if (options.indent && 0 < context.keys.length) {
|
||||
push(options.lineSeparator);
|
||||
for(var i = 0; i < context.level; i += 1) { // indent level - 1
|
||||
push(options.indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function beforeEachChild (context, push, options) {
|
||||
if (options.indent) {
|
||||
push(options.lineSeparator);
|
||||
for(var i = 0; i <= context.level; i += 1) {
|
||||
push(options.indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterEachChild (childContext, push) {
|
||||
if (!childContext.isLast) {
|
||||
push(',');
|
||||
}
|
||||
}
|
||||
|
||||
function nan (kvp, acc) {
|
||||
return kvp.value !== kvp.value;
|
||||
}
|
||||
|
||||
function positiveInfinity (kvp, acc) {
|
||||
return !isFinite(kvp.value) && kvp.value === Infinity;
|
||||
}
|
||||
|
||||
function negativeInfinity (kvp, acc) {
|
||||
return !isFinite(kvp.value) && kvp.value !== Infinity;
|
||||
}
|
||||
|
||||
function circular (kvp, acc) {
|
||||
return acc.context.circular;
|
||||
}
|
||||
|
||||
function maxDepth (kvp, acc) {
|
||||
return (acc.options.maxDepth && acc.options.maxDepth <= acc.context.level);
|
||||
}
|
||||
|
||||
var prune = compose(
|
||||
always('#'),
|
||||
constructorName(),
|
||||
always('#'),
|
||||
end()
|
||||
);
|
||||
var omitNaN = when(nan, compose(
|
||||
always('NaN'),
|
||||
end()
|
||||
));
|
||||
var omitPositiveInfinity = when(positiveInfinity, compose(
|
||||
always('Infinity'),
|
||||
end()
|
||||
));
|
||||
var omitNegativeInfinity = when(negativeInfinity, compose(
|
||||
always('-Infinity'),
|
||||
end()
|
||||
));
|
||||
var omitCircular = when(circular, compose(
|
||||
optionValue('circular'),
|
||||
end()
|
||||
));
|
||||
var omitMaxDepth = when(maxDepth, prune);
|
||||
|
||||
module.exports = {
|
||||
filters: {
|
||||
always: always,
|
||||
optionValue: optionValue,
|
||||
constructorName: constructorName,
|
||||
json: json,
|
||||
toStr: toStr,
|
||||
prune: prune,
|
||||
truncate: truncate,
|
||||
decorateArray: decorateArray,
|
||||
decorateObject: decorateObject
|
||||
},
|
||||
flow: {
|
||||
compose: compose,
|
||||
when: when,
|
||||
allowedKeys: allowedKeys,
|
||||
safeKeys: safeKeys,
|
||||
arrayIndicesToKeys: arrayIndicesToKeys,
|
||||
filter: filter,
|
||||
iterate: iterate,
|
||||
end: end
|
||||
},
|
||||
symbols: {
|
||||
END: END,
|
||||
ITERATE: ITERATE
|
||||
},
|
||||
always: function (str) {
|
||||
return compose(always(str), end());
|
||||
},
|
||||
json: function () {
|
||||
return compose(json(), end());
|
||||
},
|
||||
toStr: function () {
|
||||
return compose(toStr(), end());
|
||||
},
|
||||
prune: function () {
|
||||
return prune;
|
||||
},
|
||||
number: function () {
|
||||
return compose(
|
||||
omitNaN,
|
||||
omitPositiveInfinity,
|
||||
omitNegativeInfinity,
|
||||
json(),
|
||||
end()
|
||||
);
|
||||
},
|
||||
newLike: function () {
|
||||
return compose(
|
||||
always('new '),
|
||||
constructorName(),
|
||||
always('('),
|
||||
json(),
|
||||
always(')'),
|
||||
end()
|
||||
);
|
||||
},
|
||||
array: function (predicate) {
|
||||
return compose(
|
||||
omitCircular,
|
||||
omitMaxDepth,
|
||||
decorateArray(),
|
||||
arrayIndicesToKeys(),
|
||||
filter(predicate),
|
||||
iterate()
|
||||
);
|
||||
},
|
||||
object: function (predicate, orderedWhiteList) {
|
||||
return compose(
|
||||
omitCircular,
|
||||
omitMaxDepth,
|
||||
constructorName(),
|
||||
decorateObject(),
|
||||
allowedKeys(orderedWhiteList),
|
||||
safeKeys(),
|
||||
filter(predicate),
|
||||
iterate()
|
||||
);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user