diff --git a/.eslintrc b/.eslintrc
index 9b16d51..ff3c67b 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -7,6 +7,7 @@
"es6": true
},
"rules": {
+ "code": 120,
"prettier/prettier": "error"
},
"globals": {}
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
index 0504489..97a3f82 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,5 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
- "printWidth": 80
+ "printWidth": 120
}
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 7006875..4985893 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -20,28 +20,28 @@ If you see someone who is making an extra effort to ensure our community is welc
The following behaviors are expected and requested of all community members:
-* Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
-* Exercise consideration and respect in your speech and actions.
-* Attempt collaboration before conflict.
-* Refrain from demeaning, discriminatory, or harassing behavior and speech.
-* Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
-* Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations.
+- Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
+- Exercise consideration and respect in your speech and actions.
+- Attempt collaboration before conflict.
+- Refrain from demeaning, discriminatory, or harassing behavior and speech.
+- Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
+- Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations.
## 4. Unacceptable Behavior
The following behaviors are considered harassment and are unacceptable within our community:
-* Violence, threats of violence or violent language directed against another person.
-* Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
-* Posting or displaying sexually explicit or violent material.
-* Posting or threatening to post other people’s personally identifying information ("doxing").
-* Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
-* Inappropriate photography or recording.
-* Inappropriate physical contact. You should have someone’s consent before touching them.
-* Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
-* Deliberate intimidation, stalking or following (online or in person).
-* Advocating for, or encouraging, any of the above behavior.
-* Sustained disruption of community events, including talks and presentations.
+- Violence, threats of violence or violent language directed against another person.
+- Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
+- Posting or displaying sexually explicit or violent material.
+- Posting or threatening to post other people’s personally identifying information ("doxing").
+- Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
+- Inappropriate photography or recording.
+- Inappropriate physical contact. You should have someone’s consent before touching them.
+- Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
+- Deliberate intimidation, stalking or following (online or in person).
+- Advocating for, or encouraging, any of the above behavior.
+- Sustained disruption of community events, including talks and presentations.
## 5. Consequences of Unacceptable Behavior
@@ -63,8 +63,6 @@ Additionally, community organizers are available to help community members engag
If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify Alexander Ivanov with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies.
-
-
## 8. Scope
We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues–online and in-person–as well as in all one-on-one communications pertaining to community business.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5c8e282..7bd2463 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,5 +3,5 @@
If you have something to add, go ahead.
Transparency and simplicity are supported as:
-* Short syllable in the main file (readme.md is fine)
-* Detailed description in issues (Its are fine too)
+- Short syllable in the main file (readme.md is fine)
+- Detailed description in issues (Its are fine too)
diff --git a/extra/hslToHex.js b/extra/hslToHex.js
index 6abcae3..cfbd99b 100644
--- a/extra/hslToHex.js
+++ b/extra/hslToHex.js
@@ -9,8 +9,8 @@
* @return {string} The HEX representation
*/
-var hslToHex = function(h, s, l) {
- var hue2rgb = function(p, q, t) {
+var hslToHex = function (h, s, l) {
+ var hue2rgb = function (p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
@@ -18,7 +18,7 @@ var hslToHex = function(h, s, l) {
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
};
- var toHex = function(x) {
+ var toHex = function (x) {
var hex = Math.round(x * 255).toString(16);
return hex.length === 1 ? '0' + hex : hex;
};
diff --git a/gulpfile.js b/gulpfile.js
index 282bfa8..8b294a0 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -12,9 +12,7 @@ const ms = require('merge-stream');
const packageJson = require('./package.json');
-const watchDelay =
- (packageJson.devSettings ? packageJson.devSettings.watchDelay : undefined) ||
- 1000;
+const watchDelay = (packageJson.devSettings ? packageJson.devSettings.watchDelay : undefined) || 1000;
gulp.task('br', function (done) {
// console.log('asdfsdf', path.normalize(`${process.cwd()}/`));
@@ -26,12 +24,7 @@ gulp.task('br', function (done) {
const config = JSON.parse(fs.readFileSync(path.join(snippet, 'config.json')));
console.log(snippet);
del.sync('./dist/');
- let src = [
- `${snippet}**/*.js`,
- `${snippet}**/*.ts`,
- `${snippet}**/*.html`,
- `${snippet}appsscript.json`,
- ];
+ let src = [`${snippet}**/*.js`, `${snippet}**/*.ts`, `${snippet}**/*.html`, `${snippet}appsscript.json`];
let claspConfig = '';
if (!config.type) throw new Error('USER CONFIG ERROR: type requeried');
if (config.type === 'single') claspConfig = `${snippet}.clasp.json`;
@@ -71,9 +64,7 @@ gulp.task('copy-sheet', function () {
.src('./templates/sheet_snippet/**/*.*', {
base: './templates/sheet_snippet',
})
- .pipe(
- gulp.dest(`./snippets/sheets/_auto_${arg.name || new Date().getTime()}`)
- );
+ .pipe(gulp.dest(`./snippets/sheets/_auto_${arg.name || new Date().getTime()}`));
});
gulp.task(
diff --git a/package-lock.json b/package-lock.json
index dcd24e6..cc7bfdd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,75 +9,88 @@
"version": "1.1.6-24",
"license": "MIT",
"dependencies": {
- "bootstrap": "^5.1.3",
+ "bootstrap": "^5.2.0",
"jaro-winkler": "^0.2.8",
"jquery": "^3.5.1",
- "jsonata": "^1.8.4",
+ "jsonata": "^1.8.6",
"xml-js": "^1.6.11"
},
"devDependencies": {
- "@babel/core": "^7.12.10",
- "@babel/preset-env": "^7.12.11",
- "@types/google-apps-script": "^1.0.20",
- "@types/lodash": "^4.14.165",
+ "@babel/core": "^7.18.10",
+ "@babel/preset-env": "^7.18.10",
+ "@types/google-apps-script": "^1.0.53",
+ "@types/lodash": "^4.14.182",
"babel-plugin-transform-es5-property-mutators": "^6.24.1",
- "del": "^6.0.0",
- "eslint": "^8.5.0",
+ "del": "^7.0.0",
+ "eslint": "^8.21.0",
"eslint-config-google": "^0.14.0",
- "eslint-config-prettier": "^8.1.0",
+ "eslint-config-prettier": "^8.5.0",
"eslint-plugin-googleappsscript": "^1.0.3",
- "eslint-plugin-prettier": "^4.0.0",
+ "eslint-plugin-prettier": "^4.2.1",
"forked-clasp": "^2.11.2",
- "got": "^12.0.0",
+ "got": "^12.3.0",
"gulp": "^4.0.2",
"gulp-file-include": "^2.3.0",
"merge-stream": "^2.0.0",
- "prettier": "^2.2.1",
- "uglify-js": "^3.13.10"
+ "prettier": "^2.7.1",
+ "uglify-js": "^3.16.3"
+ }
+ },
+ "node_modules/@ampproject/remapping": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz",
+ "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/gen-mapping": "^0.1.0",
+ "@jridgewell/trace-mapping": "^0.3.9"
+ },
+ "engines": {
+ "node": ">=6.0.0"
}
},
"node_modules/@babel/code-frame": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz",
- "integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
+ "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
"dev": true,
"dependencies": {
- "@babel/highlight": "^7.16.0"
+ "@babel/highlight": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/compat-data": {
- "version": "7.16.4",
- "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.16.4.tgz",
- "integrity": "sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.8.tgz",
+ "integrity": "sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/core": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.16.5.tgz",
- "integrity": "sha512-wUcenlLzuWMZ9Zt8S0KmFwGlH6QKRh3vsm/dhDA3CHkiTA45YuG1XkHRcNRl73EFPXDp/d5kVOU0/y7x2w6OaQ==",
- "dev": true,
- "dependencies": {
- "@babel/code-frame": "^7.16.0",
- "@babel/generator": "^7.16.5",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helpers": "^7.16.5",
- "@babel/parser": "^7.16.5",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.10.tgz",
+ "integrity": "sha512-JQM6k6ENcBFKVtWvLavlvi/mPcpYZ3+R+2EySDEMSMbp7Mn4FexlbbJVrx2R7Ijhr01T8gyqrOaABWIOgxeUyw==",
+ "dev": true,
+ "dependencies": {
+ "@ampproject/remapping": "^2.1.0",
+ "@babel/code-frame": "^7.18.6",
+ "@babel/generator": "^7.18.10",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-module-transforms": "^7.18.9",
+ "@babel/helpers": "^7.18.9",
+ "@babel/parser": "^7.18.10",
+ "@babel/template": "^7.18.10",
+ "@babel/traverse": "^7.18.10",
+ "@babel/types": "^7.18.10",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
- "json5": "^2.1.2",
- "semver": "^6.3.0",
- "source-map": "^0.5.0"
+ "json5": "^2.2.1",
+ "semver": "^6.3.0"
},
"engines": {
"node": ">=6.9.0"
@@ -88,53 +101,67 @@
}
},
"node_modules/@babel/generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.5.tgz",
- "integrity": "sha512-kIvCdjZqcdKqoDbVVdt5R99icaRtrtYhYK/xux5qiWCBmfdvEYMFZ68QCrpE5cbFM1JsuArUNs1ZkuKtTtUcZA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.10.tgz",
+ "integrity": "sha512-0+sW7e3HjQbiHbj1NeU/vN8ornohYlacAfZIaXhdoGweQqgcNy69COVciYYqEXJ/v+9OBA7Frxm4CVAuNqKeNA==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0",
- "jsesc": "^2.5.1",
- "source-map": "^0.5.0"
+ "@babel/types": "^7.18.10",
+ "@jridgewell/gen-mapping": "^0.3.2",
+ "jsesc": "^2.5.1"
},
"engines": {
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
+ "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/set-array": "^1.0.1",
+ "@jridgewell/sourcemap-codec": "^1.4.10",
+ "@jridgewell/trace-mapping": "^0.3.9"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/@babel/helper-annotate-as-pure": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.0.tgz",
- "integrity": "sha512-ItmYF9vR4zA8cByDocY05o0LGUkp1zhbTQOH1NFyl5xXEqlTJQCEJjieriw+aFpxo16swMxUnUiKS7a/r4vtHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz",
+ "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-builder-binary-assignment-operator-visitor": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.5.tgz",
- "integrity": "sha512-3JEA9G5dmmnIWdzaT9d0NmFRgYnWUThLsDaL7982H0XqqWr56lRrsmwheXFMjR+TMl7QMBb6mzy9kvgr1lRLUA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz",
+ "integrity": "sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw==",
"dev": true,
"dependencies": {
- "@babel/helper-explode-assignable-expression": "^7.16.0",
- "@babel/types": "^7.16.0"
+ "@babel/helper-explode-assignable-expression": "^7.18.6",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-compilation-targets": {
- "version": "7.16.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.3.tgz",
- "integrity": "sha512-vKsoSQAyBmxS35JUOOt+07cLc6Nk/2ljLIHwmq2/NM6hdioUaqEXq/S+nXvbvXbZkNDlWOymPanJGOc4CBjSJA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz",
+ "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==",
"dev": true,
"dependencies": {
- "@babel/compat-data": "^7.16.0",
- "@babel/helper-validator-option": "^7.14.5",
- "browserslist": "^4.17.5",
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-validator-option": "^7.18.6",
+ "browserslist": "^4.20.2",
"semver": "^6.3.0"
},
"engines": {
@@ -145,18 +172,18 @@
}
},
"node_modules/@babel/helper-create-class-features-plugin": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.16.5.tgz",
- "integrity": "sha512-NEohnYA7mkB8L5JhU7BLwcBdU3j83IziR9aseMueWGeAjblbul3zzb8UvJ3a1zuBiqCMObzCJHFqKIQE6hTVmg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz",
+ "integrity": "sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw==",
"dev": true,
"dependencies": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-member-expression-to-functions": "^7.16.5",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/helper-replace-supers": "^7.16.5",
- "@babel/helper-split-export-declaration": "^7.16.0"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-member-expression-to-functions": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/helper-replace-supers": "^7.18.9",
+ "@babel/helper-split-export-declaration": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -166,13 +193,13 @@
}
},
"node_modules/@babel/helper-create-regexp-features-plugin": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.16.0.tgz",
- "integrity": "sha512-3DyG0zAFAZKcOp7aVr33ddwkxJ0Z0Jr5V99y3I690eYLpukJsJvAbzTy1ewoCqsML8SbIrjH14Jc/nSQ4TvNPA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.18.6.tgz",
+ "integrity": "sha512-7LcpH1wnQLGrI+4v+nPp+zUvIkF9x0ddv1Hkdue10tg3gmRnLy97DXh4STiOf1qeIInyD69Qv5kKSZzKD8B/7A==",
"dev": true,
"dependencies": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "regexpu-core": "^4.7.1"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "regexpu-core": "^5.1.0"
},
"engines": {
"node": ">=6.9.0"
@@ -182,15 +209,13 @@
}
},
"node_modules/@babel/helper-define-polyfill-provider": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.0.tgz",
- "integrity": "sha512-7hfT8lUljl/tM3h+izTX/pO3W3frz2ok6Pk+gzys8iJqDfZrZy2pXjRTZAvG2YmfHun1X4q8/UZRLatMfqc5Tg==",
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.2.tgz",
+ "integrity": "sha512-r9QJJ+uDWrd+94BSPcP6/de67ygLtvVy6cK4luE6MOuDsZIdoaPBnfSpbO/+LTifjPckbKXRuI9BB/Z2/y3iTg==",
"dev": true,
"dependencies": {
- "@babel/helper-compilation-targets": "^7.13.0",
- "@babel/helper-module-imports": "^7.12.13",
- "@babel/helper-plugin-utils": "^7.13.0",
- "@babel/traverse": "^7.13.0",
+ "@babel/helper-compilation-targets": "^7.17.7",
+ "@babel/helper-plugin-utils": "^7.16.7",
"debug": "^4.1.1",
"lodash.debounce": "^4.0.8",
"resolve": "^1.14.2",
@@ -201,251 +226,248 @@
}
},
"node_modules/@babel/helper-environment-visitor": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.5.tgz",
- "integrity": "sha512-ODQyc5AnxmZWm/R2W7fzhamOk1ey8gSguo5SGvF0zcB3uUzRpTRmM/jmLSm9bDMyPlvbyJ+PwPEK0BWIoZ9wjg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz",
+ "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==",
"dev": true,
- "dependencies": {
- "@babel/types": "^7.16.0"
- },
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-explode-assignable-expression": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.0.tgz",
- "integrity": "sha512-Hk2SLxC9ZbcOhLpg/yMznzJ11W++lg5GMbxt1ev6TXUiJB0N42KPC+7w8a+eWGuqDnUYuwStJoZHM7RgmIOaGQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz",
+ "integrity": "sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-function-name": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.0.tgz",
- "integrity": "sha512-BZh4mEk1xi2h4HFjWUXRQX5AEx4rvaZxHgax9gcjdLWdkjsY7MKt5p0otjsg5noXw+pB+clMCjw+aEVYADMjog==",
- "dev": true,
- "dependencies": {
- "@babel/helper-get-function-arity": "^7.16.0",
- "@babel/template": "^7.16.0",
- "@babel/types": "^7.16.0"
- },
- "engines": {
- "node": ">=6.9.0"
- }
- },
- "node_modules/@babel/helper-get-function-arity": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.0.tgz",
- "integrity": "sha512-ASCquNcywC1NkYh/z7Cgp3w31YW8aojjYIlNg4VeJiHkqyP4AzIvr4qx7pYDb4/s8YcsZWqqOSxgkvjUz1kpDQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz",
+ "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/template": "^7.18.6",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-hoist-variables": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.0.tgz",
- "integrity": "sha512-1AZlpazjUR0EQZQv3sgRNfM9mEVWPK3M6vlalczA+EECcPz3XPh6VplbErL5UoMpChhSck5wAJHthlj1bYpcmg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz",
+ "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-member-expression-to-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.5.tgz",
- "integrity": "sha512-7fecSXq7ZrLE+TWshbGT+HyCLkxloWNhTbU2QM1NTI/tDqyf0oZiMcEfYtDuUDCo528EOlt39G1rftea4bRZIw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz",
+ "integrity": "sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-module-imports": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.0.tgz",
- "integrity": "sha512-kkH7sWzKPq0xt3H1n+ghb4xEMP8k0U7XV3kkB+ZGy69kDk2ySFW1qPi06sjKzFY3t1j6XbJSqr4mF9L7CYVyhg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz",
+ "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-module-transforms": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.16.5.tgz",
- "integrity": "sha512-CkvMxgV4ZyyioElFwcuWnDCcNIeyqTkCm9BxXZi73RR1ozqlpboqsbGUNvRTflgZtFbbJ1v5Emvm+lkjMYY/LQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz",
+ "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==",
"dev": true,
"dependencies": {
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-module-imports": "^7.16.0",
- "@babel/helper-simple-access": "^7.16.0",
- "@babel/helper-split-export-declaration": "^7.16.0",
- "@babel/helper-validator-identifier": "^7.15.7",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-module-imports": "^7.18.6",
+ "@babel/helper-simple-access": "^7.18.6",
+ "@babel/helper-split-export-declaration": "^7.18.6",
+ "@babel/helper-validator-identifier": "^7.18.6",
+ "@babel/template": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-optimise-call-expression": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.0.tgz",
- "integrity": "sha512-SuI467Gi2V8fkofm2JPnZzB/SUuXoJA5zXe/xzyPP2M04686RzFKFHPK6HDVN6JvWBIEW8tt9hPR7fXdn2Lgpw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz",
+ "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-plugin-utils": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.5.tgz",
- "integrity": "sha512-59KHWHXxVA9K4HNF4sbHCf+eJeFe0Te/ZFGqBT4OjXhrwvA04sGfaEGsVTdsjoszq0YTP49RC9UKe5g8uN2RwQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz",
+ "integrity": "sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-remap-async-to-generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.5.tgz",
- "integrity": "sha512-X+aAJldyxrOmN9v3FKp+Hu1NO69VWgYgDGq6YDykwRPzxs5f2N+X988CBXS7EQahDU+Vpet5QYMqLk+nsp+Qxw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz",
+ "integrity": "sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==",
"dev": true,
"dependencies": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-wrap-function": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-wrap-function": "^7.18.9",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0"
}
},
"node_modules/@babel/helper-replace-supers": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.5.tgz",
- "integrity": "sha512-ao3seGVa/FZCMCCNDuBcqnBFSbdr8N2EW35mzojx3TwfIbdPmNK+JV6+2d5bR0Z71W5ocLnQp9en/cTF7pBJiQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.18.9.tgz",
+ "integrity": "sha512-dNsWibVI4lNT6HiuOIBr1oyxo40HvIVmbwPUm3XZ7wMh4k2WxrxTqZwSqw/eEmXDS9np0ey5M2bz9tBmO9c+YQ==",
"dev": true,
"dependencies": {
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-member-expression-to-functions": "^7.16.5",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-member-expression-to-functions": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-simple-access": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.0.tgz",
- "integrity": "sha512-o1rjBT/gppAqKsYfUdfHq5Rk03lMQrkPHG1OWzHWpLgVXRH4HnMM9Et9CVdIqwkCQlobnGHEJMsgWP/jE1zUiw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz",
+ "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-skip-transparent-expression-wrappers": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz",
- "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.18.9.tgz",
+ "integrity": "sha512-imytd2gHi3cJPsybLRbmFrF7u5BIEuI2cNheyKi3/iOBC63kNn3q8Crn2xVuESli0aM4KYsyEqKyS7lFL8YVtw==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-split-export-declaration": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.0.tgz",
- "integrity": "sha512-0YMMRpuDFNGTHNRiiqJX19GjNXA4H0E8jZ2ibccfSxaCogbm3am5WN/2nQNj0YnQwGWM1J06GOcQ2qnh3+0paw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz",
+ "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==",
"dev": true,
"dependencies": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/helper-string-parser": {
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz",
+ "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/helper-validator-identifier": {
- "version": "7.15.7",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
- "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
+ "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-option": {
- "version": "7.14.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz",
- "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz",
+ "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-wrap-function": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.5.tgz",
- "integrity": "sha512-2J2pmLBqUqVdJw78U0KPNdeE2qeuIyKoG4mKV7wAq3mc4jJG282UgjZw4ZYDnqiWQuS3Y3IYdF/AQ6CpyBV3VA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.18.10.tgz",
+ "integrity": "sha512-95NLBP59VWdfK2lyLKe6eTMq9xg+yWKzxzxbJ1wcYNi1Auz200+83fMDADjRxBvc2QQor5zja2yTQzXGhk2GtQ==",
"dev": true,
"dependencies": {
- "@babel/helper-function-name": "^7.16.0",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/template": "^7.18.10",
+ "@babel/traverse": "^7.18.10",
+ "@babel/types": "^7.18.10"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helpers": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.5.tgz",
- "integrity": "sha512-TLgi6Lh71vvMZGEkFuIxzaPsyeYCHQ5jJOOX1f0xXn0uciFuE8cEk0wyBquMcCxBXZ5BJhE2aUB7pnWTD150Tw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz",
+ "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==",
"dev": true,
"dependencies": {
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/template": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/highlight": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz",
- "integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
+ "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
"dev": true,
"dependencies": {
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-validator-identifier": "^7.18.6",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
},
@@ -454,9 +476,9 @@
}
},
"node_modules/@babel/parser": {
- "version": "7.16.6",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.6.tgz",
- "integrity": "sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.10.tgz",
+ "integrity": "sha512-TYk3OA0HKL6qNryUayb5UUEhM/rkOQozIBEA5ITXh5DWrSp0TlUQXMyZmnWxG/DizSWBeeQ0Zbc5z8UGaaqoeg==",
"dev": true,
"bin": {
"parser": "bin/babel-parser.js"
@@ -466,12 +488,12 @@
}
},
"node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": {
- "version": "7.16.2",
- "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.2.tgz",
- "integrity": "sha512-h37CvpLSf8gb2lIJ2CgC3t+EjFbi0t8qS7LCS1xcJIlEXE4czlofwaW7W1HA8zpgOCzI9C1nmoqNR1zWkk0pQg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz",
+ "integrity": "sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.14.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -481,14 +503,14 @@
}
},
"node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.0.tgz",
- "integrity": "sha512-4tcFwwicpWTrpl9qjf7UsoosaArgImF85AxqCRZlgc3IQDvkUHjJpruXAL58Wmj+T6fypWTC/BakfEkwIL/pwA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.18.9.tgz",
+ "integrity": "sha512-AHrP9jadvH7qlOj6PINbgSuphjQUAK7AOT7DPjBo9EHoLhQTnnK5u45e1Hd4DbSQEO9nqPWtQ89r+XEOWFScKg==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.14.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0",
- "@babel/plugin-proposal-optional-chaining": "^7.16.0"
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9",
+ "@babel/plugin-proposal-optional-chaining": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -498,13 +520,14 @@
}
},
"node_modules/@babel/plugin-proposal-async-generator-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.5.tgz",
- "integrity": "sha512-C/FX+3HNLV6sz7AqbTQqEo1L9/kfrKjxcVtgyBCmvIgOjvuBVUWooDoi7trsLxOzCEo5FccjRvKHkfDsJFZlfA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.18.10.tgz",
+ "integrity": "sha512-1mFuY2TOsR1hxbjCo4QL+qlIjV07p4H4EUYw2J/WCqsvFV6V9X9z9YhXbWndc/4fw+hYGlDT7egYxliMp5O6Ew==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-remap-async-to-generator": "^7.16.5",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-remap-async-to-generator": "^7.18.9",
"@babel/plugin-syntax-async-generators": "^7.8.4"
},
"engines": {
@@ -515,13 +538,13 @@
}
},
"node_modules/@babel/plugin-proposal-class-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.5.tgz",
- "integrity": "sha512-pJD3HjgRv83s5dv1sTnDbZOaTjghKEz8KUn1Kbh2eAIRhGuyQ1XSeI4xVXU3UlIEVA3DAyIdxqT1eRn7Wcn55A==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz",
+ "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==",
"dev": true,
"dependencies": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -531,13 +554,13 @@
}
},
"node_modules/@babel/plugin-proposal-class-static-block": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.16.5.tgz",
- "integrity": "sha512-EEFzuLZcm/rNJ8Q5krK+FRKdVkd6FjfzT9tuSZql9sQn64K0hHA2KLJ0DqVot9/iV6+SsuadC5yI39zWnm+nmQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.18.6.tgz",
+ "integrity": "sha512-+I3oIiNxrCpup3Gi8n5IGMwj0gOCAjcJUSQEcotNnCCPMEnixawOQ+KeJPlgfjzx+FKQ1QSyZOWe7wmoJp7vhw==",
"dev": true,
"dependencies": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-class-static-block": "^7.14.5"
},
"engines": {
@@ -548,12 +571,12 @@
}
},
"node_modules/@babel/plugin-proposal-dynamic-import": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.5.tgz",
- "integrity": "sha512-P05/SJZTTvHz79LNYTF8ff5xXge0kk5sIIWAypcWgX4BTRUgyHc8wRxJ/Hk+mU0KXldgOOslKaeqnhthcDJCJQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz",
+ "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
},
"engines": {
@@ -564,12 +587,12 @@
}
},
"node_modules/@babel/plugin-proposal-export-namespace-from": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.5.tgz",
- "integrity": "sha512-i+sltzEShH1vsVydvNaTRsgvq2vZsfyrd7K7vPLUU/KgS0D5yZMe6uipM0+izminnkKrEfdUnz7CxMRb6oHZWw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz",
+ "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3"
},
"engines": {
@@ -580,12 +603,12 @@
}
},
"node_modules/@babel/plugin-proposal-json-strings": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.5.tgz",
- "integrity": "sha512-QQJueTFa0y9E4qHANqIvMsuxM/qcLQmKttBACtPCQzGUEizsXDACGonlPiSwynHfOa3vNw0FPMVvQzbuXwh4SQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz",
+ "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-json-strings": "^7.8.3"
},
"engines": {
@@ -596,12 +619,12 @@
}
},
"node_modules/@babel/plugin-proposal-logical-assignment-operators": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.5.tgz",
- "integrity": "sha512-xqibl7ISO2vjuQM+MzR3rkd0zfNWltk7n9QhaD8ghMmMceVguYrNDt7MikRyj4J4v3QehpnrU8RYLnC7z/gZLA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.18.9.tgz",
+ "integrity": "sha512-128YbMpjCrP35IOExw2Fq+x55LMP42DzhOhX2aNNIdI9avSWl2PI0yuBWarr3RYpZBSPtabfadkH2yeRiMD61Q==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4"
},
"engines": {
@@ -612,12 +635,12 @@
}
},
"node_modules/@babel/plugin-proposal-nullish-coalescing-operator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.5.tgz",
- "integrity": "sha512-YwMsTp/oOviSBhrjwi0vzCUycseCYwoXnLiXIL3YNjHSMBHicGTz7GjVU/IGgz4DtOEXBdCNG72pvCX22ehfqg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
+ "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
},
"engines": {
@@ -628,12 +651,12 @@
}
},
"node_modules/@babel/plugin-proposal-numeric-separator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.5.tgz",
- "integrity": "sha512-DvB9l/TcsCRvsIV9v4jxR/jVP45cslTVC0PMVHvaJhhNuhn2Y1SOhCSFlPK777qLB5wb8rVDaNoqMTyOqtY5Iw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz",
+ "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-numeric-separator": "^7.10.4"
},
"engines": {
@@ -644,16 +667,16 @@
}
},
"node_modules/@babel/plugin-proposal-object-rest-spread": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.16.5.tgz",
- "integrity": "sha512-UEd6KpChoyPhCoE840KRHOlGhEZFutdPDMGj+0I56yuTTOaT51GzmnEl/0uT41fB/vD2nT+Pci2KjezyE3HmUw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.18.9.tgz",
+ "integrity": "sha512-kDDHQ5rflIeY5xl69CEqGEZ0KY369ehsCIEbTGb4siHG5BE9sga/T0r0OUwyZNLMmZE79E1kbsqAjwFCW4ds6Q==",
"dev": true,
"dependencies": {
- "@babel/compat-data": "^7.16.4",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
- "@babel/plugin-transform-parameters": "^7.16.5"
+ "@babel/plugin-transform-parameters": "^7.18.8"
},
"engines": {
"node": ">=6.9.0"
@@ -663,12 +686,12 @@
}
},
"node_modules/@babel/plugin-proposal-optional-catch-binding": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.5.tgz",
- "integrity": "sha512-ihCMxY1Iljmx4bWy/PIMJGXN4NS4oUj1MKynwO07kiKms23pNvIn1DMB92DNB2R0EA882sw0VXIelYGdtF7xEQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz",
+ "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3"
},
"engines": {
@@ -679,13 +702,13 @@
}
},
"node_modules/@babel/plugin-proposal-optional-chaining": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.5.tgz",
- "integrity": "sha512-kzdHgnaXRonttiTfKYnSVafbWngPPr2qKw9BWYBESl91W54e+9R5pP70LtWxV56g0f05f/SQrwHYkfvbwcdQ/A==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.18.9.tgz",
+ "integrity": "sha512-v5nwt4IqBXihxGsW2QmCWMDS3B3bzGIk/EQVZz2ei7f3NJl8NzAJVvUmpDW5q1CRNY+Beb/k58UAH1Km1N411w==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9",
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
},
"engines": {
@@ -696,13 +719,13 @@
}
},
"node_modules/@babel/plugin-proposal-private-methods": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.5.tgz",
- "integrity": "sha512-+yFMO4BGT3sgzXo+lrq7orX5mAZt57DwUK6seqII6AcJnJOIhBJ8pzKH47/ql/d426uQ7YhN8DpUFirQzqYSUA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz",
+ "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==",
"dev": true,
"dependencies": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -712,14 +735,14 @@
}
},
"node_modules/@babel/plugin-proposal-private-property-in-object": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.5.tgz",
- "integrity": "sha512-+YGh5Wbw0NH3y/E5YMu6ci5qTDmAEVNoZ3I54aB6nVEOZ5BQ7QJlwKq5pYVucQilMByGn/bvX0af+uNaPRCabA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.18.6.tgz",
+ "integrity": "sha512-9Rysx7FOctvT5ouj5JODjAFAkgGoudQuLPamZb0v1TGLpapdNaftzifU8NTWQm0IRjqoYypdrSmyWgkocDQ8Dw==",
"dev": true,
"dependencies": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5"
},
"engines": {
@@ -730,13 +753,13 @@
}
},
"node_modules/@babel/plugin-proposal-unicode-property-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.5.tgz",
- "integrity": "sha512-s5sKtlKQyFSatt781HQwv1hoM5BQ9qRH30r+dK56OLDsHmV74mzwJNX7R1yMuE7VZKG5O6q/gmOGSAO6ikTudg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz",
+ "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==",
"dev": true,
"dependencies": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=4"
@@ -808,6 +831,21 @@
"@babel/core": "^7.0.0-0"
}
},
+ "node_modules/@babel/plugin-syntax-import-assertions": {
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.18.6.tgz",
+ "integrity": "sha512-/DU3RXad9+bZwrgWJQKbr39gYbJpLJHezqEzRzi/BHRlJ9zsQb4CK2CA/5apllXNomwA1qHwzvHl+AdEmC5krQ==",
+ "dev": true,
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.18.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
"node_modules/@babel/plugin-syntax-json-strings": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz",
@@ -923,12 +961,12 @@
}
},
"node_modules/@babel/plugin-transform-arrow-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.5.tgz",
- "integrity": "sha512-8bTHiiZyMOyfZFULjsCnYOWG059FVMes0iljEHSfARhNgFfpsqE92OrCffv3veSw9rwMkYcFe9bj0ZoXU2IGtQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz",
+ "integrity": "sha512-9S9X9RUefzrsHZmKMbDXxweEH+YlE8JJEuat9FdvW9Qh1cw7W64jELCtWNkPBPX5En45uy28KGvA/AySqUh8CQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -938,14 +976,14 @@
}
},
"node_modules/@babel/plugin-transform-async-to-generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.5.tgz",
- "integrity": "sha512-TMXgfioJnkXU+XRoj7P2ED7rUm5jbnDWwlCuFVTpQboMfbSya5WrmubNBAMlk7KXvywpo8rd8WuYZkis1o2H8w==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.18.6.tgz",
+ "integrity": "sha512-ARE5wZLKnTgPW7/1ftQmSi1CmkqqHo2DNmtztFhvgtOWSDfq0Cq9/9L+KnZNYSNrydBekhW3rwShduf59RoXag==",
"dev": true,
"dependencies": {
- "@babel/helper-module-imports": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-remap-async-to-generator": "^7.16.5"
+ "@babel/helper-module-imports": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-remap-async-to-generator": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -955,12 +993,12 @@
}
},
"node_modules/@babel/plugin-transform-block-scoped-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.5.tgz",
- "integrity": "sha512-BxmIyKLjUGksJ99+hJyL/HIxLIGnLKtw772zYDER7UuycDZ+Xvzs98ZQw6NGgM2ss4/hlFAaGiZmMNKvValEjw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz",
+ "integrity": "sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -970,12 +1008,12 @@
}
},
"node_modules/@babel/plugin-transform-block-scoping": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.5.tgz",
- "integrity": "sha512-JxjSPNZSiOtmxjX7PBRBeRJTUKTyJ607YUYeT0QJCNdsedOe+/rXITjP08eG8xUpsLfPirgzdCFN+h0w6RI+pQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.18.9.tgz",
+ "integrity": "sha512-5sDIJRV1KtQVEbt/EIBwGy4T01uYIo4KRB3VUqzkhrAIOGx7AoctL9+Ux88btY0zXdDyPJ9mW+bg+v+XEkGmtw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -985,18 +1023,18 @@
}
},
"node_modules/@babel/plugin-transform-classes": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.5.tgz",
- "integrity": "sha512-DzJ1vYf/7TaCYy57J3SJ9rV+JEuvmlnvvyvYKFbk5u46oQbBvuB9/0w+YsVsxkOv8zVWKpDmUoj4T5ILHoXevA==",
- "dev": true,
- "dependencies": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-replace-supers": "^7.16.5",
- "@babel/helper-split-export-declaration": "^7.16.0",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.18.9.tgz",
+ "integrity": "sha512-EkRQxsxoytpTlKJmSPYrsOMjCILacAjtSVkd4gChEe2kXjFCun3yohhW5I7plXJhCemM0gKsaGMcO8tinvCA5g==",
+ "dev": true,
+ "dependencies": {
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-replace-supers": "^7.18.9",
+ "@babel/helper-split-export-declaration": "^7.18.6",
"globals": "^11.1.0"
},
"engines": {
@@ -1007,12 +1045,12 @@
}
},
"node_modules/@babel/plugin-transform-computed-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.5.tgz",
- "integrity": "sha512-n1+O7xtU5lSLraRzX88CNcpl7vtGdPakKzww74bVwpAIRgz9JVLJJpOLb0uYqcOaXVM0TL6X0RVeIJGD2CnCkg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.18.9.tgz",
+ "integrity": "sha512-+i0ZU1bCDymKakLxn5srGHrsAPRELC2WIbzwjLhHW9SIE1cPYkLCL0NlnXMZaM1vhfgA2+M7hySk42VBvrkBRw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1022,12 +1060,12 @@
}
},
"node_modules/@babel/plugin-transform-destructuring": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.16.5.tgz",
- "integrity": "sha512-GuRVAsjq+c9YPK6NeTkRLWyQskDC099XkBSVO+6QzbnOnH2d/4mBVXYStaPrZD3dFRfg00I6BFJ9Atsjfs8mlg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.18.9.tgz",
+ "integrity": "sha512-p5VCYNddPLkZTq4XymQIaIfZNJwT9YsjkPOhkVEqt6QIpQFZVM9IltqqYpOEkJoN1DPznmxUDyZ5CTZs/ZCuHA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1037,13 +1075,13 @@
}
},
"node_modules/@babel/plugin-transform-dotall-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.5.tgz",
- "integrity": "sha512-iQiEMt8Q4/5aRGHpGVK2Zc7a6mx7qEAO7qehgSug3SDImnuMzgmm/wtJALXaz25zUj1PmnNHtShjFgk4PDx4nw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz",
+ "integrity": "sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg==",
"dev": true,
"dependencies": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1053,12 +1091,12 @@
}
},
"node_modules/@babel/plugin-transform-duplicate-keys": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.5.tgz",
- "integrity": "sha512-81tijpDg2a6I1Yhj4aWY1l3O1J4Cg/Pd7LfvuaH2VVInAkXtzibz9+zSPdUM1WvuUi128ksstAP0hM5w48vQgg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz",
+ "integrity": "sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1068,13 +1106,13 @@
}
},
"node_modules/@babel/plugin-transform-exponentiation-operator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.5.tgz",
- "integrity": "sha512-12rba2HwemQPa7BLIKCzm1pT2/RuQHtSFHdNl41cFiC6oi4tcrp7gjB07pxQvFpcADojQywSjblQth6gJyE6CA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz",
+ "integrity": "sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw==",
"dev": true,
"dependencies": {
- "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-builder-binary-assignment-operator-visitor": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1084,12 +1122,12 @@
}
},
"node_modules/@babel/plugin-transform-for-of": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.5.tgz",
- "integrity": "sha512-+DpCAJFPAvViR17PIMi9x2AE34dll5wNlXO43wagAX2YcRGgEVHCNFC4azG85b4YyyFarvkc/iD5NPrz4Oneqw==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.18.8.tgz",
+ "integrity": "sha512-yEfTRnjuskWYo0k1mHUqrVWaZwrdq8AYbfrpqULOJOaucGSp4mNMVps+YtA8byoevxS/urwU75vyhQIxcCgiBQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1099,13 +1137,14 @@
}
},
"node_modules/@babel/plugin-transform-function-name": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.5.tgz",
- "integrity": "sha512-Fuec/KPSpVLbGo6z1RPw4EE1X+z9gZk1uQmnYy7v4xr4TO9p41v1AoUuXEtyqAI7H+xNJYSICzRqZBhDEkd3kQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz",
+ "integrity": "sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ==",
"dev": true,
"dependencies": {
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1115,12 +1154,12 @@
}
},
"node_modules/@babel/plugin-transform-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.5.tgz",
- "integrity": "sha512-B1j9C/IfvshnPcklsc93AVLTrNVa69iSqztylZH6qnmiAsDDOmmjEYqOm3Ts2lGSgTSywnBNiqC949VdD0/gfw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz",
+ "integrity": "sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1130,12 +1169,12 @@
}
},
"node_modules/@babel/plugin-transform-member-expression-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.5.tgz",
- "integrity": "sha512-d57i3vPHWgIde/9Y8W/xSFUndhvhZN5Wu2TjRrN1MVz5KzdUihKnfDVlfP1U7mS5DNj/WHHhaE4/tTi4hIyHwQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz",
+ "integrity": "sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1145,13 +1184,13 @@
}
},
"node_modules/@babel/plugin-transform-modules-amd": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.5.tgz",
- "integrity": "sha512-oHI15S/hdJuSCfnwIz+4lm6wu/wBn7oJ8+QrkzPPwSFGXk8kgdI/AIKcbR/XnD1nQVMg/i6eNaXpszbGuwYDRQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.18.6.tgz",
+ "integrity": "sha512-Pra5aXsmTsOnjM3IajS8rTaLCy++nGM4v3YR4esk5PCsyg9z8NA5oQLwxzMUtDBd8F+UmVza3VxoAaWCbzH1rg==",
"dev": true,
"dependencies": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
},
"engines": {
@@ -1162,14 +1201,14 @@
}
},
"node_modules/@babel/plugin-transform-modules-commonjs": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.5.tgz",
- "integrity": "sha512-ABhUkxvoQyqhCWyb8xXtfwqNMJD7tx+irIRnUh6lmyFud7Jln1WzONXKlax1fg/ey178EXbs4bSGNd6PngO+SQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.18.6.tgz",
+ "integrity": "sha512-Qfv2ZOWikpvmedXQJDSbxNqy7Xr/j2Y8/KfijM0iJyKkBTmWuvCA1yeH1yDM7NJhBW/2aXxeucLj6i80/LAJ/Q==",
"dev": true,
"dependencies": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-simple-access": "^7.16.0",
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-simple-access": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
},
"engines": {
@@ -1180,15 +1219,15 @@
}
},
"node_modules/@babel/plugin-transform-modules-systemjs": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.5.tgz",
- "integrity": "sha512-53gmLdScNN28XpjEVIm7LbWnD/b/TpbwKbLk6KV4KqC9WyU6rq1jnNmVG6UgAdQZVVGZVoik3DqHNxk4/EvrjA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.9.tgz",
+ "integrity": "sha512-zY/VSIbbqtoRoJKo2cDTewL364jSlZGvn0LKOf9ntbfxOvjfmyrdtEEOAdswOswhZEb8UH3jDkCKHd1sPgsS0A==",
"dev": true,
"dependencies": {
- "@babel/helper-hoist-variables": "^7.16.0",
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-hoist-variables": "^7.18.6",
+ "@babel/helper-module-transforms": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-validator-identifier": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
},
"engines": {
@@ -1199,13 +1238,13 @@
}
},
"node_modules/@babel/plugin-transform-modules-umd": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.5.tgz",
- "integrity": "sha512-qTFnpxHMoenNHkS3VoWRdwrcJ3FhX567GvDA3hRZKF0Dj8Fmg0UzySZp3AP2mShl/bzcywb/UWAMQIjA1bhXvw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz",
+ "integrity": "sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ==",
"dev": true,
"dependencies": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1215,12 +1254,13 @@
}
},
"node_modules/@babel/plugin-transform-named-capturing-groups-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.5.tgz",
- "integrity": "sha512-/wqGDgvFUeKELW6ex6QB7dLVRkd5ehjw34tpXu1nhKC0sFfmaLabIswnpf8JgDyV2NeDmZiwoOb0rAmxciNfjA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.18.6.tgz",
+ "integrity": "sha512-UmEOGF8XgaIqD74bC8g7iV3RYj8lMf0Bw7NJzvnS9qQhM4mg+1WHKotUIdjxgD2RGrgFLZZPCFPFj3P/kVDYhg==",
"dev": true,
"dependencies": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1230,12 +1270,12 @@
}
},
"node_modules/@babel/plugin-transform-new-target": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.5.tgz",
- "integrity": "sha512-ZaIrnXF08ZC8jnKR4/5g7YakGVL6go6V9ql6Jl3ecO8PQaQqFE74CuM384kezju7Z9nGCCA20BqZaR1tJ/WvHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz",
+ "integrity": "sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1245,13 +1285,13 @@
}
},
"node_modules/@babel/plugin-transform-object-super": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.5.tgz",
- "integrity": "sha512-tded+yZEXuxt9Jdtkc1RraW1zMF/GalVxaVVxh41IYwirdRgyAxxxCKZ9XB7LxZqmsjfjALxupNE1MIz9KH+Zg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz",
+ "integrity": "sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-replace-supers": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-replace-supers": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1261,12 +1301,12 @@
}
},
"node_modules/@babel/plugin-transform-parameters": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.5.tgz",
- "integrity": "sha512-B3O6AL5oPop1jAVg8CV+haeUte9oFuY85zu0jwnRNZZi3tVAbJriu5tag/oaO2kGaQM/7q7aGPBlTI5/sr9enA==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.18.8.tgz",
+ "integrity": "sha512-ivfbE3X2Ss+Fj8nnXvKJS6sjRG4gzwPMsP+taZC+ZzEGjAYlvENixmt1sZ5Ca6tWls+BlKSGKPJ6OOXvXCbkFg==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1276,12 +1316,12 @@
}
},
"node_modules/@babel/plugin-transform-property-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.5.tgz",
- "integrity": "sha512-+IRcVW71VdF9pEH/2R/Apab4a19LVvdVsr/gEeotH00vSDVlKD+XgfSIw+cgGWsjDB/ziqGv/pGoQZBIiQVXHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz",
+ "integrity": "sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1291,12 +1331,13 @@
}
},
"node_modules/@babel/plugin-transform-regenerator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.5.tgz",
- "integrity": "sha512-2z+it2eVWU8TtQQRauvGUqZwLy4+7rTfo6wO4npr+fvvN1SW30ZF3O/ZRCNmTuu4F5MIP8OJhXAhRV5QMJOuYg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz",
+ "integrity": "sha512-poqRI2+qiSdeldcz4wTSTXBRryoq3Gc70ye7m7UD5Ww0nE29IXqMl6r7Nd15WBgRd74vloEMlShtH6CKxVzfmQ==",
"dev": true,
"dependencies": {
- "regenerator-transform": "^0.14.2"
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "regenerator-transform": "^0.15.0"
},
"engines": {
"node": ">=6.9.0"
@@ -1306,12 +1347,12 @@
}
},
"node_modules/@babel/plugin-transform-reserved-words": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.5.tgz",
- "integrity": "sha512-aIB16u8lNcf7drkhXJRoggOxSTUAuihTSTfAcpynowGJOZiGf+Yvi7RuTwFzVYSYPmWyARsPqUGoZWWWxLiknw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz",
+ "integrity": "sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1321,12 +1362,12 @@
}
},
"node_modules/@babel/plugin-transform-shorthand-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.5.tgz",
- "integrity": "sha512-ZbuWVcY+MAXJuuW7qDoCwoxDUNClfZxoo7/4swVbOW1s/qYLOMHlm9YRWMsxMFuLs44eXsv4op1vAaBaBaDMVg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz",
+ "integrity": "sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1336,13 +1377,13 @@
}
},
"node_modules/@babel/plugin-transform-spread": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.5.tgz",
- "integrity": "sha512-5d6l/cnG7Lw4tGHEoga4xSkYp1euP7LAtrah1h1PgJ3JY7yNsjybsxQAnVK4JbtReZ/8z6ASVmd3QhYYKLaKZw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.18.9.tgz",
+ "integrity": "sha512-39Q814wyoOPtIB/qGopNIL9xDChOE1pNU0ZY5dO0owhiVt/5kFm4li+/bBtwc7QotG0u5EPzqhZdjMtmqBqyQA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0"
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1352,12 +1393,12 @@
}
},
"node_modules/@babel/plugin-transform-sticky-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.5.tgz",
- "integrity": "sha512-usYsuO1ID2LXxzuUxifgWtJemP7wL2uZtyrTVM4PKqsmJycdS4U4mGovL5xXkfUheds10Dd2PjoQLXw6zCsCbg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz",
+ "integrity": "sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1367,12 +1408,12 @@
}
},
"node_modules/@babel/plugin-transform-template-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.5.tgz",
- "integrity": "sha512-gnyKy9RyFhkovex4BjKWL3BVYzUDG6zC0gba7VMLbQoDuqMfJ1SDXs8k/XK41Mmt1Hyp4qNAvGFb9hKzdCqBRQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz",
+ "integrity": "sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1382,12 +1423,12 @@
}
},
"node_modules/@babel/plugin-transform-typeof-symbol": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.5.tgz",
- "integrity": "sha512-ldxCkW180qbrvyCVDzAUZqB0TAeF8W/vGJoRcaf75awm6By+PxfJKvuqVAnq8N9wz5Xa6mSpM19OfVKKVmGHSQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz",
+ "integrity": "sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1397,12 +1438,12 @@
}
},
"node_modules/@babel/plugin-transform-unicode-escapes": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.5.tgz",
- "integrity": "sha512-shiCBHTIIChGLdyojsKQjoAyB8MBwat25lKM7MJjbe1hE0bgIppD+LX9afr41lLHOhqceqeWl4FkLp+Bgn9o1Q==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz",
+ "integrity": "sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ==",
"dev": true,
"dependencies": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
},
"engines": {
"node": ">=6.9.0"
@@ -1412,13 +1453,13 @@
}
},
"node_modules/@babel/plugin-transform-unicode-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.5.tgz",
- "integrity": "sha512-GTJ4IW012tiPEMMubd7sD07iU9O/LOo8Q/oU4xNhcaq0Xn8+6TcUQaHtC8YxySo1T+ErQ8RaWogIEeFhKGNPzw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz",
+ "integrity": "sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA==",
"dev": true,
"dependencies": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
@@ -1428,37 +1469,38 @@
}
},
"node_modules/@babel/preset-env": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.5.tgz",
- "integrity": "sha512-MiJJW5pwsktG61NDxpZ4oJ1CKxM1ncam9bzRtx9g40/WkLRkxFP6mhpkYV0/DxcciqoiHicx291+eUQrXb/SfQ==",
- "dev": true,
- "dependencies": {
- "@babel/compat-data": "^7.16.4",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-validator-option": "^7.14.5",
- "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.2",
- "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.0",
- "@babel/plugin-proposal-async-generator-functions": "^7.16.5",
- "@babel/plugin-proposal-class-properties": "^7.16.5",
- "@babel/plugin-proposal-class-static-block": "^7.16.5",
- "@babel/plugin-proposal-dynamic-import": "^7.16.5",
- "@babel/plugin-proposal-export-namespace-from": "^7.16.5",
- "@babel/plugin-proposal-json-strings": "^7.16.5",
- "@babel/plugin-proposal-logical-assignment-operators": "^7.16.5",
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
- "@babel/plugin-proposal-numeric-separator": "^7.16.5",
- "@babel/plugin-proposal-object-rest-spread": "^7.16.5",
- "@babel/plugin-proposal-optional-catch-binding": "^7.16.5",
- "@babel/plugin-proposal-optional-chaining": "^7.16.5",
- "@babel/plugin-proposal-private-methods": "^7.16.5",
- "@babel/plugin-proposal-private-property-in-object": "^7.16.5",
- "@babel/plugin-proposal-unicode-property-regex": "^7.16.5",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.18.10.tgz",
+ "integrity": "sha512-wVxs1yjFdW3Z/XkNfXKoblxoHgbtUF7/l3PvvP4m02Qz9TZ6uZGxRVYjSQeR87oQmHco9zWitW5J82DJ7sCjvA==",
+ "dev": true,
+ "dependencies": {
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-validator-option": "^7.18.6",
+ "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6",
+ "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9",
+ "@babel/plugin-proposal-async-generator-functions": "^7.18.10",
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
+ "@babel/plugin-proposal-class-static-block": "^7.18.6",
+ "@babel/plugin-proposal-dynamic-import": "^7.18.6",
+ "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
+ "@babel/plugin-proposal-json-strings": "^7.18.6",
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9",
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
+ "@babel/plugin-proposal-numeric-separator": "^7.18.6",
+ "@babel/plugin-proposal-object-rest-spread": "^7.18.9",
+ "@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
+ "@babel/plugin-proposal-optional-chaining": "^7.18.9",
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
+ "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
+ "@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-class-static-block": "^7.14.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3",
+ "@babel/plugin-syntax-import-assertions": "^7.18.6",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
@@ -1468,44 +1510,44 @@
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
- "@babel/plugin-transform-arrow-functions": "^7.16.5",
- "@babel/plugin-transform-async-to-generator": "^7.16.5",
- "@babel/plugin-transform-block-scoped-functions": "^7.16.5",
- "@babel/plugin-transform-block-scoping": "^7.16.5",
- "@babel/plugin-transform-classes": "^7.16.5",
- "@babel/plugin-transform-computed-properties": "^7.16.5",
- "@babel/plugin-transform-destructuring": "^7.16.5",
- "@babel/plugin-transform-dotall-regex": "^7.16.5",
- "@babel/plugin-transform-duplicate-keys": "^7.16.5",
- "@babel/plugin-transform-exponentiation-operator": "^7.16.5",
- "@babel/plugin-transform-for-of": "^7.16.5",
- "@babel/plugin-transform-function-name": "^7.16.5",
- "@babel/plugin-transform-literals": "^7.16.5",
- "@babel/plugin-transform-member-expression-literals": "^7.16.5",
- "@babel/plugin-transform-modules-amd": "^7.16.5",
- "@babel/plugin-transform-modules-commonjs": "^7.16.5",
- "@babel/plugin-transform-modules-systemjs": "^7.16.5",
- "@babel/plugin-transform-modules-umd": "^7.16.5",
- "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.5",
- "@babel/plugin-transform-new-target": "^7.16.5",
- "@babel/plugin-transform-object-super": "^7.16.5",
- "@babel/plugin-transform-parameters": "^7.16.5",
- "@babel/plugin-transform-property-literals": "^7.16.5",
- "@babel/plugin-transform-regenerator": "^7.16.5",
- "@babel/plugin-transform-reserved-words": "^7.16.5",
- "@babel/plugin-transform-shorthand-properties": "^7.16.5",
- "@babel/plugin-transform-spread": "^7.16.5",
- "@babel/plugin-transform-sticky-regex": "^7.16.5",
- "@babel/plugin-transform-template-literals": "^7.16.5",
- "@babel/plugin-transform-typeof-symbol": "^7.16.5",
- "@babel/plugin-transform-unicode-escapes": "^7.16.5",
- "@babel/plugin-transform-unicode-regex": "^7.16.5",
+ "@babel/plugin-transform-arrow-functions": "^7.18.6",
+ "@babel/plugin-transform-async-to-generator": "^7.18.6",
+ "@babel/plugin-transform-block-scoped-functions": "^7.18.6",
+ "@babel/plugin-transform-block-scoping": "^7.18.9",
+ "@babel/plugin-transform-classes": "^7.18.9",
+ "@babel/plugin-transform-computed-properties": "^7.18.9",
+ "@babel/plugin-transform-destructuring": "^7.18.9",
+ "@babel/plugin-transform-dotall-regex": "^7.18.6",
+ "@babel/plugin-transform-duplicate-keys": "^7.18.9",
+ "@babel/plugin-transform-exponentiation-operator": "^7.18.6",
+ "@babel/plugin-transform-for-of": "^7.18.8",
+ "@babel/plugin-transform-function-name": "^7.18.9",
+ "@babel/plugin-transform-literals": "^7.18.9",
+ "@babel/plugin-transform-member-expression-literals": "^7.18.6",
+ "@babel/plugin-transform-modules-amd": "^7.18.6",
+ "@babel/plugin-transform-modules-commonjs": "^7.18.6",
+ "@babel/plugin-transform-modules-systemjs": "^7.18.9",
+ "@babel/plugin-transform-modules-umd": "^7.18.6",
+ "@babel/plugin-transform-named-capturing-groups-regex": "^7.18.6",
+ "@babel/plugin-transform-new-target": "^7.18.6",
+ "@babel/plugin-transform-object-super": "^7.18.6",
+ "@babel/plugin-transform-parameters": "^7.18.8",
+ "@babel/plugin-transform-property-literals": "^7.18.6",
+ "@babel/plugin-transform-regenerator": "^7.18.6",
+ "@babel/plugin-transform-reserved-words": "^7.18.6",
+ "@babel/plugin-transform-shorthand-properties": "^7.18.6",
+ "@babel/plugin-transform-spread": "^7.18.9",
+ "@babel/plugin-transform-sticky-regex": "^7.18.6",
+ "@babel/plugin-transform-template-literals": "^7.18.9",
+ "@babel/plugin-transform-typeof-symbol": "^7.18.9",
+ "@babel/plugin-transform-unicode-escapes": "^7.18.10",
+ "@babel/plugin-transform-unicode-regex": "^7.18.6",
"@babel/preset-modules": "^0.1.5",
- "@babel/types": "^7.16.0",
- "babel-plugin-polyfill-corejs2": "^0.3.0",
- "babel-plugin-polyfill-corejs3": "^0.4.0",
- "babel-plugin-polyfill-regenerator": "^0.3.0",
- "core-js-compat": "^3.19.1",
+ "@babel/types": "^7.18.10",
+ "babel-plugin-polyfill-corejs2": "^0.3.2",
+ "babel-plugin-polyfill-corejs3": "^0.5.3",
+ "babel-plugin-polyfill-regenerator": "^0.4.0",
+ "core-js-compat": "^3.22.1",
"semver": "^6.3.0"
},
"engines": {
@@ -1532,9 +1574,9 @@
}
},
"node_modules/@babel/runtime": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz",
- "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz",
+ "integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==",
"dev": true,
"dependencies": {
"regenerator-runtime": "^0.13.4"
@@ -1550,33 +1592,33 @@
"dev": true
},
"node_modules/@babel/template": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.0.tgz",
- "integrity": "sha512-MnZdpFD/ZdYhXwiunMqqgyZyucaYsbL0IrjoGjaVhGilz+x8YB++kRfygSOIj1yOtWKPlx7NBp+9I1RQSgsd5A==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz",
+ "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==",
"dev": true,
"dependencies": {
- "@babel/code-frame": "^7.16.0",
- "@babel/parser": "^7.16.0",
- "@babel/types": "^7.16.0"
+ "@babel/code-frame": "^7.18.6",
+ "@babel/parser": "^7.18.10",
+ "@babel/types": "^7.18.10"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.5.tgz",
- "integrity": "sha512-FOCODAzqUMROikDYLYxl4nmwiLlu85rNqBML/A5hKRVXG2LV8d0iMqgPzdYTcIpjZEBB7D6UDU9vxRZiriASdQ==",
- "dev": true,
- "dependencies": {
- "@babel/code-frame": "^7.16.0",
- "@babel/generator": "^7.16.5",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-hoist-variables": "^7.16.0",
- "@babel/helper-split-export-declaration": "^7.16.0",
- "@babel/parser": "^7.16.5",
- "@babel/types": "^7.16.0",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.10.tgz",
+ "integrity": "sha512-J7ycxg0/K9XCtLyHf0cz2DqDihonJeIo+z+HEdRe9YuT8TY4A66i+Ab2/xZCEW7Ro60bPCBBfqqboHSamoV3+g==",
+ "dev": true,
+ "dependencies": {
+ "@babel/code-frame": "^7.18.6",
+ "@babel/generator": "^7.18.10",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-hoist-variables": "^7.18.6",
+ "@babel/helper-split-export-declaration": "^7.18.6",
+ "@babel/parser": "^7.18.10",
+ "@babel/types": "^7.18.10",
"debug": "^4.1.0",
"globals": "^11.1.0"
},
@@ -1585,12 +1627,13 @@
}
},
"node_modules/@babel/types": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.0.tgz",
- "integrity": "sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.10.tgz",
+ "integrity": "sha512-MJvnbEiiNkpjo+LknnmRrqbY1GPUUggjv+wQVjetM/AONoupqRALB7I6jGqNUAZsKcRIEu2J6FRFvsczljjsaQ==",
"dev": true,
"dependencies": {
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-string-parser": "^7.18.10",
+ "@babel/helper-validator-identifier": "^7.18.6",
"to-fast-properties": "^2.0.0"
},
"engines": {
@@ -1598,19 +1641,19 @@
}
},
"node_modules/@eslint/eslintrc": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz",
- "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
+ "integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
"dev": true,
"dependencies": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
- "espree": "^9.2.0",
- "globals": "^13.9.0",
- "ignore": "^4.0.6",
+ "espree": "^9.3.2",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
- "minimatch": "^3.0.4",
+ "minimatch": "^3.1.2",
"strip-json-comments": "^3.1.1"
},
"engines": {
@@ -1618,9 +1661,9 @@
}
},
"node_modules/@eslint/eslintrc/node_modules/globals": {
- "version": "13.12.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz",
- "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==",
+ "version": "13.17.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
+ "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"dev": true,
"dependencies": {
"type-fest": "^0.20.2"
@@ -1632,6 +1675,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/@eslint/eslintrc/node_modules/minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
"node_modules/@eslint/eslintrc/node_modules/type-fest": {
"version": "0.20.2",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
@@ -1645,9 +1700,9 @@
}
},
"node_modules/@humanwhocodes/config-array": {
- "version": "0.9.2",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz",
- "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==",
+ "version": "0.10.4",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz",
+ "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==",
"dev": true,
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
@@ -1658,12 +1713,69 @@
"node": ">=10.10.0"
}
},
+ "node_modules/@humanwhocodes/gitignore-to-minimatch": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz",
+ "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==",
+ "dev": true,
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/nzakas"
+ }
+ },
"node_modules/@humanwhocodes/object-schema": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true
},
+ "node_modules/@jridgewell/gen-mapping": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
+ "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/set-array": "^1.0.0",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/resolve-uri": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
+ "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/set-array": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
+ "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.4.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
+ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
+ "dev": true
+ },
+ "node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz",
+ "integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -1700,9 +1812,9 @@
}
},
"node_modules/@popperjs/core": {
- "version": "2.11.0",
- "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.0.tgz",
- "integrity": "sha512-zrsUxjLOKAzdewIDRWy9nsV1GQsKBCWaGwsZQlCgr6/q+vjyZhFgqedLfFBuI9anTPEUT4APq9Mu0SZBTzIcGQ==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz",
+ "integrity": "sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw==",
"peer": true,
"funding": {
"type": "opencollective",
@@ -1746,9 +1858,9 @@
}
},
"node_modules/@types/google-apps-script": {
- "version": "1.0.41",
- "resolved": "https://registry.npmjs.org/@types/google-apps-script/-/google-apps-script-1.0.41.tgz",
- "integrity": "sha512-Lv8Tila1iNUynITT0H4lR59fcdkZ1JOPQiuthaOoG/agAbWYkZLeaR6yLIeRydFQ2bQqVgOrAXlmu8Ut8uUcOA==",
+ "version": "1.0.53",
+ "resolved": "https://registry.npmjs.org/@types/google-apps-script/-/google-apps-script-1.0.53.tgz",
+ "integrity": "sha512-aFDrrqxhCcbM8h4hNID41HqhFWSwKsCCs9y99vbZdwNr5yeAW9ZcmQiNDp+P3BEL0nsR/rn5wt5Hv4kvyAU3Wg==",
"dev": true
},
"node_modules/@types/http-cache-semantics": {
@@ -1767,9 +1879,9 @@
}
},
"node_modules/@types/lodash": {
- "version": "4.14.178",
- "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz",
- "integrity": "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==",
+ "version": "4.14.182",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz",
+ "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==",
"dev": true
},
"node_modules/@types/minimatch": {
@@ -1812,9 +1924,9 @@
}
},
"node_modules/acorn": {
- "version": "8.6.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz",
- "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
"dev": true,
"bin": {
"acorn": "bin/acorn"
@@ -1873,15 +1985,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
- "node_modules/ansi-colors": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
- "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
- "dev": true,
- "engines": {
- "node": ">=6"
- }
- },
"node_modules/ansi-escapes": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
@@ -2475,13 +2578,13 @@
}
},
"node_modules/babel-plugin-polyfill-corejs2": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.0.tgz",
- "integrity": "sha512-wMDoBJ6uG4u4PNFh72Ty6t3EgfA91puCuAwKIazbQlci+ENb/UU9A3xG5lutjUIiXCIn1CY5L15r9LimiJyrSA==",
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.2.tgz",
+ "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==",
"dev": true,
"dependencies": {
- "@babel/compat-data": "^7.13.11",
- "@babel/helper-define-polyfill-provider": "^0.3.0",
+ "@babel/compat-data": "^7.17.7",
+ "@babel/helper-define-polyfill-provider": "^0.3.2",
"semver": "^6.1.1"
},
"peerDependencies": {
@@ -2489,25 +2592,25 @@
}
},
"node_modules/babel-plugin-polyfill-corejs3": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.4.0.tgz",
- "integrity": "sha512-YxFreYwUfglYKdLUGvIF2nJEsGwj+RhWSX/ije3D2vQPOXuyMLMtg/cCGMDpOA7Nd+MwlNdnGODbd2EwUZPlsw==",
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.3.tgz",
+ "integrity": "sha512-zKsXDh0XjnrUEW0mxIHLfjBfnXSMr5Q/goMe/fxpQnLm07mcOZiIZHBNWCMx60HmdvjxfXcalac0tfFg0wqxyw==",
"dev": true,
"dependencies": {
- "@babel/helper-define-polyfill-provider": "^0.3.0",
- "core-js-compat": "^3.18.0"
+ "@babel/helper-define-polyfill-provider": "^0.3.2",
+ "core-js-compat": "^3.21.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
}
},
"node_modules/babel-plugin-polyfill-regenerator": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.0.tgz",
- "integrity": "sha512-dhAPTDLGoMW5/84wkgwiLRwMnio2i1fUe53EuvtKMv0pn2p3S8OCoV1xAzfJPl0KOX7IB89s2ib85vbYiea3jg==",
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.0.tgz",
+ "integrity": "sha512-RW1cnryiADFeHmfLS+WW/G431p1PsW5qdRdz0SDRi7TKcUgc7Oh/uXkT7MZ/+tGsT1BkczEAmD5XjUyJ5SWDTw==",
"dev": true,
"dependencies": {
- "@babel/helper-define-polyfill-provider": "^0.3.0"
+ "@babel/helper-define-polyfill-provider": "^0.3.2"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
@@ -2794,15 +2897,21 @@
}
},
"node_modules/bootstrap": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
- "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/bootstrap"
- },
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
+ "integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/twbs"
+ },
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/bootstrap"
+ }
+ ],
"peerDependencies": {
- "@popperjs/core": "^2.10.2"
+ "@popperjs/core": "^2.11.5"
}
},
"node_modules/brace-expansion": {
@@ -2837,26 +2946,31 @@
}
},
"node_modules/browserslist": {
- "version": "4.19.1",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz",
- "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==",
+ "version": "4.21.3",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz",
+ "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==",
"dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/browserslist"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
+ }
+ ],
"dependencies": {
- "caniuse-lite": "^1.0.30001286",
- "electron-to-chromium": "^1.4.17",
- "escalade": "^3.1.1",
- "node-releases": "^2.0.1",
- "picocolors": "^1.0.0"
+ "caniuse-lite": "^1.0.30001370",
+ "electron-to-chromium": "^1.4.202",
+ "node-releases": "^2.0.6",
+ "update-browserslist-db": "^1.0.5"
},
"bin": {
"browserslist": "cli.js"
},
"engines": {
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/browserslist"
}
},
"node_modules/buffer": {
@@ -2983,14 +3097,20 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001292",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001292.tgz",
- "integrity": "sha512-jnT4Tq0Q4ma+6nncYQVe7d73kmDmE9C3OGTx3MvW7lBM/eY1S1DZTMBON7dqV481RhNiS5OxD7k9JQvmDOTirw==",
+ "version": "1.0.30001373",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001373.tgz",
+ "integrity": "sha512-pJYArGHrPp3TUqQzFYRmP/lwJlj8RCbVe3Gd3eJQkAV8SAC6b19XS9BjMvRdvaS8RMkaTN8ZhoHP6S1y8zzwEQ==",
"dev": true,
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/browserslist"
- }
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/browserslist"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
+ }
+ ]
},
"node_modules/chalk": {
"version": "2.4.2",
@@ -3365,12 +3485,12 @@
"hasInstallScript": true
},
"node_modules/core-js-compat": {
- "version": "3.20.0",
- "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.20.0.tgz",
- "integrity": "sha512-relrah5h+sslXssTTOkvqcC/6RURifB0W5yhYBdBkaPYa5/2KBMiog3XiD+s3TwEHWxInWVv4Jx2/Lw0vng+IQ==",
+ "version": "3.24.1",
+ "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.24.1.tgz",
+ "integrity": "sha512-XhdNAGeRnTpp8xbD+sR/HFDK9CbeeeqXT6TuofXh3urqEevzkWmLRgrVoykodsw8okqo2pu1BOmuCKrHx63zdw==",
"dev": true,
"dependencies": {
- "browserslist": "^4.19.1",
+ "browserslist": "^4.21.3",
"semver": "7.0.0"
},
"funding": {
@@ -3579,22 +3699,22 @@
}
},
"node_modules/del": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
- "integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/del/-/del-7.0.0.tgz",
+ "integrity": "sha512-tQbV/4u5WVB8HMJr08pgw0b6nG4RGt/tj+7Numvq+zqcvUFeMaIWWOUFltiU+6go8BSO2/ogsB4EasDaj0y68Q==",
"dev": true,
"dependencies": {
- "globby": "^11.0.1",
- "graceful-fs": "^4.2.4",
- "is-glob": "^4.0.1",
- "is-path-cwd": "^2.2.0",
- "is-path-inside": "^3.0.2",
- "p-map": "^4.0.0",
+ "globby": "^13.1.2",
+ "graceful-fs": "^4.2.10",
+ "is-glob": "^4.0.3",
+ "is-path-cwd": "^3.0.0",
+ "is-path-inside": "^4.0.0",
+ "p-map": "^5.5.0",
"rimraf": "^3.0.2",
- "slash": "^3.0.0"
+ "slash": "^4.0.0"
},
"engines": {
- "node": ">=10"
+ "node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@@ -3690,9 +3810,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.4.26",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.26.tgz",
- "integrity": "sha512-cA1YwlRzO6TGp7yd3+KAqh9Tt6Z4CuuKqsAJP6uF/H5MQryjAGDhMhnY5cEXo8MaRCczpzSBhMPdqRIodkbZYw==",
+ "version": "1.4.208",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.208.tgz",
+ "integrity": "sha512-diMr4t69FigAGUk2KovP0bygEtN/9AkqEVkzjEp0cu+zFFbZMVvwACpTTfuj1mAmFR5kNoSW8wGKDFWIvmThiQ==",
"dev": true
},
"node_modules/emoji-regex": {
@@ -3710,18 +3830,6 @@
"once": "^1.4.0"
}
},
- "node_modules/enquirer": {
- "version": "2.3.6",
- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
- "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
- "dev": true,
- "dependencies": {
- "ansi-colors": "^4.1.1"
- },
- "engines": {
- "node": ">=8.6"
- }
- },
"node_modules/error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -3794,32 +3902,35 @@
}
},
"node_modules/eslint": {
- "version": "8.5.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.5.0.tgz",
- "integrity": "sha512-tVGSkgNbOfiHyVte8bCM8OmX+xG9PzVG/B4UCF60zx7j61WIVY/AqJECDgpLD4DbbESD0e174gOg3ZlrX15GDg==",
+ "version": "8.21.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.21.0.tgz",
+ "integrity": "sha512-/XJ1+Qurf1T9G2M5IHrsjp+xrGT73RZf23xA1z5wB1ZzzEAWSZKvRwhWxTFp1rvkvCfwcvAUNAP31bhKTTGfDA==",
"dev": true,
"dependencies": {
- "@eslint/eslintrc": "^1.0.5",
- "@humanwhocodes/config-array": "^0.9.2",
+ "@eslint/eslintrc": "^1.3.0",
+ "@humanwhocodes/config-array": "^0.10.4",
+ "@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
- "enquirer": "^2.3.5",
"escape-string-regexp": "^4.0.0",
- "eslint-scope": "^7.1.0",
+ "eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
- "eslint-visitor-keys": "^3.1.0",
- "espree": "^9.2.0",
+ "eslint-visitor-keys": "^3.3.0",
+ "espree": "^9.3.3",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
+ "find-up": "^5.0.0",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
- "globals": "^13.6.0",
- "ignore": "^4.0.6",
+ "globals": "^13.15.0",
+ "globby": "^11.1.0",
+ "grapheme-splitter": "^1.0.4",
+ "ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
@@ -3827,12 +3938,10 @@
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash.merge": "^4.6.2",
- "minimatch": "^3.0.4",
+ "minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
- "progress": "^2.0.0",
"regexpp": "^3.2.0",
- "semver": "^7.2.1",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.0",
"text-table": "^0.2.0",
@@ -3861,9 +3970,9 @@
}
},
"node_modules/eslint-config-prettier": {
- "version": "8.3.0",
- "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz",
- "integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==",
+ "version": "8.5.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
+ "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
@@ -3885,15 +3994,15 @@
}
},
"node_modules/eslint-plugin-prettier": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz",
- "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==",
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz",
+ "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==",
"dev": true,
"dependencies": {
"prettier-linter-helpers": "^1.0.0"
},
"engines": {
- "node": ">=6.0.0"
+ "node": ">=12.0.0"
},
"peerDependencies": {
"eslint": ">=7.28.0",
@@ -3906,9 +4015,9 @@
}
},
"node_modules/eslint-scope": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz",
- "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==",
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz",
+ "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==",
"dev": true,
"dependencies": {
"esrecurse": "^4.3.0",
@@ -3946,9 +4055,9 @@
}
},
"node_modules/eslint-visitor-keys": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz",
- "integrity": "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
+ "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -4015,6 +4124,22 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/eslint/node_modules/find-up": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dev": true,
+ "dependencies": {
+ "locate-path": "^6.0.0",
+ "path-exists": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/eslint/node_modules/glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
@@ -4028,9 +4153,9 @@
}
},
"node_modules/eslint/node_modules/globals": {
- "version": "13.12.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz",
- "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==",
+ "version": "13.17.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
+ "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"dev": true,
"dependencies": {
"type-fest": "^0.20.2"
@@ -4042,6 +4167,26 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/eslint/node_modules/globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dev": true,
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/eslint/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -4051,19 +4196,70 @@
"node": ">=8"
}
},
- "node_modules/eslint/node_modules/semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
+ "node_modules/eslint/node_modules/locate-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dev": true,
"dependencies": {
- "lru-cache": "^6.0.0"
+ "p-locate": "^5.0.0"
},
- "bin": {
- "semver": "bin/semver.js"
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/eslint/node_modules/minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
+ "node_modules/eslint/node_modules/p-limit": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
+ "dev": true,
+ "dependencies": {
+ "yocto-queue": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/eslint/node_modules/p-locate": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
+ "dev": true,
+ "dependencies": {
+ "p-limit": "^3.0.2"
},
"engines": {
"node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/eslint/node_modules/slash": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=8"
}
},
"node_modules/eslint/node_modules/supports-color": {
@@ -4091,17 +4287,20 @@
}
},
"node_modules/espree": {
- "version": "9.2.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz",
- "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==",
+ "version": "9.3.3",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.3.tgz",
+ "integrity": "sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng==",
"dev": true,
"dependencies": {
- "acorn": "^8.6.0",
- "acorn-jsx": "^5.3.1",
- "eslint-visitor-keys": "^3.1.0"
+ "acorn": "^8.8.0",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
}
},
"node_modules/esquery": {
@@ -4362,9 +4561,9 @@
"dev": true
},
"node_modules/fast-glob": {
- "version": "3.2.7",
- "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz",
- "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
+ "version": "3.2.11",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz",
+ "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==",
"dev": true,
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
@@ -4374,7 +4573,7 @@
"micromatch": "^4.0.4"
},
"engines": {
- "node": ">=8"
+ "node": ">=8.6.0"
}
},
"node_modules/fast-json-stable-stringify": {
@@ -4806,10 +5005,13 @@
}
},
"node_modules/form-data-encoder": {
- "version": "1.7.1",
- "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz",
- "integrity": "sha512-EFRDrsMm/kyqbTQocNvRXMLjc7Es2Vk+IQFx/YW7hkUH1eBl4J1fqiP34l74Yt0pFLCNpc06fkbVk00008mzjg==",
- "dev": true
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.0.1.tgz",
+ "integrity": "sha512-Oy+P9w5mnO4TWXVgUiQvggNKPI9/ummcSt5usuIV6HkaLKigwzPpoenhEqmGmx3zHqm6ZLJ+CR/99N8JLinaEw==",
+ "dev": true,
+ "engines": {
+ "node": ">= 14.17"
+ }
},
"node_modules/fragment-cache": {
"version": "0.2.1",
@@ -5134,34 +5336,24 @@
}
},
"node_modules/globby": {
- "version": "11.0.4",
- "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
- "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
+ "version": "13.1.2",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",
+ "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",
"dev": true,
"dependencies": {
- "array-union": "^2.1.0",
"dir-glob": "^3.0.1",
- "fast-glob": "^3.1.1",
- "ignore": "^5.1.4",
- "merge2": "^1.3.0",
- "slash": "^3.0.0"
+ "fast-glob": "^3.2.11",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^4.0.0"
},
"engines": {
- "node": ">=10"
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/globby/node_modules/ignore": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
- "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
- "dev": true,
- "engines": {
- "node": ">= 4"
- }
- },
"node_modules/glogg": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz",
@@ -5240,21 +5432,21 @@
}
},
"node_modules/got": {
- "version": "12.0.0",
- "resolved": "https://registry.npmjs.org/got/-/got-12.0.0.tgz",
- "integrity": "sha512-gNNNghQ1yw0hyzie1FLK6gY90BQlXU9zSByyRygnbomHPruKQ6hAKKbpO1RfNZp8b+qNzNipGeRG3tUelKcVsA==",
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/got/-/got-12.3.0.tgz",
+ "integrity": "sha512-7uK06aluHF0UibYFBX3lFUZ2FG/W0KS4O4EqAIrbWIdbPxIT33r6ZJy7Zy+pdh0CP/ZbF3zBa7Fd9dCn7vGPBg==",
"dev": true,
"dependencies": {
- "@sindresorhus/is": "^4.2.0",
+ "@sindresorhus/is": "^5.2.0",
"@szmarczak/http-timer": "^5.0.1",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.4",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
- "form-data-encoder": "1.7.1",
+ "form-data-encoder": "^2.0.1",
"get-stream": "^6.0.1",
- "http2-wrapper": "^2.1.9",
+ "http2-wrapper": "^2.1.10",
"lowercase-keys": "^3.0.0",
"p-cancelable": "^3.0.0",
"responselike": "^2.0.0"
@@ -5266,6 +5458,18 @@
"url": "https://github.com/sindresorhus/got?sponsor=1"
}
},
+ "node_modules/got/node_modules/@sindresorhus/is": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.3.0.tgz",
+ "integrity": "sha512-CX6t4SYQ37lzxicAqsBtxA3OseeoVrh9cSJ5PFYam0GksYlupRfy1A+Q4aYD3zvcfECLc0zO2u+ZnR2UYKvCrw==",
+ "dev": true,
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/is?sponsor=1"
+ }
+ },
"node_modules/got/node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
@@ -5300,9 +5504,15 @@
}
},
"node_modules/graceful-fs": {
- "version": "4.2.8",
- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
- "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
+ "version": "4.2.10",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
+ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
+ "dev": true
+ },
+ "node_modules/grapheme-splitter": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
+ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==",
"dev": true
},
"node_modules/gtoken": {
@@ -5614,9 +5824,9 @@
]
},
"node_modules/ignore": {
- "version": "4.0.6",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
- "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
+ "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
"dev": true,
"engines": {
"node": ">= 4"
@@ -6045,21 +6255,27 @@
}
},
"node_modules/is-path-cwd": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
- "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-3.0.0.tgz",
+ "integrity": "sha512-kyiNFFLU0Ampr6SDZitD/DwUo4Zs1nSdnygUBqsu3LooL00Qvb5j+UnvApUn/TTj1J3OuE6BTdQ5rudKmU2ZaA==",
"dev": true,
"engines": {
- "node": ">=6"
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-path-inside": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
- "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz",
+ "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==",
"dev": true,
"engines": {
- "node": ">=8"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-plain-object": {
@@ -6340,13 +6556,10 @@
"dev": true
},
"node_modules/json5": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
- "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==",
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
+ "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"dev": true,
- "dependencies": {
- "minimist": "^1.2.5"
- },
"bin": {
"json5": "lib/cli.js"
},
@@ -6355,9 +6568,9 @@
}
},
"node_modules/jsonata": {
- "version": "1.8.5",
- "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.5.tgz",
- "integrity": "sha512-ilDyTBkg6qhNoNVr8PUPzz5GYvRK+REKOM5MdOGzH2y6V4yvPRMegSvbZLpbTtI0QAgz09QM7drDhSHUlwp9pA==",
+ "version": "1.8.6",
+ "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.6.tgz",
+ "integrity": "sha512-ZH2TPYdNP2JecOl/HvrH47Xc+9imibEMQ4YqKy/F/FrM+2a6vfbGxeCX23dB9Fr6uvGwv+ghf1KxWB3iZk09wA==",
"engines": {
"node": ">= 8"
}
@@ -6579,7 +6792,7 @@
"node_modules/lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
- "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
+ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
"dev": true
},
"node_modules/lodash.merge": {
@@ -6962,13 +7175,13 @@
}
},
"node_modules/micromatch": {
- "version": "4.0.4",
- "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
- "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
+ "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true,
"dependencies": {
- "braces": "^3.0.1",
- "picomatch": "^2.2.3"
+ "braces": "^3.0.2",
+ "picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
@@ -7292,9 +7505,9 @@
}
},
"node_modules/node-releases": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz",
- "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==",
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
+ "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"dev": true
},
"node_modules/normalize-newline": {
@@ -7717,37 +7930,92 @@
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"dependencies": {
- "p-try": "^2.0.0"
+ "p-try": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/p-locate": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "dev": true,
+ "dependencies": {
+ "p-limit": "^2.2.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/p-map": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/p-map/-/p-map-5.5.0.tgz",
+ "integrity": "sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg==",
+ "dev": true,
+ "dependencies": {
+ "aggregate-error": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/p-map/node_modules/aggregate-error": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-4.0.1.tgz",
+ "integrity": "sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w==",
+ "dev": true,
+ "dependencies": {
+ "clean-stack": "^4.0.0",
+ "indent-string": "^5.0.0"
},
"engines": {
- "node": ">=6"
+ "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/p-locate": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
- "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "node_modules/p-map/node_modules/clean-stack": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz",
+ "integrity": "sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg==",
"dev": true,
"dependencies": {
- "p-limit": "^2.2.0"
+ "escape-string-regexp": "5.0.0"
},
"engines": {
- "node": ">=8"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/p-map": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
- "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
+ "node_modules/p-map/node_modules/escape-string-regexp": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
+ "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
"dev": true,
- "dependencies": {
- "aggregate-error": "^3.0.0"
+ "engines": {
+ "node": ">=12"
},
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/p-map/node_modules/indent-string": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz",
+ "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==",
+ "dev": true,
"engines": {
- "node": ">=10"
+ "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@@ -7937,9 +8205,9 @@
"dev": true
},
"node_modules/picomatch": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
- "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"engines": {
"node": ">=8.6"
@@ -8070,15 +8338,18 @@
}
},
"node_modules/prettier": {
- "version": "2.5.1",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz",
- "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==",
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
+ "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/prettier-linter-helpers": {
@@ -8108,15 +8379,6 @@
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true
},
- "node_modules/progress": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
- "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
- "dev": true,
- "engines": {
- "node": ">=0.4.0"
- }
- },
"node_modules/pump": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
@@ -8441,9 +8703,9 @@
"dev": true
},
"node_modules/regenerate-unicode-properties": {
- "version": "9.0.0",
- "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-9.0.0.tgz",
- "integrity": "sha512-3E12UeNSPfjrgwjkR81m5J7Aw/T55Tu7nUyZVQYCKEOs+2dkxEY+DpPtZzO4YruuiPb7NkYLVcyJC4+zCbk5pA==",
+ "version": "10.0.1",
+ "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz",
+ "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==",
"dev": true,
"dependencies": {
"regenerate": "^1.4.2"
@@ -8459,9 +8721,9 @@
"dev": true
},
"node_modules/regenerator-transform": {
- "version": "0.14.5",
- "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz",
- "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==",
+ "version": "0.15.0",
+ "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz",
+ "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.8.4"
@@ -8530,15 +8792,15 @@
}
},
"node_modules/regexpu-core": {
- "version": "4.8.0",
- "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.8.0.tgz",
- "integrity": "sha512-1F6bYsoYiz6is+oz70NWur2Vlh9KWtswuRuzJOfeYUrfPX2o8n74AnUVaOGDbUqVGO9fNHu48/pjJO4sNVwsOg==",
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.1.0.tgz",
+ "integrity": "sha512-bb6hk+xWd2PEOkj5It46A16zFMs2mv86Iwpdu94la4S3sJ7C973h2dHpYKwIBGaWSO7cIRJ+UX0IeMaWcO4qwA==",
"dev": true,
"dependencies": {
"regenerate": "^1.4.2",
- "regenerate-unicode-properties": "^9.0.0",
- "regjsgen": "^0.5.2",
- "regjsparser": "^0.7.0",
+ "regenerate-unicode-properties": "^10.0.1",
+ "regjsgen": "^0.6.0",
+ "regjsparser": "^0.8.2",
"unicode-match-property-ecmascript": "^2.0.0",
"unicode-match-property-value-ecmascript": "^2.0.0"
},
@@ -8547,15 +8809,15 @@
}
},
"node_modules/regjsgen": {
- "version": "0.5.2",
- "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz",
- "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==",
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz",
+ "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==",
"dev": true
},
"node_modules/regjsparser": {
- "version": "0.7.0",
- "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.7.0.tgz",
- "integrity": "sha512-A4pcaORqmNMDVwUjWoTzuhwMGpP+NykpfqAsEgI1FSH/EzC7lrN5TMd+kN8YCovX+jMpu8eaqXgXPCa0g8FQNQ==",
+ "version": "0.8.4",
+ "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz",
+ "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==",
"dev": true,
"dependencies": {
"jsesc": "~0.5.0"
@@ -8567,7 +8829,7 @@
"node_modules/regjsparser/node_modules/jsesc": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
- "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
+ "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==",
"dev": true,
"bin": {
"jsesc": "bin/jsesc"
@@ -8975,12 +9237,15 @@
"dev": true
},
"node_modules/slash": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
- "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+ "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
"dev": true,
"engines": {
- "node": ">=8"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/slice-ansi": {
@@ -9746,9 +10011,9 @@
}
},
"node_modules/uglify-js": {
- "version": "3.14.5",
- "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.5.tgz",
- "integrity": "sha512-qZukoSxOG0urUTvjc2ERMTcAy+BiFh3weWAkeurLwjrCba73poHmG3E36XEjd/JGukMzwTL7uCxZiAexj8ppvQ==",
+ "version": "3.16.3",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.16.3.tgz",
+ "integrity": "sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==",
"dev": true,
"bin": {
"uglifyjs": "bin/uglifyjs"
@@ -9934,6 +10199,32 @@
"yarn": "*"
}
},
+ "node_modules/update-browserslist-db": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz",
+ "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/browserslist"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
+ }
+ ],
+ "dependencies": {
+ "escalade": "^3.1.1",
+ "picocolors": "^1.0.0"
+ },
+ "bin": {
+ "browserslist-lint": "cli.js"
+ },
+ "peerDependencies": {
+ "browserslist": ">= 4.21.0"
+ }
+ },
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@@ -10433,124 +10724,157 @@
"engines": {
"node": ">=0.10.0"
}
+ },
+ "node_modules/yocto-queue": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
}
},
"dependencies": {
+ "@ampproject/remapping": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz",
+ "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/gen-mapping": "^0.1.0",
+ "@jridgewell/trace-mapping": "^0.3.9"
+ }
+ },
"@babel/code-frame": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz",
- "integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
+ "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
"dev": true,
"requires": {
- "@babel/highlight": "^7.16.0"
+ "@babel/highlight": "^7.18.6"
}
},
"@babel/compat-data": {
- "version": "7.16.4",
- "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.16.4.tgz",
- "integrity": "sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.8.tgz",
+ "integrity": "sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ==",
"dev": true
},
"@babel/core": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.16.5.tgz",
- "integrity": "sha512-wUcenlLzuWMZ9Zt8S0KmFwGlH6QKRh3vsm/dhDA3CHkiTA45YuG1XkHRcNRl73EFPXDp/d5kVOU0/y7x2w6OaQ==",
- "dev": true,
- "requires": {
- "@babel/code-frame": "^7.16.0",
- "@babel/generator": "^7.16.5",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helpers": "^7.16.5",
- "@babel/parser": "^7.16.5",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.10.tgz",
+ "integrity": "sha512-JQM6k6ENcBFKVtWvLavlvi/mPcpYZ3+R+2EySDEMSMbp7Mn4FexlbbJVrx2R7Ijhr01T8gyqrOaABWIOgxeUyw==",
+ "dev": true,
+ "requires": {
+ "@ampproject/remapping": "^2.1.0",
+ "@babel/code-frame": "^7.18.6",
+ "@babel/generator": "^7.18.10",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-module-transforms": "^7.18.9",
+ "@babel/helpers": "^7.18.9",
+ "@babel/parser": "^7.18.10",
+ "@babel/template": "^7.18.10",
+ "@babel/traverse": "^7.18.10",
+ "@babel/types": "^7.18.10",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
- "json5": "^2.1.2",
- "semver": "^6.3.0",
- "source-map": "^0.5.0"
+ "json5": "^2.2.1",
+ "semver": "^6.3.0"
}
},
"@babel/generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.5.tgz",
- "integrity": "sha512-kIvCdjZqcdKqoDbVVdt5R99icaRtrtYhYK/xux5qiWCBmfdvEYMFZ68QCrpE5cbFM1JsuArUNs1ZkuKtTtUcZA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.10.tgz",
+ "integrity": "sha512-0+sW7e3HjQbiHbj1NeU/vN8ornohYlacAfZIaXhdoGweQqgcNy69COVciYYqEXJ/v+9OBA7Frxm4CVAuNqKeNA==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0",
- "jsesc": "^2.5.1",
- "source-map": "^0.5.0"
+ "@babel/types": "^7.18.10",
+ "@jridgewell/gen-mapping": "^0.3.2",
+ "jsesc": "^2.5.1"
+ },
+ "dependencies": {
+ "@jridgewell/gen-mapping": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
+ "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/set-array": "^1.0.1",
+ "@jridgewell/sourcemap-codec": "^1.4.10",
+ "@jridgewell/trace-mapping": "^0.3.9"
+ }
+ }
}
},
"@babel/helper-annotate-as-pure": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.0.tgz",
- "integrity": "sha512-ItmYF9vR4zA8cByDocY05o0LGUkp1zhbTQOH1NFyl5xXEqlTJQCEJjieriw+aFpxo16swMxUnUiKS7a/r4vtHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz",
+ "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-builder-binary-assignment-operator-visitor": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.5.tgz",
- "integrity": "sha512-3JEA9G5dmmnIWdzaT9d0NmFRgYnWUThLsDaL7982H0XqqWr56lRrsmwheXFMjR+TMl7QMBb6mzy9kvgr1lRLUA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz",
+ "integrity": "sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw==",
"dev": true,
"requires": {
- "@babel/helper-explode-assignable-expression": "^7.16.0",
- "@babel/types": "^7.16.0"
+ "@babel/helper-explode-assignable-expression": "^7.18.6",
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-compilation-targets": {
- "version": "7.16.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.3.tgz",
- "integrity": "sha512-vKsoSQAyBmxS35JUOOt+07cLc6Nk/2ljLIHwmq2/NM6hdioUaqEXq/S+nXvbvXbZkNDlWOymPanJGOc4CBjSJA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz",
+ "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==",
"dev": true,
"requires": {
- "@babel/compat-data": "^7.16.0",
- "@babel/helper-validator-option": "^7.14.5",
- "browserslist": "^4.17.5",
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-validator-option": "^7.18.6",
+ "browserslist": "^4.20.2",
"semver": "^6.3.0"
}
},
"@babel/helper-create-class-features-plugin": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.16.5.tgz",
- "integrity": "sha512-NEohnYA7mkB8L5JhU7BLwcBdU3j83IziR9aseMueWGeAjblbul3zzb8UvJ3a1zuBiqCMObzCJHFqKIQE6hTVmg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz",
+ "integrity": "sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw==",
"dev": true,
"requires": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-member-expression-to-functions": "^7.16.5",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/helper-replace-supers": "^7.16.5",
- "@babel/helper-split-export-declaration": "^7.16.0"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-member-expression-to-functions": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/helper-replace-supers": "^7.18.9",
+ "@babel/helper-split-export-declaration": "^7.18.6"
}
},
"@babel/helper-create-regexp-features-plugin": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.16.0.tgz",
- "integrity": "sha512-3DyG0zAFAZKcOp7aVr33ddwkxJ0Z0Jr5V99y3I690eYLpukJsJvAbzTy1ewoCqsML8SbIrjH14Jc/nSQ4TvNPA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.18.6.tgz",
+ "integrity": "sha512-7LcpH1wnQLGrI+4v+nPp+zUvIkF9x0ddv1Hkdue10tg3gmRnLy97DXh4STiOf1qeIInyD69Qv5kKSZzKD8B/7A==",
"dev": true,
"requires": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "regexpu-core": "^4.7.1"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "regexpu-core": "^5.1.0"
}
},
"@babel/helper-define-polyfill-provider": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.0.tgz",
- "integrity": "sha512-7hfT8lUljl/tM3h+izTX/pO3W3frz2ok6Pk+gzys8iJqDfZrZy2pXjRTZAvG2YmfHun1X4q8/UZRLatMfqc5Tg==",
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.2.tgz",
+ "integrity": "sha512-r9QJJ+uDWrd+94BSPcP6/de67ygLtvVy6cK4luE6MOuDsZIdoaPBnfSpbO/+LTifjPckbKXRuI9BB/Z2/y3iTg==",
"dev": true,
"requires": {
- "@babel/helper-compilation-targets": "^7.13.0",
- "@babel/helper-module-imports": "^7.12.13",
- "@babel/helper-plugin-utils": "^7.13.0",
- "@babel/traverse": "^7.13.0",
+ "@babel/helper-compilation-targets": "^7.17.7",
+ "@babel/helper-plugin-utils": "^7.16.7",
"debug": "^4.1.1",
"lodash.debounce": "^4.0.8",
"resolve": "^1.14.2",
@@ -10558,380 +10882,375 @@
}
},
"@babel/helper-environment-visitor": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.5.tgz",
- "integrity": "sha512-ODQyc5AnxmZWm/R2W7fzhamOk1ey8gSguo5SGvF0zcB3uUzRpTRmM/jmLSm9bDMyPlvbyJ+PwPEK0BWIoZ9wjg==",
- "dev": true,
- "requires": {
- "@babel/types": "^7.16.0"
- }
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz",
+ "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==",
+ "dev": true
},
"@babel/helper-explode-assignable-expression": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.0.tgz",
- "integrity": "sha512-Hk2SLxC9ZbcOhLpg/yMznzJ11W++lg5GMbxt1ev6TXUiJB0N42KPC+7w8a+eWGuqDnUYuwStJoZHM7RgmIOaGQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz",
+ "integrity": "sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-function-name": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.0.tgz",
- "integrity": "sha512-BZh4mEk1xi2h4HFjWUXRQX5AEx4rvaZxHgax9gcjdLWdkjsY7MKt5p0otjsg5noXw+pB+clMCjw+aEVYADMjog==",
- "dev": true,
- "requires": {
- "@babel/helper-get-function-arity": "^7.16.0",
- "@babel/template": "^7.16.0",
- "@babel/types": "^7.16.0"
- }
- },
- "@babel/helper-get-function-arity": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.0.tgz",
- "integrity": "sha512-ASCquNcywC1NkYh/z7Cgp3w31YW8aojjYIlNg4VeJiHkqyP4AzIvr4qx7pYDb4/s8YcsZWqqOSxgkvjUz1kpDQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz",
+ "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/template": "^7.18.6",
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-hoist-variables": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.0.tgz",
- "integrity": "sha512-1AZlpazjUR0EQZQv3sgRNfM9mEVWPK3M6vlalczA+EECcPz3XPh6VplbErL5UoMpChhSck5wAJHthlj1bYpcmg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz",
+ "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-member-expression-to-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.5.tgz",
- "integrity": "sha512-7fecSXq7ZrLE+TWshbGT+HyCLkxloWNhTbU2QM1NTI/tDqyf0oZiMcEfYtDuUDCo528EOlt39G1rftea4bRZIw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz",
+ "integrity": "sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-module-imports": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.0.tgz",
- "integrity": "sha512-kkH7sWzKPq0xt3H1n+ghb4xEMP8k0U7XV3kkB+ZGy69kDk2ySFW1qPi06sjKzFY3t1j6XbJSqr4mF9L7CYVyhg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz",
+ "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-module-transforms": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.16.5.tgz",
- "integrity": "sha512-CkvMxgV4ZyyioElFwcuWnDCcNIeyqTkCm9BxXZi73RR1ozqlpboqsbGUNvRTflgZtFbbJ1v5Emvm+lkjMYY/LQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz",
+ "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==",
"dev": true,
"requires": {
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-module-imports": "^7.16.0",
- "@babel/helper-simple-access": "^7.16.0",
- "@babel/helper-split-export-declaration": "^7.16.0",
- "@babel/helper-validator-identifier": "^7.15.7",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-module-imports": "^7.18.6",
+ "@babel/helper-simple-access": "^7.18.6",
+ "@babel/helper-split-export-declaration": "^7.18.6",
+ "@babel/helper-validator-identifier": "^7.18.6",
+ "@babel/template": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-optimise-call-expression": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.0.tgz",
- "integrity": "sha512-SuI467Gi2V8fkofm2JPnZzB/SUuXoJA5zXe/xzyPP2M04686RzFKFHPK6HDVN6JvWBIEW8tt9hPR7fXdn2Lgpw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz",
+ "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-plugin-utils": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.5.tgz",
- "integrity": "sha512-59KHWHXxVA9K4HNF4sbHCf+eJeFe0Te/ZFGqBT4OjXhrwvA04sGfaEGsVTdsjoszq0YTP49RC9UKe5g8uN2RwQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz",
+ "integrity": "sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w==",
"dev": true
},
"@babel/helper-remap-async-to-generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.5.tgz",
- "integrity": "sha512-X+aAJldyxrOmN9v3FKp+Hu1NO69VWgYgDGq6YDykwRPzxs5f2N+X988CBXS7EQahDU+Vpet5QYMqLk+nsp+Qxw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz",
+ "integrity": "sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==",
"dev": true,
"requires": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-wrap-function": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-wrap-function": "^7.18.9",
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-replace-supers": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.5.tgz",
- "integrity": "sha512-ao3seGVa/FZCMCCNDuBcqnBFSbdr8N2EW35mzojx3TwfIbdPmNK+JV6+2d5bR0Z71W5ocLnQp9en/cTF7pBJiQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.18.9.tgz",
+ "integrity": "sha512-dNsWibVI4lNT6HiuOIBr1oyxo40HvIVmbwPUm3XZ7wMh4k2WxrxTqZwSqw/eEmXDS9np0ey5M2bz9tBmO9c+YQ==",
"dev": true,
"requires": {
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-member-expression-to-functions": "^7.16.5",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-member-expression-to-functions": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-simple-access": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.0.tgz",
- "integrity": "sha512-o1rjBT/gppAqKsYfUdfHq5Rk03lMQrkPHG1OWzHWpLgVXRH4HnMM9Et9CVdIqwkCQlobnGHEJMsgWP/jE1zUiw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz",
+ "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
"@babel/helper-skip-transparent-expression-wrappers": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz",
- "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.18.9.tgz",
+ "integrity": "sha512-imytd2gHi3cJPsybLRbmFrF7u5BIEuI2cNheyKi3/iOBC63kNn3q8Crn2xVuESli0aM4KYsyEqKyS7lFL8YVtw==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.9"
}
},
"@babel/helper-split-export-declaration": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.0.tgz",
- "integrity": "sha512-0YMMRpuDFNGTHNRiiqJX19GjNXA4H0E8jZ2ibccfSxaCogbm3am5WN/2nQNj0YnQwGWM1J06GOcQ2qnh3+0paw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz",
+ "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==",
"dev": true,
"requires": {
- "@babel/types": "^7.16.0"
+ "@babel/types": "^7.18.6"
}
},
+ "@babel/helper-string-parser": {
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz",
+ "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==",
+ "dev": true
+ },
"@babel/helper-validator-identifier": {
- "version": "7.15.7",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
- "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
+ "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"dev": true
},
"@babel/helper-validator-option": {
- "version": "7.14.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz",
- "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz",
+ "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==",
"dev": true
},
"@babel/helper-wrap-function": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.5.tgz",
- "integrity": "sha512-2J2pmLBqUqVdJw78U0KPNdeE2qeuIyKoG4mKV7wAq3mc4jJG282UgjZw4ZYDnqiWQuS3Y3IYdF/AQ6CpyBV3VA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.18.10.tgz",
+ "integrity": "sha512-95NLBP59VWdfK2lyLKe6eTMq9xg+yWKzxzxbJ1wcYNi1Auz200+83fMDADjRxBvc2QQor5zja2yTQzXGhk2GtQ==",
"dev": true,
"requires": {
- "@babel/helper-function-name": "^7.16.0",
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/template": "^7.18.10",
+ "@babel/traverse": "^7.18.10",
+ "@babel/types": "^7.18.10"
}
},
"@babel/helpers": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.5.tgz",
- "integrity": "sha512-TLgi6Lh71vvMZGEkFuIxzaPsyeYCHQ5jJOOX1f0xXn0uciFuE8cEk0wyBquMcCxBXZ5BJhE2aUB7pnWTD150Tw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz",
+ "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==",
"dev": true,
"requires": {
- "@babel/template": "^7.16.0",
- "@babel/traverse": "^7.16.5",
- "@babel/types": "^7.16.0"
+ "@babel/template": "^7.18.6",
+ "@babel/traverse": "^7.18.9",
+ "@babel/types": "^7.18.9"
}
},
"@babel/highlight": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz",
- "integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
+ "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
"dev": true,
"requires": {
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-validator-identifier": "^7.18.6",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
}
},
"@babel/parser": {
- "version": "7.16.6",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.6.tgz",
- "integrity": "sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.10.tgz",
+ "integrity": "sha512-TYk3OA0HKL6qNryUayb5UUEhM/rkOQozIBEA5ITXh5DWrSp0TlUQXMyZmnWxG/DizSWBeeQ0Zbc5z8UGaaqoeg==",
"dev": true
},
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": {
- "version": "7.16.2",
- "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.2.tgz",
- "integrity": "sha512-h37CvpLSf8gb2lIJ2CgC3t+EjFbi0t8qS7LCS1xcJIlEXE4czlofwaW7W1HA8zpgOCzI9C1nmoqNR1zWkk0pQg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz",
+ "integrity": "sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.14.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.0.tgz",
- "integrity": "sha512-4tcFwwicpWTrpl9qjf7UsoosaArgImF85AxqCRZlgc3IQDvkUHjJpruXAL58Wmj+T6fypWTC/BakfEkwIL/pwA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.18.9.tgz",
+ "integrity": "sha512-AHrP9jadvH7qlOj6PINbgSuphjQUAK7AOT7DPjBo9EHoLhQTnnK5u45e1Hd4DbSQEO9nqPWtQ89r+XEOWFScKg==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.14.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0",
- "@babel/plugin-proposal-optional-chaining": "^7.16.0"
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9",
+ "@babel/plugin-proposal-optional-chaining": "^7.18.9"
}
},
"@babel/plugin-proposal-async-generator-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.5.tgz",
- "integrity": "sha512-C/FX+3HNLV6sz7AqbTQqEo1L9/kfrKjxcVtgyBCmvIgOjvuBVUWooDoi7trsLxOzCEo5FccjRvKHkfDsJFZlfA==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.18.10.tgz",
+ "integrity": "sha512-1mFuY2TOsR1hxbjCo4QL+qlIjV07p4H4EUYw2J/WCqsvFV6V9X9z9YhXbWndc/4fw+hYGlDT7egYxliMp5O6Ew==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-remap-async-to-generator": "^7.16.5",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-remap-async-to-generator": "^7.18.9",
"@babel/plugin-syntax-async-generators": "^7.8.4"
}
},
"@babel/plugin-proposal-class-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.5.tgz",
- "integrity": "sha512-pJD3HjgRv83s5dv1sTnDbZOaTjghKEz8KUn1Kbh2eAIRhGuyQ1XSeI4xVXU3UlIEVA3DAyIdxqT1eRn7Wcn55A==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz",
+ "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==",
"dev": true,
"requires": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-proposal-class-static-block": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.16.5.tgz",
- "integrity": "sha512-EEFzuLZcm/rNJ8Q5krK+FRKdVkd6FjfzT9tuSZql9sQn64K0hHA2KLJ0DqVot9/iV6+SsuadC5yI39zWnm+nmQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.18.6.tgz",
+ "integrity": "sha512-+I3oIiNxrCpup3Gi8n5IGMwj0gOCAjcJUSQEcotNnCCPMEnixawOQ+KeJPlgfjzx+FKQ1QSyZOWe7wmoJp7vhw==",
"dev": true,
"requires": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-class-static-block": "^7.14.5"
}
},
"@babel/plugin-proposal-dynamic-import": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.5.tgz",
- "integrity": "sha512-P05/SJZTTvHz79LNYTF8ff5xXge0kk5sIIWAypcWgX4BTRUgyHc8wRxJ/Hk+mU0KXldgOOslKaeqnhthcDJCJQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz",
+ "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
}
},
"@babel/plugin-proposal-export-namespace-from": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.5.tgz",
- "integrity": "sha512-i+sltzEShH1vsVydvNaTRsgvq2vZsfyrd7K7vPLUU/KgS0D5yZMe6uipM0+izminnkKrEfdUnz7CxMRb6oHZWw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz",
+ "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3"
}
},
"@babel/plugin-proposal-json-strings": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.5.tgz",
- "integrity": "sha512-QQJueTFa0y9E4qHANqIvMsuxM/qcLQmKttBACtPCQzGUEizsXDACGonlPiSwynHfOa3vNw0FPMVvQzbuXwh4SQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz",
+ "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-json-strings": "^7.8.3"
}
},
"@babel/plugin-proposal-logical-assignment-operators": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.5.tgz",
- "integrity": "sha512-xqibl7ISO2vjuQM+MzR3rkd0zfNWltk7n9QhaD8ghMmMceVguYrNDt7MikRyj4J4v3QehpnrU8RYLnC7z/gZLA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.18.9.tgz",
+ "integrity": "sha512-128YbMpjCrP35IOExw2Fq+x55LMP42DzhOhX2aNNIdI9avSWl2PI0yuBWarr3RYpZBSPtabfadkH2yeRiMD61Q==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4"
}
},
"@babel/plugin-proposal-nullish-coalescing-operator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.5.tgz",
- "integrity": "sha512-YwMsTp/oOviSBhrjwi0vzCUycseCYwoXnLiXIL3YNjHSMBHicGTz7GjVU/IGgz4DtOEXBdCNG72pvCX22ehfqg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
+ "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
}
},
"@babel/plugin-proposal-numeric-separator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.5.tgz",
- "integrity": "sha512-DvB9l/TcsCRvsIV9v4jxR/jVP45cslTVC0PMVHvaJhhNuhn2Y1SOhCSFlPK777qLB5wb8rVDaNoqMTyOqtY5Iw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz",
+ "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-numeric-separator": "^7.10.4"
}
},
"@babel/plugin-proposal-object-rest-spread": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.16.5.tgz",
- "integrity": "sha512-UEd6KpChoyPhCoE840KRHOlGhEZFutdPDMGj+0I56yuTTOaT51GzmnEl/0uT41fB/vD2nT+Pci2KjezyE3HmUw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.18.9.tgz",
+ "integrity": "sha512-kDDHQ5rflIeY5xl69CEqGEZ0KY369ehsCIEbTGb4siHG5BE9sga/T0r0OUwyZNLMmZE79E1kbsqAjwFCW4ds6Q==",
"dev": true,
"requires": {
- "@babel/compat-data": "^7.16.4",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
- "@babel/plugin-transform-parameters": "^7.16.5"
+ "@babel/plugin-transform-parameters": "^7.18.8"
}
},
"@babel/plugin-proposal-optional-catch-binding": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.5.tgz",
- "integrity": "sha512-ihCMxY1Iljmx4bWy/PIMJGXN4NS4oUj1MKynwO07kiKms23pNvIn1DMB92DNB2R0EA882sw0VXIelYGdtF7xEQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz",
+ "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3"
}
},
"@babel/plugin-proposal-optional-chaining": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.5.tgz",
- "integrity": "sha512-kzdHgnaXRonttiTfKYnSVafbWngPPr2qKw9BWYBESl91W54e+9R5pP70LtWxV56g0f05f/SQrwHYkfvbwcdQ/A==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.18.9.tgz",
+ "integrity": "sha512-v5nwt4IqBXihxGsW2QmCWMDS3B3bzGIk/EQVZz2ei7f3NJl8NzAJVvUmpDW5q1CRNY+Beb/k58UAH1Km1N411w==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9",
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
}
},
"@babel/plugin-proposal-private-methods": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.5.tgz",
- "integrity": "sha512-+yFMO4BGT3sgzXo+lrq7orX5mAZt57DwUK6seqII6AcJnJOIhBJ8pzKH47/ql/d426uQ7YhN8DpUFirQzqYSUA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz",
+ "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==",
"dev": true,
"requires": {
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-proposal-private-property-in-object": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.5.tgz",
- "integrity": "sha512-+YGh5Wbw0NH3y/E5YMu6ci5qTDmAEVNoZ3I54aB6nVEOZ5BQ7QJlwKq5pYVucQilMByGn/bvX0af+uNaPRCabA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.18.6.tgz",
+ "integrity": "sha512-9Rysx7FOctvT5ouj5JODjAFAkgGoudQuLPamZb0v1TGLpapdNaftzifU8NTWQm0IRjqoYypdrSmyWgkocDQ8Dw==",
"dev": true,
"requires": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-create-class-features-plugin": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5"
}
},
"@babel/plugin-proposal-unicode-property-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.5.tgz",
- "integrity": "sha512-s5sKtlKQyFSatt781HQwv1hoM5BQ9qRH30r+dK56OLDsHmV74mzwJNX7R1yMuE7VZKG5O6q/gmOGSAO6ikTudg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz",
+ "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==",
"dev": true,
"requires": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-syntax-async-generators": {
@@ -10979,6 +11298,15 @@
"@babel/helper-plugin-utils": "^7.8.3"
}
},
+ "@babel/plugin-syntax-import-assertions": {
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.18.6.tgz",
+ "integrity": "sha512-/DU3RXad9+bZwrgWJQKbr39gYbJpLJHezqEzRzi/BHRlJ9zsQb4CK2CA/5apllXNomwA1qHwzvHl+AdEmC5krQ==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-plugin-utils": "^7.18.6"
+ }
+ },
"@babel/plugin-syntax-json-strings": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz",
@@ -11061,350 +11389,354 @@
}
},
"@babel/plugin-transform-arrow-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.5.tgz",
- "integrity": "sha512-8bTHiiZyMOyfZFULjsCnYOWG059FVMes0iljEHSfARhNgFfpsqE92OrCffv3veSw9rwMkYcFe9bj0ZoXU2IGtQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz",
+ "integrity": "sha512-9S9X9RUefzrsHZmKMbDXxweEH+YlE8JJEuat9FdvW9Qh1cw7W64jELCtWNkPBPX5En45uy28KGvA/AySqUh8CQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-async-to-generator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.5.tgz",
- "integrity": "sha512-TMXgfioJnkXU+XRoj7P2ED7rUm5jbnDWwlCuFVTpQboMfbSya5WrmubNBAMlk7KXvywpo8rd8WuYZkis1o2H8w==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.18.6.tgz",
+ "integrity": "sha512-ARE5wZLKnTgPW7/1ftQmSi1CmkqqHo2DNmtztFhvgtOWSDfq0Cq9/9L+KnZNYSNrydBekhW3rwShduf59RoXag==",
"dev": true,
"requires": {
- "@babel/helper-module-imports": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-remap-async-to-generator": "^7.16.5"
+ "@babel/helper-module-imports": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-remap-async-to-generator": "^7.18.6"
}
},
"@babel/plugin-transform-block-scoped-functions": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.5.tgz",
- "integrity": "sha512-BxmIyKLjUGksJ99+hJyL/HIxLIGnLKtw772zYDER7UuycDZ+Xvzs98ZQw6NGgM2ss4/hlFAaGiZmMNKvValEjw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz",
+ "integrity": "sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-block-scoping": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.5.tgz",
- "integrity": "sha512-JxjSPNZSiOtmxjX7PBRBeRJTUKTyJ607YUYeT0QJCNdsedOe+/rXITjP08eG8xUpsLfPirgzdCFN+h0w6RI+pQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.18.9.tgz",
+ "integrity": "sha512-5sDIJRV1KtQVEbt/EIBwGy4T01uYIo4KRB3VUqzkhrAIOGx7AoctL9+Ux88btY0zXdDyPJ9mW+bg+v+XEkGmtw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-classes": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.5.tgz",
- "integrity": "sha512-DzJ1vYf/7TaCYy57J3SJ9rV+JEuvmlnvvyvYKFbk5u46oQbBvuB9/0w+YsVsxkOv8zVWKpDmUoj4T5ILHoXevA==",
- "dev": true,
- "requires": {
- "@babel/helper-annotate-as-pure": "^7.16.0",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-optimise-call-expression": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-replace-supers": "^7.16.5",
- "@babel/helper-split-export-declaration": "^7.16.0",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.18.9.tgz",
+ "integrity": "sha512-EkRQxsxoytpTlKJmSPYrsOMjCILacAjtSVkd4gChEe2kXjFCun3yohhW5I7plXJhCemM0gKsaGMcO8tinvCA5g==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-annotate-as-pure": "^7.18.6",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-optimise-call-expression": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-replace-supers": "^7.18.9",
+ "@babel/helper-split-export-declaration": "^7.18.6",
"globals": "^11.1.0"
}
},
"@babel/plugin-transform-computed-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.5.tgz",
- "integrity": "sha512-n1+O7xtU5lSLraRzX88CNcpl7vtGdPakKzww74bVwpAIRgz9JVLJJpOLb0uYqcOaXVM0TL6X0RVeIJGD2CnCkg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.18.9.tgz",
+ "integrity": "sha512-+i0ZU1bCDymKakLxn5srGHrsAPRELC2WIbzwjLhHW9SIE1cPYkLCL0NlnXMZaM1vhfgA2+M7hySk42VBvrkBRw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-destructuring": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.16.5.tgz",
- "integrity": "sha512-GuRVAsjq+c9YPK6NeTkRLWyQskDC099XkBSVO+6QzbnOnH2d/4mBVXYStaPrZD3dFRfg00I6BFJ9Atsjfs8mlg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.18.9.tgz",
+ "integrity": "sha512-p5VCYNddPLkZTq4XymQIaIfZNJwT9YsjkPOhkVEqt6QIpQFZVM9IltqqYpOEkJoN1DPznmxUDyZ5CTZs/ZCuHA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-dotall-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.5.tgz",
- "integrity": "sha512-iQiEMt8Q4/5aRGHpGVK2Zc7a6mx7qEAO7qehgSug3SDImnuMzgmm/wtJALXaz25zUj1PmnNHtShjFgk4PDx4nw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz",
+ "integrity": "sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg==",
"dev": true,
"requires": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-duplicate-keys": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.5.tgz",
- "integrity": "sha512-81tijpDg2a6I1Yhj4aWY1l3O1J4Cg/Pd7LfvuaH2VVInAkXtzibz9+zSPdUM1WvuUi128ksstAP0hM5w48vQgg==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz",
+ "integrity": "sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-exponentiation-operator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.5.tgz",
- "integrity": "sha512-12rba2HwemQPa7BLIKCzm1pT2/RuQHtSFHdNl41cFiC6oi4tcrp7gjB07pxQvFpcADojQywSjblQth6gJyE6CA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz",
+ "integrity": "sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw==",
"dev": true,
"requires": {
- "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-builder-binary-assignment-operator-visitor": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-for-of": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.5.tgz",
- "integrity": "sha512-+DpCAJFPAvViR17PIMi9x2AE34dll5wNlXO43wagAX2YcRGgEVHCNFC4azG85b4YyyFarvkc/iD5NPrz4Oneqw==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.18.8.tgz",
+ "integrity": "sha512-yEfTRnjuskWYo0k1mHUqrVWaZwrdq8AYbfrpqULOJOaucGSp4mNMVps+YtA8byoevxS/urwU75vyhQIxcCgiBQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-function-name": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.5.tgz",
- "integrity": "sha512-Fuec/KPSpVLbGo6z1RPw4EE1X+z9gZk1uQmnYy7v4xr4TO9p41v1AoUuXEtyqAI7H+xNJYSICzRqZBhDEkd3kQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz",
+ "integrity": "sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ==",
"dev": true,
"requires": {
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.5.tgz",
- "integrity": "sha512-B1j9C/IfvshnPcklsc93AVLTrNVa69iSqztylZH6qnmiAsDDOmmjEYqOm3Ts2lGSgTSywnBNiqC949VdD0/gfw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz",
+ "integrity": "sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-member-expression-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.5.tgz",
- "integrity": "sha512-d57i3vPHWgIde/9Y8W/xSFUndhvhZN5Wu2TjRrN1MVz5KzdUihKnfDVlfP1U7mS5DNj/WHHhaE4/tTi4hIyHwQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz",
+ "integrity": "sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-modules-amd": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.5.tgz",
- "integrity": "sha512-oHI15S/hdJuSCfnwIz+4lm6wu/wBn7oJ8+QrkzPPwSFGXk8kgdI/AIKcbR/XnD1nQVMg/i6eNaXpszbGuwYDRQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.18.6.tgz",
+ "integrity": "sha512-Pra5aXsmTsOnjM3IajS8rTaLCy++nGM4v3YR4esk5PCsyg9z8NA5oQLwxzMUtDBd8F+UmVza3VxoAaWCbzH1rg==",
"dev": true,
"requires": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
}
},
"@babel/plugin-transform-modules-commonjs": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.5.tgz",
- "integrity": "sha512-ABhUkxvoQyqhCWyb8xXtfwqNMJD7tx+irIRnUh6lmyFud7Jln1WzONXKlax1fg/ey178EXbs4bSGNd6PngO+SQ==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.18.6.tgz",
+ "integrity": "sha512-Qfv2ZOWikpvmedXQJDSbxNqy7Xr/j2Y8/KfijM0iJyKkBTmWuvCA1yeH1yDM7NJhBW/2aXxeucLj6i80/LAJ/Q==",
"dev": true,
"requires": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-simple-access": "^7.16.0",
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-simple-access": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
}
},
"@babel/plugin-transform-modules-systemjs": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.5.tgz",
- "integrity": "sha512-53gmLdScNN28XpjEVIm7LbWnD/b/TpbwKbLk6KV4KqC9WyU6rq1jnNmVG6UgAdQZVVGZVoik3DqHNxk4/EvrjA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.18.9.tgz",
+ "integrity": "sha512-zY/VSIbbqtoRoJKo2cDTewL364jSlZGvn0LKOf9ntbfxOvjfmyrdtEEOAdswOswhZEb8UH3jDkCKHd1sPgsS0A==",
"dev": true,
"requires": {
- "@babel/helper-hoist-variables": "^7.16.0",
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-hoist-variables": "^7.18.6",
+ "@babel/helper-module-transforms": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-validator-identifier": "^7.18.6",
"babel-plugin-dynamic-import-node": "^2.3.3"
}
},
"@babel/plugin-transform-modules-umd": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.5.tgz",
- "integrity": "sha512-qTFnpxHMoenNHkS3VoWRdwrcJ3FhX567GvDA3hRZKF0Dj8Fmg0UzySZp3AP2mShl/bzcywb/UWAMQIjA1bhXvw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz",
+ "integrity": "sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ==",
"dev": true,
"requires": {
- "@babel/helper-module-transforms": "^7.16.5",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-module-transforms": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-named-capturing-groups-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.5.tgz",
- "integrity": "sha512-/wqGDgvFUeKELW6ex6QB7dLVRkd5ehjw34tpXu1nhKC0sFfmaLabIswnpf8JgDyV2NeDmZiwoOb0rAmxciNfjA==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.18.6.tgz",
+ "integrity": "sha512-UmEOGF8XgaIqD74bC8g7iV3RYj8lMf0Bw7NJzvnS9qQhM4mg+1WHKotUIdjxgD2RGrgFLZZPCFPFj3P/kVDYhg==",
"dev": true,
"requires": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-new-target": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.5.tgz",
- "integrity": "sha512-ZaIrnXF08ZC8jnKR4/5g7YakGVL6go6V9ql6Jl3ecO8PQaQqFE74CuM384kezju7Z9nGCCA20BqZaR1tJ/WvHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz",
+ "integrity": "sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-object-super": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.5.tgz",
- "integrity": "sha512-tded+yZEXuxt9Jdtkc1RraW1zMF/GalVxaVVxh41IYwirdRgyAxxxCKZ9XB7LxZqmsjfjALxupNE1MIz9KH+Zg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz",
+ "integrity": "sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-replace-supers": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "@babel/helper-replace-supers": "^7.18.6"
}
},
"@babel/plugin-transform-parameters": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.5.tgz",
- "integrity": "sha512-B3O6AL5oPop1jAVg8CV+haeUte9oFuY85zu0jwnRNZZi3tVAbJriu5tag/oaO2kGaQM/7q7aGPBlTI5/sr9enA==",
+ "version": "7.18.8",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.18.8.tgz",
+ "integrity": "sha512-ivfbE3X2Ss+Fj8nnXvKJS6sjRG4gzwPMsP+taZC+ZzEGjAYlvENixmt1sZ5Ca6tWls+BlKSGKPJ6OOXvXCbkFg==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-property-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.5.tgz",
- "integrity": "sha512-+IRcVW71VdF9pEH/2R/Apab4a19LVvdVsr/gEeotH00vSDVlKD+XgfSIw+cgGWsjDB/ziqGv/pGoQZBIiQVXHg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz",
+ "integrity": "sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-regenerator": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.5.tgz",
- "integrity": "sha512-2z+it2eVWU8TtQQRauvGUqZwLy4+7rTfo6wO4npr+fvvN1SW30ZF3O/ZRCNmTuu4F5MIP8OJhXAhRV5QMJOuYg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz",
+ "integrity": "sha512-poqRI2+qiSdeldcz4wTSTXBRryoq3Gc70ye7m7UD5Ww0nE29IXqMl6r7Nd15WBgRd74vloEMlShtH6CKxVzfmQ==",
"dev": true,
"requires": {
- "regenerator-transform": "^0.14.2"
+ "@babel/helper-plugin-utils": "^7.18.6",
+ "regenerator-transform": "^0.15.0"
}
},
"@babel/plugin-transform-reserved-words": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.5.tgz",
- "integrity": "sha512-aIB16u8lNcf7drkhXJRoggOxSTUAuihTSTfAcpynowGJOZiGf+Yvi7RuTwFzVYSYPmWyARsPqUGoZWWWxLiknw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz",
+ "integrity": "sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-shorthand-properties": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.5.tgz",
- "integrity": "sha512-ZbuWVcY+MAXJuuW7qDoCwoxDUNClfZxoo7/4swVbOW1s/qYLOMHlm9YRWMsxMFuLs44eXsv4op1vAaBaBaDMVg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz",
+ "integrity": "sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-spread": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.5.tgz",
- "integrity": "sha512-5d6l/cnG7Lw4tGHEoga4xSkYp1euP7LAtrah1h1PgJ3JY7yNsjybsxQAnVK4JbtReZ/8z6ASVmd3QhYYKLaKZw==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.18.9.tgz",
+ "integrity": "sha512-39Q814wyoOPtIB/qGopNIL9xDChOE1pNU0ZY5dO0owhiVt/5kFm4li+/bBtwc7QotG0u5EPzqhZdjMtmqBqyQA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0"
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9"
}
},
"@babel/plugin-transform-sticky-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.5.tgz",
- "integrity": "sha512-usYsuO1ID2LXxzuUxifgWtJemP7wL2uZtyrTVM4PKqsmJycdS4U4mGovL5xXkfUheds10Dd2PjoQLXw6zCsCbg==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz",
+ "integrity": "sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/plugin-transform-template-literals": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.5.tgz",
- "integrity": "sha512-gnyKy9RyFhkovex4BjKWL3BVYzUDG6zC0gba7VMLbQoDuqMfJ1SDXs8k/XK41Mmt1Hyp4qNAvGFb9hKzdCqBRQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz",
+ "integrity": "sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-typeof-symbol": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.5.tgz",
- "integrity": "sha512-ldxCkW180qbrvyCVDzAUZqB0TAeF8W/vGJoRcaf75awm6By+PxfJKvuqVAnq8N9wz5Xa6mSpM19OfVKKVmGHSQ==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz",
+ "integrity": "sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-unicode-escapes": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.5.tgz",
- "integrity": "sha512-shiCBHTIIChGLdyojsKQjoAyB8MBwat25lKM7MJjbe1hE0bgIppD+LX9afr41lLHOhqceqeWl4FkLp+Bgn9o1Q==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz",
+ "integrity": "sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-plugin-utils": "^7.18.9"
}
},
"@babel/plugin-transform-unicode-regex": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.5.tgz",
- "integrity": "sha512-GTJ4IW012tiPEMMubd7sD07iU9O/LOo8Q/oU4xNhcaq0Xn8+6TcUQaHtC8YxySo1T+ErQ8RaWogIEeFhKGNPzw==",
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz",
+ "integrity": "sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA==",
"dev": true,
"requires": {
- "@babel/helper-create-regexp-features-plugin": "^7.16.0",
- "@babel/helper-plugin-utils": "^7.16.5"
+ "@babel/helper-create-regexp-features-plugin": "^7.18.6",
+ "@babel/helper-plugin-utils": "^7.18.6"
}
},
"@babel/preset-env": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.5.tgz",
- "integrity": "sha512-MiJJW5pwsktG61NDxpZ4oJ1CKxM1ncam9bzRtx9g40/WkLRkxFP6mhpkYV0/DxcciqoiHicx291+eUQrXb/SfQ==",
- "dev": true,
- "requires": {
- "@babel/compat-data": "^7.16.4",
- "@babel/helper-compilation-targets": "^7.16.3",
- "@babel/helper-plugin-utils": "^7.16.5",
- "@babel/helper-validator-option": "^7.14.5",
- "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.2",
- "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.0",
- "@babel/plugin-proposal-async-generator-functions": "^7.16.5",
- "@babel/plugin-proposal-class-properties": "^7.16.5",
- "@babel/plugin-proposal-class-static-block": "^7.16.5",
- "@babel/plugin-proposal-dynamic-import": "^7.16.5",
- "@babel/plugin-proposal-export-namespace-from": "^7.16.5",
- "@babel/plugin-proposal-json-strings": "^7.16.5",
- "@babel/plugin-proposal-logical-assignment-operators": "^7.16.5",
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
- "@babel/plugin-proposal-numeric-separator": "^7.16.5",
- "@babel/plugin-proposal-object-rest-spread": "^7.16.5",
- "@babel/plugin-proposal-optional-catch-binding": "^7.16.5",
- "@babel/plugin-proposal-optional-chaining": "^7.16.5",
- "@babel/plugin-proposal-private-methods": "^7.16.5",
- "@babel/plugin-proposal-private-property-in-object": "^7.16.5",
- "@babel/plugin-proposal-unicode-property-regex": "^7.16.5",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.18.10.tgz",
+ "integrity": "sha512-wVxs1yjFdW3Z/XkNfXKoblxoHgbtUF7/l3PvvP4m02Qz9TZ6uZGxRVYjSQeR87oQmHco9zWitW5J82DJ7sCjvA==",
+ "dev": true,
+ "requires": {
+ "@babel/compat-data": "^7.18.8",
+ "@babel/helper-compilation-targets": "^7.18.9",
+ "@babel/helper-plugin-utils": "^7.18.9",
+ "@babel/helper-validator-option": "^7.18.6",
+ "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6",
+ "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9",
+ "@babel/plugin-proposal-async-generator-functions": "^7.18.10",
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
+ "@babel/plugin-proposal-class-static-block": "^7.18.6",
+ "@babel/plugin-proposal-dynamic-import": "^7.18.6",
+ "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
+ "@babel/plugin-proposal-json-strings": "^7.18.6",
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9",
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
+ "@babel/plugin-proposal-numeric-separator": "^7.18.6",
+ "@babel/plugin-proposal-object-rest-spread": "^7.18.9",
+ "@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
+ "@babel/plugin-proposal-optional-chaining": "^7.18.9",
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
+ "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
+ "@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-class-static-block": "^7.14.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3",
+ "@babel/plugin-syntax-import-assertions": "^7.18.6",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
@@ -11414,44 +11746,44 @@
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
- "@babel/plugin-transform-arrow-functions": "^7.16.5",
- "@babel/plugin-transform-async-to-generator": "^7.16.5",
- "@babel/plugin-transform-block-scoped-functions": "^7.16.5",
- "@babel/plugin-transform-block-scoping": "^7.16.5",
- "@babel/plugin-transform-classes": "^7.16.5",
- "@babel/plugin-transform-computed-properties": "^7.16.5",
- "@babel/plugin-transform-destructuring": "^7.16.5",
- "@babel/plugin-transform-dotall-regex": "^7.16.5",
- "@babel/plugin-transform-duplicate-keys": "^7.16.5",
- "@babel/plugin-transform-exponentiation-operator": "^7.16.5",
- "@babel/plugin-transform-for-of": "^7.16.5",
- "@babel/plugin-transform-function-name": "^7.16.5",
- "@babel/plugin-transform-literals": "^7.16.5",
- "@babel/plugin-transform-member-expression-literals": "^7.16.5",
- "@babel/plugin-transform-modules-amd": "^7.16.5",
- "@babel/plugin-transform-modules-commonjs": "^7.16.5",
- "@babel/plugin-transform-modules-systemjs": "^7.16.5",
- "@babel/plugin-transform-modules-umd": "^7.16.5",
- "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.5",
- "@babel/plugin-transform-new-target": "^7.16.5",
- "@babel/plugin-transform-object-super": "^7.16.5",
- "@babel/plugin-transform-parameters": "^7.16.5",
- "@babel/plugin-transform-property-literals": "^7.16.5",
- "@babel/plugin-transform-regenerator": "^7.16.5",
- "@babel/plugin-transform-reserved-words": "^7.16.5",
- "@babel/plugin-transform-shorthand-properties": "^7.16.5",
- "@babel/plugin-transform-spread": "^7.16.5",
- "@babel/plugin-transform-sticky-regex": "^7.16.5",
- "@babel/plugin-transform-template-literals": "^7.16.5",
- "@babel/plugin-transform-typeof-symbol": "^7.16.5",
- "@babel/plugin-transform-unicode-escapes": "^7.16.5",
- "@babel/plugin-transform-unicode-regex": "^7.16.5",
+ "@babel/plugin-transform-arrow-functions": "^7.18.6",
+ "@babel/plugin-transform-async-to-generator": "^7.18.6",
+ "@babel/plugin-transform-block-scoped-functions": "^7.18.6",
+ "@babel/plugin-transform-block-scoping": "^7.18.9",
+ "@babel/plugin-transform-classes": "^7.18.9",
+ "@babel/plugin-transform-computed-properties": "^7.18.9",
+ "@babel/plugin-transform-destructuring": "^7.18.9",
+ "@babel/plugin-transform-dotall-regex": "^7.18.6",
+ "@babel/plugin-transform-duplicate-keys": "^7.18.9",
+ "@babel/plugin-transform-exponentiation-operator": "^7.18.6",
+ "@babel/plugin-transform-for-of": "^7.18.8",
+ "@babel/plugin-transform-function-name": "^7.18.9",
+ "@babel/plugin-transform-literals": "^7.18.9",
+ "@babel/plugin-transform-member-expression-literals": "^7.18.6",
+ "@babel/plugin-transform-modules-amd": "^7.18.6",
+ "@babel/plugin-transform-modules-commonjs": "^7.18.6",
+ "@babel/plugin-transform-modules-systemjs": "^7.18.9",
+ "@babel/plugin-transform-modules-umd": "^7.18.6",
+ "@babel/plugin-transform-named-capturing-groups-regex": "^7.18.6",
+ "@babel/plugin-transform-new-target": "^7.18.6",
+ "@babel/plugin-transform-object-super": "^7.18.6",
+ "@babel/plugin-transform-parameters": "^7.18.8",
+ "@babel/plugin-transform-property-literals": "^7.18.6",
+ "@babel/plugin-transform-regenerator": "^7.18.6",
+ "@babel/plugin-transform-reserved-words": "^7.18.6",
+ "@babel/plugin-transform-shorthand-properties": "^7.18.6",
+ "@babel/plugin-transform-spread": "^7.18.9",
+ "@babel/plugin-transform-sticky-regex": "^7.18.6",
+ "@babel/plugin-transform-template-literals": "^7.18.9",
+ "@babel/plugin-transform-typeof-symbol": "^7.18.9",
+ "@babel/plugin-transform-unicode-escapes": "^7.18.10",
+ "@babel/plugin-transform-unicode-regex": "^7.18.6",
"@babel/preset-modules": "^0.1.5",
- "@babel/types": "^7.16.0",
- "babel-plugin-polyfill-corejs2": "^0.3.0",
- "babel-plugin-polyfill-corejs3": "^0.4.0",
- "babel-plugin-polyfill-regenerator": "^0.3.0",
- "core-js-compat": "^3.19.1",
+ "@babel/types": "^7.18.10",
+ "babel-plugin-polyfill-corejs2": "^0.3.2",
+ "babel-plugin-polyfill-corejs3": "^0.5.3",
+ "babel-plugin-polyfill-regenerator": "^0.4.0",
+ "core-js-compat": "^3.22.1",
"semver": "^6.3.0"
}
},
@@ -11469,9 +11801,9 @@
}
},
"@babel/runtime": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz",
- "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==",
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz",
+ "integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==",
"dev": true,
"requires": {
"regenerator-runtime": "^0.13.4"
@@ -11486,70 +11818,80 @@
}
},
"@babel/template": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.0.tgz",
- "integrity": "sha512-MnZdpFD/ZdYhXwiunMqqgyZyucaYsbL0IrjoGjaVhGilz+x8YB++kRfygSOIj1yOtWKPlx7NBp+9I1RQSgsd5A==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz",
+ "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.16.0",
- "@babel/parser": "^7.16.0",
- "@babel/types": "^7.16.0"
+ "@babel/code-frame": "^7.18.6",
+ "@babel/parser": "^7.18.10",
+ "@babel/types": "^7.18.10"
}
},
"@babel/traverse": {
- "version": "7.16.5",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.5.tgz",
- "integrity": "sha512-FOCODAzqUMROikDYLYxl4nmwiLlu85rNqBML/A5hKRVXG2LV8d0iMqgPzdYTcIpjZEBB7D6UDU9vxRZiriASdQ==",
- "dev": true,
- "requires": {
- "@babel/code-frame": "^7.16.0",
- "@babel/generator": "^7.16.5",
- "@babel/helper-environment-visitor": "^7.16.5",
- "@babel/helper-function-name": "^7.16.0",
- "@babel/helper-hoist-variables": "^7.16.0",
- "@babel/helper-split-export-declaration": "^7.16.0",
- "@babel/parser": "^7.16.5",
- "@babel/types": "^7.16.0",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.10.tgz",
+ "integrity": "sha512-J7ycxg0/K9XCtLyHf0cz2DqDihonJeIo+z+HEdRe9YuT8TY4A66i+Ab2/xZCEW7Ro60bPCBBfqqboHSamoV3+g==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.18.6",
+ "@babel/generator": "^7.18.10",
+ "@babel/helper-environment-visitor": "^7.18.9",
+ "@babel/helper-function-name": "^7.18.9",
+ "@babel/helper-hoist-variables": "^7.18.6",
+ "@babel/helper-split-export-declaration": "^7.18.6",
+ "@babel/parser": "^7.18.10",
+ "@babel/types": "^7.18.10",
"debug": "^4.1.0",
"globals": "^11.1.0"
}
},
"@babel/types": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.0.tgz",
- "integrity": "sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg==",
+ "version": "7.18.10",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.18.10.tgz",
+ "integrity": "sha512-MJvnbEiiNkpjo+LknnmRrqbY1GPUUggjv+wQVjetM/AONoupqRALB7I6jGqNUAZsKcRIEu2J6FRFvsczljjsaQ==",
"dev": true,
"requires": {
- "@babel/helper-validator-identifier": "^7.15.7",
+ "@babel/helper-string-parser": "^7.18.10",
+ "@babel/helper-validator-identifier": "^7.18.6",
"to-fast-properties": "^2.0.0"
}
},
"@eslint/eslintrc": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz",
- "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
+ "integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
- "espree": "^9.2.0",
- "globals": "^13.9.0",
- "ignore": "^4.0.6",
+ "espree": "^9.3.2",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
- "minimatch": "^3.0.4",
+ "minimatch": "^3.1.2",
"strip-json-comments": "^3.1.1"
},
"dependencies": {
"globals": {
- "version": "13.12.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz",
- "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==",
+ "version": "13.17.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
+ "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"dev": true,
"requires": {
"type-fest": "^0.20.2"
}
},
+ "minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
"type-fest": {
"version": "0.20.2",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
@@ -11559,9 +11901,9 @@
}
},
"@humanwhocodes/config-array": {
- "version": "0.9.2",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz",
- "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==",
+ "version": "0.10.4",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz",
+ "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==",
"dev": true,
"requires": {
"@humanwhocodes/object-schema": "^1.2.1",
@@ -11569,12 +11911,56 @@
"minimatch": "^3.0.4"
}
},
+ "@humanwhocodes/gitignore-to-minimatch": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz",
+ "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==",
+ "dev": true
+ },
"@humanwhocodes/object-schema": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true
},
+ "@jridgewell/gen-mapping": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
+ "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/set-array": "^1.0.0",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
+ "@jridgewell/resolve-uri": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
+ "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==",
+ "dev": true
+ },
+ "@jridgewell/set-array": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
+ "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
+ "dev": true
+ },
+ "@jridgewell/sourcemap-codec": {
+ "version": "1.4.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
+ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
+ "dev": true
+ },
+ "@jridgewell/trace-mapping": {
+ "version": "0.3.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz",
+ "integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -11602,9 +11988,9 @@
}
},
"@popperjs/core": {
- "version": "2.11.0",
- "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.0.tgz",
- "integrity": "sha512-zrsUxjLOKAzdewIDRWy9nsV1GQsKBCWaGwsZQlCgr6/q+vjyZhFgqedLfFBuI9anTPEUT4APq9Mu0SZBTzIcGQ==",
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz",
+ "integrity": "sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw==",
"peer": true
},
"@sindresorhus/is": {
@@ -11635,9 +12021,9 @@
}
},
"@types/google-apps-script": {
- "version": "1.0.41",
- "resolved": "https://registry.npmjs.org/@types/google-apps-script/-/google-apps-script-1.0.41.tgz",
- "integrity": "sha512-Lv8Tila1iNUynITT0H4lR59fcdkZ1JOPQiuthaOoG/agAbWYkZLeaR6yLIeRydFQ2bQqVgOrAXlmu8Ut8uUcOA==",
+ "version": "1.0.53",
+ "resolved": "https://registry.npmjs.org/@types/google-apps-script/-/google-apps-script-1.0.53.tgz",
+ "integrity": "sha512-aFDrrqxhCcbM8h4hNID41HqhFWSwKsCCs9y99vbZdwNr5yeAW9ZcmQiNDp+P3BEL0nsR/rn5wt5Hv4kvyAU3Wg==",
"dev": true
},
"@types/http-cache-semantics": {
@@ -11656,9 +12042,9 @@
}
},
"@types/lodash": {
- "version": "4.14.178",
- "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz",
- "integrity": "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==",
+ "version": "4.14.182",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz",
+ "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==",
"dev": true
},
"@types/minimatch": {
@@ -11698,9 +12084,9 @@
}
},
"acorn": {
- "version": "8.6.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz",
- "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
"dev": true
},
"acorn-jsx": {
@@ -11741,12 +12127,6 @@
"uri-js": "^4.2.2"
}
},
- "ansi-colors": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
- "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
- "dev": true
- },
"ansi-escapes": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
@@ -12210,33 +12590,33 @@
}
},
"babel-plugin-polyfill-corejs2": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.0.tgz",
- "integrity": "sha512-wMDoBJ6uG4u4PNFh72Ty6t3EgfA91puCuAwKIazbQlci+ENb/UU9A3xG5lutjUIiXCIn1CY5L15r9LimiJyrSA==",
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.2.tgz",
+ "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==",
"dev": true,
"requires": {
- "@babel/compat-data": "^7.13.11",
- "@babel/helper-define-polyfill-provider": "^0.3.0",
+ "@babel/compat-data": "^7.17.7",
+ "@babel/helper-define-polyfill-provider": "^0.3.2",
"semver": "^6.1.1"
}
},
"babel-plugin-polyfill-corejs3": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.4.0.tgz",
- "integrity": "sha512-YxFreYwUfglYKdLUGvIF2nJEsGwj+RhWSX/ije3D2vQPOXuyMLMtg/cCGMDpOA7Nd+MwlNdnGODbd2EwUZPlsw==",
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.3.tgz",
+ "integrity": "sha512-zKsXDh0XjnrUEW0mxIHLfjBfnXSMr5Q/goMe/fxpQnLm07mcOZiIZHBNWCMx60HmdvjxfXcalac0tfFg0wqxyw==",
"dev": true,
"requires": {
- "@babel/helper-define-polyfill-provider": "^0.3.0",
- "core-js-compat": "^3.18.0"
+ "@babel/helper-define-polyfill-provider": "^0.3.2",
+ "core-js-compat": "^3.21.0"
}
},
"babel-plugin-polyfill-regenerator": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.0.tgz",
- "integrity": "sha512-dhAPTDLGoMW5/84wkgwiLRwMnio2i1fUe53EuvtKMv0pn2p3S8OCoV1xAzfJPl0KOX7IB89s2ib85vbYiea3jg==",
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.0.tgz",
+ "integrity": "sha512-RW1cnryiADFeHmfLS+WW/G431p1PsW5qdRdz0SDRi7TKcUgc7Oh/uXkT7MZ/+tGsT1BkczEAmD5XjUyJ5SWDTw==",
"dev": true,
"requires": {
- "@babel/helper-define-polyfill-provider": "^0.3.0"
+ "@babel/helper-define-polyfill-provider": "^0.3.2"
}
},
"babel-plugin-transform-es5-property-mutators": {
@@ -12475,9 +12855,9 @@
}
},
"bootstrap": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
- "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
+ "integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
"requires": {}
},
"brace-expansion": {
@@ -12509,16 +12889,15 @@
}
},
"browserslist": {
- "version": "4.19.1",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz",
- "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==",
+ "version": "4.21.3",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz",
+ "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==",
"dev": true,
"requires": {
- "caniuse-lite": "^1.0.30001286",
- "electron-to-chromium": "^1.4.17",
- "escalade": "^3.1.1",
- "node-releases": "^2.0.1",
- "picocolors": "^1.0.0"
+ "caniuse-lite": "^1.0.30001370",
+ "electron-to-chromium": "^1.4.202",
+ "node-releases": "^2.0.6",
+ "update-browserslist-db": "^1.0.5"
}
},
"buffer": {
@@ -12610,9 +12989,9 @@
"dev": true
},
"caniuse-lite": {
- "version": "1.0.30001292",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001292.tgz",
- "integrity": "sha512-jnT4Tq0Q4ma+6nncYQVe7d73kmDmE9C3OGTx3MvW7lBM/eY1S1DZTMBON7dqV481RhNiS5OxD7k9JQvmDOTirw==",
+ "version": "1.0.30001373",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001373.tgz",
+ "integrity": "sha512-pJYArGHrPp3TUqQzFYRmP/lwJlj8RCbVe3Gd3eJQkAV8SAC6b19XS9BjMvRdvaS8RMkaTN8ZhoHP6S1y8zzwEQ==",
"dev": true
},
"chalk": {
@@ -12920,12 +13299,12 @@
"dev": true
},
"core-js-compat": {
- "version": "3.20.0",
- "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.20.0.tgz",
- "integrity": "sha512-relrah5h+sslXssTTOkvqcC/6RURifB0W5yhYBdBkaPYa5/2KBMiog3XiD+s3TwEHWxInWVv4Jx2/Lw0vng+IQ==",
+ "version": "3.24.1",
+ "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.24.1.tgz",
+ "integrity": "sha512-XhdNAGeRnTpp8xbD+sR/HFDK9CbeeeqXT6TuofXh3urqEevzkWmLRgrVoykodsw8okqo2pu1BOmuCKrHx63zdw==",
"dev": true,
"requires": {
- "browserslist": "^4.19.1",
+ "browserslist": "^4.21.3",
"semver": "7.0.0"
},
"dependencies": {
@@ -13080,19 +13459,19 @@
}
},
"del": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
- "integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/del/-/del-7.0.0.tgz",
+ "integrity": "sha512-tQbV/4u5WVB8HMJr08pgw0b6nG4RGt/tj+7Numvq+zqcvUFeMaIWWOUFltiU+6go8BSO2/ogsB4EasDaj0y68Q==",
"dev": true,
"requires": {
- "globby": "^11.0.1",
- "graceful-fs": "^4.2.4",
- "is-glob": "^4.0.1",
- "is-path-cwd": "^2.2.0",
- "is-path-inside": "^3.0.2",
- "p-map": "^4.0.0",
+ "globby": "^13.1.2",
+ "graceful-fs": "^4.2.10",
+ "is-glob": "^4.0.3",
+ "is-path-cwd": "^3.0.0",
+ "is-path-inside": "^4.0.0",
+ "p-map": "^5.5.0",
"rimraf": "^3.0.2",
- "slash": "^3.0.0"
+ "slash": "^4.0.0"
}
},
"detect-file": {
@@ -13172,9 +13551,9 @@
}
},
"electron-to-chromium": {
- "version": "1.4.26",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.26.tgz",
- "integrity": "sha512-cA1YwlRzO6TGp7yd3+KAqh9Tt6Z4CuuKqsAJP6uF/H5MQryjAGDhMhnY5cEXo8MaRCczpzSBhMPdqRIodkbZYw==",
+ "version": "1.4.208",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.208.tgz",
+ "integrity": "sha512-diMr4t69FigAGUk2KovP0bygEtN/9AkqEVkzjEp0cu+zFFbZMVvwACpTTfuj1mAmFR5kNoSW8wGKDFWIvmThiQ==",
"dev": true
},
"emoji-regex": {
@@ -13192,15 +13571,6 @@
"once": "^1.4.0"
}
},
- "enquirer": {
- "version": "2.3.6",
- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
- "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
- "dev": true,
- "requires": {
- "ansi-colors": "^4.1.1"
- }
- },
"error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -13267,32 +13637,35 @@
"dev": true
},
"eslint": {
- "version": "8.5.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.5.0.tgz",
- "integrity": "sha512-tVGSkgNbOfiHyVte8bCM8OmX+xG9PzVG/B4UCF60zx7j61WIVY/AqJECDgpLD4DbbESD0e174gOg3ZlrX15GDg==",
+ "version": "8.21.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.21.0.tgz",
+ "integrity": "sha512-/XJ1+Qurf1T9G2M5IHrsjp+xrGT73RZf23xA1z5wB1ZzzEAWSZKvRwhWxTFp1rvkvCfwcvAUNAP31bhKTTGfDA==",
"dev": true,
"requires": {
- "@eslint/eslintrc": "^1.0.5",
- "@humanwhocodes/config-array": "^0.9.2",
+ "@eslint/eslintrc": "^1.3.0",
+ "@humanwhocodes/config-array": "^0.10.4",
+ "@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
- "enquirer": "^2.3.5",
"escape-string-regexp": "^4.0.0",
- "eslint-scope": "^7.1.0",
+ "eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
- "eslint-visitor-keys": "^3.1.0",
- "espree": "^9.2.0",
+ "eslint-visitor-keys": "^3.3.0",
+ "espree": "^9.3.3",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
+ "find-up": "^5.0.0",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
- "globals": "^13.6.0",
- "ignore": "^4.0.6",
+ "globals": "^13.15.0",
+ "globby": "^11.1.0",
+ "grapheme-splitter": "^1.0.4",
+ "ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
@@ -13300,12 +13673,10 @@
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash.merge": "^4.6.2",
- "minimatch": "^3.0.4",
+ "minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
- "progress": "^2.0.0",
"regexpp": "^3.2.0",
- "semver": "^7.2.1",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.0",
"text-table": "^0.2.0",
@@ -13352,6 +13723,16 @@
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true
},
+ "find-up": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^6.0.0",
+ "path-exists": "^4.0.0"
+ }
+ },
"glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
@@ -13362,29 +13743,76 @@
}
},
"globals": {
- "version": "13.12.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz",
- "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==",
+ "version": "13.17.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
+ "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"dev": true,
"requires": {
"type-fest": "^0.20.2"
}
},
+ "globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dev": true,
+ "requires": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ }
+ },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
- "semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
+ "locate-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^5.0.0"
+ }
+ },
+ "minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
+ "p-limit": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
+ "dev": true,
+ "requires": {
+ "yocto-queue": "^0.1.0"
+ }
+ },
+ "p-locate": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dev": true,
"requires": {
- "lru-cache": "^6.0.0"
+ "p-limit": "^3.0.2"
}
},
+ "slash": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "dev": true
+ },
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -13410,9 +13838,9 @@
"requires": {}
},
"eslint-config-prettier": {
- "version": "8.3.0",
- "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz",
- "integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==",
+ "version": "8.5.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
+ "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"requires": {}
},
@@ -13426,18 +13854,18 @@
}
},
"eslint-plugin-prettier": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz",
- "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==",
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz",
+ "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-scope": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz",
- "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==",
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz",
+ "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==",
"dev": true,
"requires": {
"esrecurse": "^4.3.0",
@@ -13462,20 +13890,20 @@
}
},
"eslint-visitor-keys": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz",
- "integrity": "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
+ "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
"dev": true
},
"espree": {
- "version": "9.2.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz",
- "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==",
+ "version": "9.3.3",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.3.tgz",
+ "integrity": "sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng==",
"dev": true,
"requires": {
- "acorn": "^8.6.0",
- "acorn-jsx": "^5.3.1",
- "eslint-visitor-keys": "^3.1.0"
+ "acorn": "^8.8.0",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^3.3.0"
}
},
"esquery": {
@@ -13694,9 +14122,9 @@
"dev": true
},
"fast-glob": {
- "version": "3.2.7",
- "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz",
- "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
+ "version": "3.2.11",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz",
+ "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
@@ -14051,9 +14479,9 @@
}
},
"form-data-encoder": {
- "version": "1.7.1",
- "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz",
- "integrity": "sha512-EFRDrsMm/kyqbTQocNvRXMLjc7Es2Vk+IQFx/YW7hkUH1eBl4J1fqiP34l74Yt0pFLCNpc06fkbVk00008mzjg==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-2.0.1.tgz",
+ "integrity": "sha512-Oy+P9w5mnO4TWXVgUiQvggNKPI9/ummcSt5usuIV6HkaLKigwzPpoenhEqmGmx3zHqm6ZLJ+CR/99N8JLinaEw==",
"dev": true
},
"fragment-cache": {
@@ -14314,25 +14742,16 @@
"dev": true
},
"globby": {
- "version": "11.0.4",
- "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
- "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
+ "version": "13.1.2",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",
+ "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",
"dev": true,
"requires": {
- "array-union": "^2.1.0",
"dir-glob": "^3.0.1",
- "fast-glob": "^3.1.1",
- "ignore": "^5.1.4",
- "merge2": "^1.3.0",
- "slash": "^3.0.0"
- },
- "dependencies": {
- "ignore": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
- "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
- "dev": true
- }
+ "fast-glob": "^3.2.11",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^4.0.0"
}
},
"glogg": {
@@ -14395,26 +14814,32 @@
}
},
"got": {
- "version": "12.0.0",
- "resolved": "https://registry.npmjs.org/got/-/got-12.0.0.tgz",
- "integrity": "sha512-gNNNghQ1yw0hyzie1FLK6gY90BQlXU9zSByyRygnbomHPruKQ6hAKKbpO1RfNZp8b+qNzNipGeRG3tUelKcVsA==",
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/got/-/got-12.3.0.tgz",
+ "integrity": "sha512-7uK06aluHF0UibYFBX3lFUZ2FG/W0KS4O4EqAIrbWIdbPxIT33r6ZJy7Zy+pdh0CP/ZbF3zBa7Fd9dCn7vGPBg==",
"dev": true,
"requires": {
- "@sindresorhus/is": "^4.2.0",
+ "@sindresorhus/is": "^5.2.0",
"@szmarczak/http-timer": "^5.0.1",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.4",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
- "form-data-encoder": "1.7.1",
+ "form-data-encoder": "^2.0.1",
"get-stream": "^6.0.1",
- "http2-wrapper": "^2.1.9",
+ "http2-wrapper": "^2.1.10",
"lowercase-keys": "^3.0.0",
"p-cancelable": "^3.0.0",
"responselike": "^2.0.0"
},
"dependencies": {
+ "@sindresorhus/is": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.3.0.tgz",
+ "integrity": "sha512-CX6t4SYQ37lzxicAqsBtxA3OseeoVrh9cSJ5PFYam0GksYlupRfy1A+Q4aYD3zvcfECLc0zO2u+ZnR2UYKvCrw==",
+ "dev": true
+ },
"get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
@@ -14436,9 +14861,15 @@
}
},
"graceful-fs": {
- "version": "4.2.8",
- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
- "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
+ "version": "4.2.10",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
+ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
+ "dev": true
+ },
+ "grapheme-splitter": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
+ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==",
"dev": true
},
"gtoken": {
@@ -14678,9 +15109,9 @@
"dev": true
},
"ignore": {
- "version": "4.0.6",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
- "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
+ "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
"dev": true
},
"import-fresh": {
@@ -15008,15 +15439,15 @@
}
},
"is-path-cwd": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
- "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-3.0.0.tgz",
+ "integrity": "sha512-kyiNFFLU0Ampr6SDZitD/DwUo4Zs1nSdnygUBqsu3LooL00Qvb5j+UnvApUn/TTj1J3OuE6BTdQ5rudKmU2ZaA==",
"dev": true
},
"is-path-inside": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
- "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz",
+ "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==",
"dev": true
},
"is-plain-object": {
@@ -15233,18 +15664,15 @@
"dev": true
},
"json5": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
- "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==",
- "dev": true,
- "requires": {
- "minimist": "^1.2.5"
- }
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
+ "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
+ "dev": true
},
"jsonata": {
- "version": "1.8.5",
- "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.5.tgz",
- "integrity": "sha512-ilDyTBkg6qhNoNVr8PUPzz5GYvRK+REKOM5MdOGzH2y6V4yvPRMegSvbZLpbTtI0QAgz09QM7drDhSHUlwp9pA=="
+ "version": "1.8.6",
+ "resolved": "https://registry.npmjs.org/jsonata/-/jsonata-1.8.6.tgz",
+ "integrity": "sha512-ZH2TPYdNP2JecOl/HvrH47Xc+9imibEMQ4YqKy/F/FrM+2a6vfbGxeCX23dB9Fr6uvGwv+ghf1KxWB3iZk09wA=="
},
"jsonfile": {
"version": "6.1.0",
@@ -15429,7 +15857,7 @@
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
- "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
+ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
"dev": true
},
"lodash.merge": {
@@ -15722,13 +16150,13 @@
"dev": true
},
"micromatch": {
- "version": "4.0.4",
- "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
- "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
+ "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true,
"requires": {
- "braces": "^3.0.1",
- "picomatch": "^2.2.3"
+ "braces": "^3.0.2",
+ "picomatch": "^2.3.1"
},
"dependencies": {
"braces": {
@@ -15983,9 +16411,9 @@
"dev": true
},
"node-releases": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz",
- "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==",
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
+ "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==",
"dev": true
},
"normalize-newline": {
@@ -16313,12 +16741,45 @@
}
},
"p-map": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
- "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/p-map/-/p-map-5.5.0.tgz",
+ "integrity": "sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg==",
"dev": true,
"requires": {
- "aggregate-error": "^3.0.0"
+ "aggregate-error": "^4.0.0"
+ },
+ "dependencies": {
+ "aggregate-error": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-4.0.1.tgz",
+ "integrity": "sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w==",
+ "dev": true,
+ "requires": {
+ "clean-stack": "^4.0.0",
+ "indent-string": "^5.0.0"
+ }
+ },
+ "clean-stack": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz",
+ "integrity": "sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg==",
+ "dev": true,
+ "requires": {
+ "escape-string-regexp": "5.0.0"
+ }
+ },
+ "escape-string-regexp": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
+ "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
+ "dev": true
+ },
+ "indent-string": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz",
+ "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==",
+ "dev": true
+ }
}
},
"p-some": {
@@ -16454,9 +16915,9 @@
"dev": true
},
"picomatch": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
- "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true
},
"pify": {
@@ -16550,9 +17011,9 @@
"dev": true
},
"prettier": {
- "version": "2.5.1",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz",
- "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==",
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
+ "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true
},
"prettier-linter-helpers": {
@@ -16576,12 +17037,6 @@
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true
},
- "progress": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
- "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
- "dev": true
- },
"pump": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
@@ -16834,9 +17289,9 @@
"dev": true
},
"regenerate-unicode-properties": {
- "version": "9.0.0",
- "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-9.0.0.tgz",
- "integrity": "sha512-3E12UeNSPfjrgwjkR81m5J7Aw/T55Tu7nUyZVQYCKEOs+2dkxEY+DpPtZzO4YruuiPb7NkYLVcyJC4+zCbk5pA==",
+ "version": "10.0.1",
+ "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz",
+ "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==",
"dev": true,
"requires": {
"regenerate": "^1.4.2"
@@ -16849,9 +17304,9 @@
"dev": true
},
"regenerator-transform": {
- "version": "0.14.5",
- "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz",
- "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==",
+ "version": "0.15.0",
+ "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz",
+ "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==",
"dev": true,
"requires": {
"@babel/runtime": "^7.8.4"
@@ -16904,29 +17359,29 @@
"dev": true
},
"regexpu-core": {
- "version": "4.8.0",
- "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.8.0.tgz",
- "integrity": "sha512-1F6bYsoYiz6is+oz70NWur2Vlh9KWtswuRuzJOfeYUrfPX2o8n74AnUVaOGDbUqVGO9fNHu48/pjJO4sNVwsOg==",
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.1.0.tgz",
+ "integrity": "sha512-bb6hk+xWd2PEOkj5It46A16zFMs2mv86Iwpdu94la4S3sJ7C973h2dHpYKwIBGaWSO7cIRJ+UX0IeMaWcO4qwA==",
"dev": true,
"requires": {
"regenerate": "^1.4.2",
- "regenerate-unicode-properties": "^9.0.0",
- "regjsgen": "^0.5.2",
- "regjsparser": "^0.7.0",
+ "regenerate-unicode-properties": "^10.0.1",
+ "regjsgen": "^0.6.0",
+ "regjsparser": "^0.8.2",
"unicode-match-property-ecmascript": "^2.0.0",
"unicode-match-property-value-ecmascript": "^2.0.0"
}
},
"regjsgen": {
- "version": "0.5.2",
- "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz",
- "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==",
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz",
+ "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==",
"dev": true
},
"regjsparser": {
- "version": "0.7.0",
- "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.7.0.tgz",
- "integrity": "sha512-A4pcaORqmNMDVwUjWoTzuhwMGpP+NykpfqAsEgI1FSH/EzC7lrN5TMd+kN8YCovX+jMpu8eaqXgXPCa0g8FQNQ==",
+ "version": "0.8.4",
+ "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz",
+ "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==",
"dev": true,
"requires": {
"jsesc": "~0.5.0"
@@ -16935,7 +17390,7 @@
"jsesc": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
- "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
+ "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==",
"dev": true
}
}
@@ -17252,9 +17707,9 @@
"dev": true
},
"slash": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
- "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz",
+ "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==",
"dev": true
},
"slice-ansi": {
@@ -17880,9 +18335,9 @@
"dev": true
},
"uglify-js": {
- "version": "3.14.5",
- "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.5.tgz",
- "integrity": "sha512-qZukoSxOG0urUTvjc2ERMTcAy+BiFh3weWAkeurLwjrCba73poHmG3E36XEjd/JGukMzwTL7uCxZiAexj8ppvQ==",
+ "version": "3.16.3",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.16.3.tgz",
+ "integrity": "sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==",
"dev": true
},
"unc-path-regex": {
@@ -18025,6 +18480,16 @@
"integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
"dev": true
},
+ "update-browserslist-db": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz",
+ "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==",
+ "dev": true,
+ "requires": {
+ "escalade": "^3.1.1",
+ "picocolors": "^1.0.0"
+ }
+ },
"uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@@ -18441,6 +18906,12 @@
"camelcase": "^3.0.0",
"object.assign": "^4.1.0"
}
+ },
+ "yocto-queue": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
+ "dev": true
}
}
}
diff --git a/package.json b/package.json
index cd9da43..2243fe3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "google-apps-script-snippets",
- "version": "1.1.6-24",
+ "version": "1.1.6-25",
"description": "Google Apps Script Snippets",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
@@ -18,30 +18,30 @@
},
"homepage": "https://github.com/contributorpw/google-apps-script-snippets#readme",
"devDependencies": {
- "@babel/core": "^7.12.10",
- "@babel/preset-env": "^7.12.11",
- "@types/google-apps-script": "^1.0.20",
- "@types/lodash": "^4.14.165",
+ "@babel/core": "^7.18.10",
+ "@babel/preset-env": "^7.18.10",
+ "@types/google-apps-script": "^1.0.53",
+ "@types/lodash": "^4.14.182",
"babel-plugin-transform-es5-property-mutators": "^6.24.1",
- "del": "^6.0.0",
- "eslint": "^8.5.0",
+ "del": "^7.0.0",
+ "eslint": "^8.21.0",
"eslint-config-google": "^0.14.0",
- "eslint-config-prettier": "^8.1.0",
+ "eslint-config-prettier": "^8.5.0",
"eslint-plugin-googleappsscript": "^1.0.3",
- "eslint-plugin-prettier": "^4.0.0",
+ "eslint-plugin-prettier": "^4.2.1",
"forked-clasp": "^2.11.2",
- "got": "^12.0.0",
+ "got": "^12.3.0",
"gulp": "^4.0.2",
"gulp-file-include": "^2.3.0",
"merge-stream": "^2.0.0",
- "prettier": "^2.2.1",
- "uglify-js": "^3.13.10"
+ "prettier": "^2.7.1",
+ "uglify-js": "^3.16.3"
},
"dependencies": {
- "bootstrap": "^5.1.3",
+ "bootstrap": "^5.2.0",
"jaro-winkler": "^0.2.8",
"jquery": "^3.5.1",
- "jsonata": "^1.8.4",
+ "jsonata": "^1.8.6",
"xml-js": "^1.6.11"
},
"devSettings": {
diff --git a/readme.md b/readme.md
index 0d34003..dc115f7 100644
--- a/readme.md
+++ b/readme.md
@@ -52,11 +52,7 @@ _example [/issues/3](../../issues/3)_
function ll_() {
var args = [];
for (var i = 0; i < arguments.length; i++) {
- args.push(
- typeof arguments[i] === 'object'
- ? '' + JSON.stringify(arguments[i], null, ' ')
- : '' + arguments[i]
- );
+ args.push(typeof arguments[i] === 'object' ? '' + JSON.stringify(arguments[i], null, ' ') : '' + arguments[i]);
}
if (!/%s/.test(args[0])) {
args.unshift(new Array(args.length).join('\n%s'));
@@ -88,8 +84,7 @@ function createSpreadsheetRC(name, rows, columns, folder, add) {
var spreadsheet = SpreadsheetApp.create.apply(SpreadsheetApp, args);
if (folder) {
- folder =
- typeof folder === 'object' ? folder : DriveApp.getFolderById(folder);
+ folder = typeof folder === 'object' ? folder : DriveApp.getFolderById(folder);
add = !!add;
var child = DriveApp.getFileById(spreadsheet.getId());
@@ -189,14 +184,7 @@ like [appendRow(rowContents)](
+
# Google Apps Script Snippets
+
## Gists
+
- [The Modal Dialog][1] works longer than the Prompt.
- [Visibility Browser API][2] for sidebars & add-ons
- [Set content to file, get content from file][3]
@@ -37,23 +40,27 @@
[4]: https://gist.github.com/oshliaer/0801f151fb57a4bee7f2
## Spreadsheet (Class)
+
### getWorkSpreadsheet
+
Basic settings workflow
+
```javascript
function getWorkSpreadsheet() {
- var spreadsheet, spreadsheetId = getUserProperties().spreadsheetId;
+ var spreadsheet,
+ spreadsheetId = getUserProperties().spreadsheetId;
try {
spreadsheet = SpreadsheetApp.openById(spreadsheetId);
} catch (err) {
spreadsheet = SpreadsheetApp.create('.appsheet');
setUserProperties({
- spreadsheetId: spreadsheet.getId()
+ spreadsheetId: spreadsheet.getId(),
});
}
return {
spreadsheetId: spreadsheetId,
- name: spreadsheet.getName()
- }
+ name: spreadsheet.getName(),
+ };
}
function getUserProperties() {
@@ -66,85 +73,113 @@ function setUserProperties(properties) {
```
### cropSheetBySize(sheet, leftRows, topCols)
+
Prettify the given sheet cropping it
+
```javascript
-function cropSheetBySize(sheet, leftRows, topCols){
- (leftRows && sheet.getMaxRows() > leftRows) &&
- sheet.deleteRows(leftRows + 1, sheet.getMaxRows() - leftRows);
- (topCols && sheet.getMaxColumns() > topCols) &&
- sheet.deleteColumns(topCols + 1, sheet.getMaxColumns() - topCols);
+function cropSheetBySize(sheet, leftRows, topCols) {
+ leftRows && sheet.getMaxRows() > leftRows && sheet.deleteRows(leftRows + 1, sheet.getMaxRows() - leftRows);
+ topCols && sheet.getMaxColumns() > topCols && sheet.deleteColumns(topCols + 1, sheet.getMaxColumns() - topCols);
return sheet;
}
```
+
#### Example
+
```javascript
- cropSheetBySize(sheet, 2, 3);
+cropSheetBySize(sheet, 2, 3);
```
+
### cropSheetByData(sheet)
+
Prettify the given sheet cropping it
+
```javascript
-function cropSheetByData(sheet){
+function cropSheetByData(sheet) {
return cropSheetBySize(sheet, sheet.getLastRow(), sheet.getLastColumn());
}
```
+
#### Example
+
```javascript
- sheet.clearContents().getRange(2, 1, values.length, values[0].length).setValues(values);
- cropSheetByData(sheet);
+sheet.clearContents().getRange(2, 1, values.length, values[0].length).setValues(values);
+cropSheetByData(sheet);
```
+
### flushAndSleep(milliseconds)
+
Give your tables to cool down. Don't use with loops
+
```javascript
-function flushAndSleep(milliseconds){
+function flushAndSleep(milliseconds) {
SpreadsheetApp.flush();
Utilities.sleep(milliseconds || 100);
}
```
+
### onOpen() Move to last cell in specific worksheet [Simple]
+
```javascript
- var name = 'Sheet1';
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(name);
- sheet.getRange(sheet.getLastRow(), 1).activate();
+var name = 'Sheet1';
+var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(name);
+sheet.getRange(sheet.getLastRow(), 1).activate();
```
+
### onOpen() Move to last cell in specific worksheet [Advanced]
+
```javascript
-function onOpen(){
+function onOpen() {
var gid = '792071603';
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
- var uidsMap = sheets.reduce(function(p,c,i){p[c.getSheetId()]=i;return p;},{});
+ var uidsMap = sheets.reduce(function (p, c, i) {
+ p[c.getSheetId()] = i;
+ return p;
+ }, {});
var sheet = sheets[uidsMap[gid]];
sheet.getRange(sheet.getLastRow(), 1).activate();
}
```
+
## Spreradsheet (Arrays)
+
### mapSheetHeaders(headers)
+
Map headers of a 2d array
+
```javascript
function mapSheetHeaders(headers) {
- var map = headers.reduce(function(pV, cV, i){
+ var map = headers.reduce(function (pV, cV, i) {
pV[cV] = i;
return pV;
}, {});
return map;
}
```
+
### Example
+
```javascript
var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
var headers = mapSheetHeaders(values.shift());
```
+
## DriveApp
+
### moveFileToFolder(file, folder, stayRoot)
+
Move file to folder
+
```javascript
-function moveFileToFolder(file, folder, stayRoot){
+function moveFileToFolder(file, folder, stayRoot) {
folder.addFile(file);
- if(stayRoot !== true)
- DriveApp.getRootFolder().removeFile(file);
+ if (stayRoot !== true) DriveApp.getRootFolder().removeFile(file);
return file;
}
```
+
### Example
+
```javascript
var folderId = '6630c884839571e483ed';
var folder = DriveApp.getFolderById(folderId);
@@ -152,28 +187,40 @@ var fileID = 'a8a398e30e79d0cc59a8';
var file = DriveApp.getFileById(fileID);
moveFileToFolder(file, folder);
```
+
## Extends and override
+
### Short `Utilities.formatDate`
+
```javascript
function ufd_() {
return Utilities.formatDate.apply(Utilities, arguments);
}
```
+
### Short `Utilities.formatString`
+
```javascript
function ufs_() {
return Utilities.formatString.apply(Utilities, arguments);
}
```
+
### getArray(length, defaultValue)
+
Initialize an array with length and default values
+
```javascript
-function getArray(length, defaultValue){
- return Array.apply(null, Array(length)).map(function () {return this;}, defaultValue);
+function getArray(length, defaultValue) {
+ return Array.apply(null, Array(length)).map(function () {
+ return this;
+ }, defaultValue);
}
```
+
### Example
+
```javascript
- var arr = getArray(5, '');
- //['', '', '', '', '']
-```
\ No newline at end of file
+var arr = getArray(5, '');
+//['', '', '', '', '']
+```
diff --git a/recast/gapps/gilp-simple-project.js b/recast/gapps/gilp-simple-project.js
index 38aa04c..1ac785e 100644
--- a/recast/gapps/gilp-simple-project.js
+++ b/recast/gapps/gilp-simple-project.js
@@ -13,7 +13,7 @@ var knownOptions = {
};
*/
-var options = minimist(process.argv.slice(2)/*, knownOptions*/);
+var options = minimist(process.argv.slice(2) /*, knownOptions*/);
var vp = require('vinyl-paths');
// var strip = require('gulp-strip-comments');
// var removeEmptyLines = require('gulp-remove-empty-lines');
@@ -27,14 +27,11 @@ gulp.task('default', ['src'], function (cb) {
});
gulp.task('clean', function () {
- del([
- 'src/*'
- ]);
+ del(['src/*']);
});
gulp.task('src', ['clean'], function () {
- gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js'])
- .pipe(gulp.dest('src'));
+ gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js']).pipe(gulp.dest('src'));
// gulp.src('node_modules/alasql/dist/alasql.js')
// .pipe(removeEmptyLines({
// removeComments: true
@@ -45,22 +42,17 @@ gulp.task('src', ['clean'], function () {
});
gulp.task('init', ['gappsinit'], function () {
- gulp.src('src/*')
- .pipe(gulp.dest('app'));
+ gulp.src('src/*').pipe(gulp.dest('app'));
});
gulp.task('cleanbup', function () {
- del([
- '.backups'
- ]);
+ del(['.backups']);
});
gulp.task('gs', function (cb) {
var path = `.backups/${new Date().getTime()}`;
- return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' })
- .pipe(vp(del))
- .pipe(gulp.dest(path));
+ return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' }).pipe(vp(del)).pipe(gulp.dest(path));
});
gulp.task('gappsinit', ['gs'], function (cb) {
@@ -68,5 +60,5 @@ gulp.task('gappsinit', ['gs'], function (cb) {
console.log(stdout);
console.log(stderr);
cb(err);
- })
+ });
});
diff --git a/recast/gapps/gulpfile-analitycs.js b/recast/gapps/gulpfile-analitycs.js
index 50932ff..d3b8ab3 100644
--- a/recast/gapps/gulpfile-analitycs.js
+++ b/recast/gapps/gulpfile-analitycs.js
@@ -20,17 +20,20 @@ gulp.task('gapps', ['gs'], function (cb) {
console.log(stderr);
cb(err);
});
-})
+});
gulp.task('googleanalytics', ['clean'], function () {
- gulp.src(['./index.html'], { base: './' })
+ gulp
+ .src(['./index.html'], { base: './' })
.pipe(debug())
- .pipe(replace('', function (match) {
- return fs.readFileSync('./googleanalytics.html');
- }))
+ .pipe(
+ replace('', function (match) {
+ return fs.readFileSync('./googleanalytics.html');
+ })
+ )
.pipe(gulp.dest('src'));
});
gulp.task('default', ['gapps'], function () {
return;
-})
\ No newline at end of file
+});
diff --git a/recast/gapps/gulpfile-gist-stack.js b/recast/gapps/gulpfile-gist-stack.js
index 5e44f5e..94d308b 100644
--- a/recast/gapps/gulpfile-gist-stack.js
+++ b/recast/gapps/gulpfile-gist-stack.js
@@ -11,17 +11,13 @@ gulp.task('default', ['src'], function (cb) {
});
gulp.task('clean', function () {
- del([
- 'src/*'
- ]);
+ del(['src/*']);
});
gulp.task('src', ['clean'], function () {
- gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js'])
- .pipe(gulp.dest('src'));
+ gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js']).pipe(gulp.dest('src'));
});
gulp.task('init', function () {
- gulp.src(['src/*.html', 'src/*.gs', 'src/*.js'])
- .pipe(gulp.dest('.'));
-});
\ No newline at end of file
+ gulp.src(['src/*.html', 'src/*.gs', 'src/*.js']).pipe(gulp.dest('.'));
+});
diff --git a/recast/gapps/gulpfile-notify-send.js b/recast/gapps/gulpfile-notify-send.js
index 23304e7..9fe7c14 100644
--- a/recast/gapps/gulpfile-notify-send.js
+++ b/recast/gapps/gulpfile-notify-send.js
@@ -11,4 +11,4 @@ gulp.task('default', function (cb) {
console.log(stderr);
cb(err);
});
-})
\ No newline at end of file
+});
diff --git a/recast/gapps/gulpfile-variant.js b/recast/gapps/gulpfile-variant.js
index 3af5794..a08b4ab 100644
--- a/recast/gapps/gulpfile-variant.js
+++ b/recast/gapps/gulpfile-variant.js
@@ -13,7 +13,7 @@ var knownOptions = {
};
*/
-var options = minimist(process.argv.slice(2)/*, knownOptions*/);
+var options = minimist(process.argv.slice(2) /*, knownOptions*/);
var vp = require('vinyl-paths');
gulp.task('default', ['src'], function (cb) {
@@ -25,33 +25,25 @@ gulp.task('default', ['src'], function (cb) {
});
gulp.task('clean', function () {
- del([
- 'src/*'
- ]);
+ del(['src/*']);
});
gulp.task('src', ['clean'], function () {
- gulp.src('app/*')
- .pipe(gulp.dest('src'));
+ gulp.src('app/*').pipe(gulp.dest('src'));
});
gulp.task('init', ['gappsinit'], function () {
- gulp.src('src/*')
- .pipe(gulp.dest('app'));
+ gulp.src('src/*').pipe(gulp.dest('app'));
});
gulp.task('cleanbup', function () {
- del([
- '.backups'
- ]);
+ del(['.backups']);
});
gulp.task('gs', function (cb) {
var path = `.backups/${new Date().getTime()}`;
- return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' })
- .pipe(vp(del))
- .pipe(gulp.dest(path));
+ return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' }).pipe(vp(del)).pipe(gulp.dest(path));
});
gulp.task('gappsinit', ['gs'], function (cb) {
@@ -59,5 +51,5 @@ gulp.task('gappsinit', ['gs'], function (cb) {
console.log(stdout);
console.log(stderr);
cb(err);
- })
+ });
});
diff --git a/recast/gapps/gulpfile-with-gappsinit-and-backups.js b/recast/gapps/gulpfile-with-gappsinit-and-backups.js
index d413090..82cc72a 100644
--- a/recast/gapps/gulpfile-with-gappsinit-and-backups.js
+++ b/recast/gapps/gulpfile-with-gappsinit-and-backups.js
@@ -16,42 +16,35 @@ gulp.task('default', ['src'], function (cb) {
});
gulp.task('clean', function () {
- del([
- 'src/*'
- ]);
+ del(['src/*']);
});
gulp.task('src', ['clean'], function () {
- gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js'])
- .pipe(gulp.dest('src'));
- gulp.src('node_modules/alasql/dist/alasql.js')
- .pipe(removeEmptyLines({
- removeComments: true
- }))
+ gulp.src(['*.html', '*.gs', '*.js', '!gulpfile.js']).pipe(gulp.dest('src'));
+ gulp
+ .src('node_modules/alasql/dist/alasql.js')
+ .pipe(
+ removeEmptyLines({
+ removeComments: true,
+ })
+ )
.pipe(strip())
.pipe(rename('z_alasql.gs'))
.pipe(gulp.dest('src'));
});
gulp.task('init', ['gappsexec'], function () {
- gulp.src(['src/*.html', 'src/*.gs', 'src/*.js'])
- .pipe(gulp.dest('.'));
+ gulp.src(['src/*.html', 'src/*.gs', 'src/*.js']).pipe(gulp.dest('.'));
});
-
gulp.task('cleanbup', function () {
- del([
- '.backups'
- ]);
+ del(['.backups']);
});
-
gulp.task('gs', function (cb) {
var path = `.backups/${new Date().getTime()}`;
- return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' })
- .pipe(vp(del))
- .pipe(gulp.dest(path));
+ return gulp.src(['src/**/*', './gapps.config.json'], { base: '.' }).pipe(vp(del)).pipe(gulp.dest(path));
});
gulp.task('gappsexec', ['gs'], function (cb) {
@@ -59,5 +52,5 @@ gulp.task('gappsexec', ['gs'], function (cb) {
console.log(stdout);
console.log(stderr);
cb(err);
- })
+ });
});
diff --git a/settings/container-bound-form/.clasp.json b/settings/container-bound-form/.clasp.json
index 1aea1ac..8d8bca7 100644
--- a/settings/container-bound-form/.clasp.json
+++ b/settings/container-bound-form/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "13F7zvpjgrURb8LU7xA2X8JZbpRzhsXbTGQIbvBeAjRpU4pAeHzYY-f1c",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/settings/container-bound-sheet/.clasp.json b/settings/container-bound-sheet/.clasp.json
index 1aea1ac..8d8bca7 100644
--- a/settings/container-bound-sheet/.clasp.json
+++ b/settings/container-bound-sheet/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "13F7zvpjgrURb8LU7xA2X8JZbpRzhsXbTGQIbvBeAjRpU4pAeHzYY-f1c",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/settings/standalone/.clasp.json b/settings/standalone/.clasp.json
index 264fbd7..deac12b 100644
--- a/settings/standalone/.clasp.json
+++ b/settings/standalone/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "1mt5rBJZH2ZnsoFifXp4BPCg-ftumrOUsSOaWcc5Q5N4Ot3-YHaAsXl9P",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/settings/webapp/.clasp.json b/settings/webapp/.clasp.json
index 50643f5..bb5c28b 100644
--- a/settings/webapp/.clasp.json
+++ b/settings/webapp/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "1HbtO9xPhT-Mxixaz1FyeflFMC3Vuz2PMuaA9yOdMCUlmEhl3tCPqA1Un",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/shims/Array.find.js b/shims/Array.find.js
index 12f25c3..b04ca64 100644
--- a/shims/Array.find.js
+++ b/shims/Array.find.js
@@ -7,7 +7,7 @@
// https://tc39.github.io/ecma262/#sec-array.prototype.find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
- value: function(predicate) {
+ value: function (predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
@@ -45,6 +45,6 @@ if (!Array.prototype.find) {
// 7. Return undefined.
return undefined;
- }
+ },
});
}
diff --git a/shims/Array.findIndex.js b/shims/Array.findIndex.js
index 1ee3321..37a59b5 100644
--- a/shims/Array.findIndex.js
+++ b/shims/Array.findIndex.js
@@ -7,7 +7,7 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
if (!Array.prototype.findIndex) {
Object.defineProperty(Array.prototype, 'findIndex', {
- value: function(predicate) {
+ value: function (predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
@@ -47,6 +47,6 @@ if (!Array.prototype.findIndex) {
return -1;
},
configurable: true,
- writable: true
+ writable: true,
});
}
diff --git a/shims/Array.findIndexRight.js b/shims/Array.findIndexRight.js
index b2125b3..b417244 100644
--- a/shims/Array.findIndexRight.js
+++ b/shims/Array.findIndexRight.js
@@ -7,7 +7,7 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
if (!Array.prototype.findIndex) {
Object.defineProperty(Array.prototype, 'findIndex', {
- value: function(predicate) {
+ value: function (predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
@@ -47,6 +47,6 @@ if (!Array.prototype.findIndex) {
return -1;
},
configurable: true,
- writable: true
+ writable: true,
});
}
diff --git a/shims/Array.flat.js b/shims/Array.flat.js
index 6f0ec16..36a4d8f 100644
--- a/shims/Array.flat.js
+++ b/shims/Array.flat.js
@@ -1,19 +1,25 @@
if (!Array.prototype.flat) {
- Object.defineProperty(Array.prototype, 'flat', {
- configurable: true,
- value: function flat () {
- var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]);
+ Object.defineProperty(Array.prototype, 'flat', {
+ configurable: true,
+ value: function flat() {
+ var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]);
- return depth ? Array.prototype.reduce.call(this, function (acc, cur) {
- if (Array.isArray(cur)) {
- acc.push.apply(acc, flat.call(cur, depth - 1));
- } else {
- acc.push(cur);
- }
+ return depth
+ ? Array.prototype.reduce.call(
+ this,
+ function (acc, cur) {
+ if (Array.isArray(cur)) {
+ acc.push.apply(acc, flat.call(cur, depth - 1));
+ } else {
+ acc.push(cur);
+ }
- return acc;
- }, []) : Array.prototype.slice.call(this);
- },
- writable: true
- });
+ return acc;
+ },
+ []
+ )
+ : Array.prototype.slice.call(this);
+ },
+ writable: true,
+ });
}
diff --git a/shims/Math.sign.js b/shims/Math.sign.js
index 6ecf245..b03e40e 100644
--- a/shims/Math.sign.js
+++ b/shims/Math.sign.js
@@ -1,6 +1,6 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
if (!Math.sign) {
- Math.sign = function(x) {
+ Math.sign = function (x) {
x = +x; // convert to a number
if (x === 0 || isNaN(x)) {
return Number(x);
diff --git a/shims/String.repeat.js b/shims/String.repeat.js
index ea6b310..3632133 100644
--- a/shims/String.repeat.js
+++ b/shims/String.repeat.js
@@ -5,7 +5,7 @@
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
if (!String.prototype.repeat) {
- String.prototype.repeat = function(count) {
+ String.prototype.repeat = function (count) {
'use strict';
if (this == null) {
throw new TypeError("can't convert " + this + ' to object');
@@ -29,9 +29,7 @@ if (!String.prototype.repeat) {
// main part. But anyway, most current (August 2014) browsers can't handle
// strings 1 << 28 chars or longer, so:
if (str.length * count >= 1 << 28) {
- throw new RangeError(
- 'repeat count must not overflow maximum string size'
- );
+ throw new RangeError('repeat count must not overflow maximum string size');
}
var rpt = '';
for (var i = 0; i < count; i++) {
diff --git a/shims/URL.js b/shims/URL.js
index 776a834..e484c51 100644
--- a/shims/URL.js
+++ b/shims/URL.js
@@ -1,4 +1,4 @@
-"use strict";
+'use strict';
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
@@ -7,10 +7,11 @@
// -- https://github.com/contributorpw/google-apps-script-snippets --
// Window.prototype.forceJURL = false;
-(function (scope) {
- 'use strict';
-// -- https://github.com/contributorpw/google-apps-script-snippets --
-/* // feature detect for URL constructor
+(
+ function (scope) {
+ 'use strict';
+ // -- https://github.com/contributorpw/google-apps-script-snippets --
+ /* // feature detect for URL constructor
var hasWorkingUrl = false;
@@ -23,682 +24,706 @@
}
if (hasWorkingUrl) return; */
- var relative = Object.create(null);
- relative['ftp'] = 21;
- relative['file'] = 0;
- relative['gopher'] = 70;
- relative['http'] = 80;
- relative['https'] = 443;
- relative['ws'] = 80;
- relative['wss'] = 443;
- var relativePathDotMapping = Object.create(null);
- relativePathDotMapping['%2e'] = '.';
- relativePathDotMapping['.%2e'] = '..';
- relativePathDotMapping['%2e.'] = '..';
- relativePathDotMapping['%2e%2e'] = '..';
-
- function isRelativeScheme(scheme) {
- return relative[scheme] !== undefined;
- }
+ var relative = Object.create(null);
+ relative['ftp'] = 21;
+ relative['file'] = 0;
+ relative['gopher'] = 70;
+ relative['http'] = 80;
+ relative['https'] = 443;
+ relative['ws'] = 80;
+ relative['wss'] = 443;
+ var relativePathDotMapping = Object.create(null);
+ relativePathDotMapping['%2e'] = '.';
+ relativePathDotMapping['.%2e'] = '..';
+ relativePathDotMapping['%2e.'] = '..';
+ relativePathDotMapping['%2e%2e'] = '..';
+
+ function isRelativeScheme(scheme) {
+ return relative[scheme] !== undefined;
+ }
- function invalid() {
- clear.call(this);
- this._isInvalid = true;
- }
+ function invalid() {
+ clear.call(this);
+ this._isInvalid = true;
+ }
- function IDNAToASCII(h) {
- if ('' == h) {
- invalid.call(this);
- } // XXX
+ function IDNAToASCII(h) {
+ if ('' == h) {
+ invalid.call(this);
+ } // XXX
+ return h.toLowerCase();
+ }
- return h.toLowerCase();
- }
+ function percentEscape(c) {
+ var unicode = c.charCodeAt(0);
- function percentEscape(c) {
- var unicode = c.charCodeAt(0);
+ if (
+ unicode > 0x20 &&
+ unicode < 0x7f && // " # < > ? `
+ [0x22, 0x23, 0x3c, 0x3e, 0x3f, 0x60].indexOf(unicode) == -1
+ ) {
+ return c;
+ }
- if (unicode > 0x20 && unicode < 0x7F && // " # < > ? `
- [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) == -1) {
- return c;
+ return encodeURIComponent(c);
}
- return encodeURIComponent(c);
- }
-
- function percentEscapeQuery(c) {
- // XXX This actually needs to encode c using encoding and then
- // convert the bytes one-by-one.
- var unicode = c.charCodeAt(0);
+ function percentEscapeQuery(c) {
+ // XXX This actually needs to encode c using encoding and then
+ // convert the bytes one-by-one.
+ var unicode = c.charCodeAt(0);
+
+ if (
+ unicode > 0x20 &&
+ unicode < 0x7f && // " # < > ` (do not escape '?')
+ [0x22, 0x23, 0x3c, 0x3e, 0x60].indexOf(unicode) == -1
+ ) {
+ return c;
+ }
- if (unicode > 0x20 && unicode < 0x7F && // " # < > ` (do not escape '?')
- [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) == -1) {
- return c;
+ return encodeURIComponent(c);
}
- return encodeURIComponent(c);
- }
-
- var EOF = undefined,
+ var EOF = undefined,
ALPHA = /[a-zA-Z]/,
ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
- /**
- * @param {!string} input
- * @param {?string=} stateOverride
- * @param {(URL|string)=} base
- */
-
- function parse(input, stateOverride, base) {
- function err(message) {
- errors.push(message);
- }
+ /**
+ * @param {!string} input
+ * @param {?string=} stateOverride
+ * @param {(URL|string)=} base
+ */
+
+ function parse(input, stateOverride, base) {
+ function err(message) {
+ errors.push(message);
+ }
- var state = stateOverride || 'scheme start',
+ var state = stateOverride || 'scheme start',
cursor = 0,
buffer = '',
seenAt = false,
seenBracket = false,
errors = [];
- loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
- var c = input[cursor];
-
- switch (state) {
- case 'scheme start':
- if (c && ALPHA.test(c)) {
- buffer += c.toLowerCase(); // ASCII-safe
-
- state = 'scheme';
- } else if (!stateOverride) {
- buffer = '';
- state = 'no scheme';
- continue;
- } else {
- err('Invalid scheme.');
- break loop;
- }
-
- break;
-
- case 'scheme':
- if (c && ALPHANUMERIC.test(c)) {
- buffer += c.toLowerCase(); // ASCII-safe
- } else if (':' == c) {
- this._scheme = buffer;
- buffer = '';
-
- if (stateOverride) {
+ loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
+ var c = input[cursor];
+
+ switch (state) {
+ case 'scheme start':
+ if (c && ALPHA.test(c)) {
+ buffer += c.toLowerCase(); // ASCII-safe
+
+ state = 'scheme';
+ } else if (!stateOverride) {
+ buffer = '';
+ state = 'no scheme';
+ continue;
+ } else {
+ err('Invalid scheme.');
break loop;
}
- if (isRelativeScheme(this._scheme)) {
- this._isRelative = true;
+ break;
+
+ case 'scheme':
+ if (c && ALPHANUMERIC.test(c)) {
+ buffer += c.toLowerCase(); // ASCII-safe
+ } else if (':' == c) {
+ this._scheme = buffer;
+ buffer = '';
+
+ if (stateOverride) {
+ break loop;
+ }
+
+ if (isRelativeScheme(this._scheme)) {
+ this._isRelative = true;
+ }
+
+ if ('file' == this._scheme) {
+ state = 'relative';
+ } else if (this._isRelative && base && base._scheme == this._scheme) {
+ state = 'relative or authority';
+ } else if (this._isRelative) {
+ state = 'authority first slash';
+ } else {
+ state = 'scheme data';
+ }
+ } else if (!stateOverride) {
+ buffer = '';
+ cursor = 0;
+ state = 'no scheme';
+ continue;
+ } else if (EOF == c) {
+ break loop;
+ } else {
+ err('Code point not allowed in scheme: ' + c);
+ break loop;
}
- if ('file' == this._scheme) {
- state = 'relative';
- } else if (this._isRelative && base && base._scheme == this._scheme) {
- state = 'relative or authority';
- } else if (this._isRelative) {
- state = 'authority first slash';
+ break;
+
+ case 'scheme data':
+ if ('?' == c) {
+ this._query = '?';
+ state = 'query';
+ } else if ('#' == c) {
+ this._fragment = '#';
+ state = 'fragment';
} else {
- state = 'scheme data';
+ // XXX error handling
+ if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
+ this._schemeData += percentEscape(c);
+ }
}
- } else if (!stateOverride) {
- buffer = '';
- cursor = 0;
- state = 'no scheme';
- continue;
- } else if (EOF == c) {
- break loop;
- } else {
- err('Code point not allowed in scheme: ' + c);
- break loop;
- }
-
- break;
-
- case 'scheme data':
- if ('?' == c) {
- this._query = '?';
- state = 'query';
- } else if ('#' == c) {
- this._fragment = '#';
- state = 'fragment';
- } else {
- // XXX error handling
- if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._schemeData += percentEscape(c);
+
+ break;
+
+ case 'no scheme':
+ if (!base || !isRelativeScheme(base._scheme)) {
+ err('Missing scheme.');
+ invalid.call(this);
+ } else {
+ state = 'relative';
+ continue;
}
- }
- break;
+ break;
- case 'no scheme':
- if (!base || !isRelativeScheme(base._scheme)) {
- err('Missing scheme.');
- invalid.call(this);
- } else {
- state = 'relative';
- continue;
- }
+ case 'relative or authority':
+ if ('/' == c && '/' == input[cursor + 1]) {
+ state = 'authority ignore slashes';
+ } else {
+ err('Expected /, got: ' + c);
+ state = 'relative';
+ continue;
+ }
- break;
+ break;
- case 'relative or authority':
- if ('/' == c && '/' == input[cursor + 1]) {
- state = 'authority ignore slashes';
- } else {
- err('Expected /, got: ' + c);
- state = 'relative';
- continue;
- }
-
- break;
-
- case 'relative':
- this._isRelative = true;
- if ('file' != this._scheme) this._scheme = base._scheme;
-
- if (EOF == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = base._query;
- this._username = base._username;
- this._password = base._password;
- break loop;
- } else if ('/' == c || '\\' == c) {
- if ('\\' == c) err('\\ is an invalid code point.');
- state = 'relative slash';
- } else if ('?' == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = '?';
- this._username = base._username;
- this._password = base._password;
- state = 'query';
- } else if ('#' == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = base._query;
- this._fragment = '#';
- this._username = base._username;
- this._password = base._password;
- state = 'fragment';
- } else {
- var nextC = input[cursor + 1];
- var nextNextC = input[cursor + 2];
-
- if ('file' != this._scheme || !ALPHA.test(c) || nextC != ':' && nextC != '|' || EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?' != nextNextC && '#' != nextNextC) {
+ case 'relative':
+ this._isRelative = true;
+ if ('file' != this._scheme) this._scheme = base._scheme;
+
+ if (EOF == c) {
this._host = base._host;
this._port = base._port;
+ this._path = base._path.slice();
+ this._query = base._query;
this._username = base._username;
this._password = base._password;
+ break loop;
+ } else if ('/' == c || '\\' == c) {
+ if ('\\' == c) err('\\ is an invalid code point.');
+ state = 'relative slash';
+ } else if ('?' == c) {
+ this._host = base._host;
+ this._port = base._port;
this._path = base._path.slice();
+ this._query = '?';
+ this._username = base._username;
+ this._password = base._password;
+ state = 'query';
+ } else if ('#' == c) {
+ this._host = base._host;
+ this._port = base._port;
+ this._path = base._path.slice();
+ this._query = base._query;
+ this._fragment = '#';
+ this._username = base._username;
+ this._password = base._password;
+ state = 'fragment';
+ } else {
+ var nextC = input[cursor + 1];
+ var nextNextC = input[cursor + 2];
+
+ if (
+ 'file' != this._scheme ||
+ !ALPHA.test(c) ||
+ (nextC != ':' && nextC != '|') ||
+ (EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?' != nextNextC && '#' != nextNextC)
+ ) {
+ this._host = base._host;
+ this._port = base._port;
+ this._username = base._username;
+ this._password = base._password;
+ this._path = base._path.slice();
+
+ this._path.pop();
+ }
- this._path.pop();
+ state = 'relative path';
+ continue;
}
- state = 'relative path';
- continue;
- }
+ break;
- break;
+ case 'relative slash':
+ if ('/' == c || '\\' == c) {
+ if ('\\' == c) {
+ err('\\ is an invalid code point.');
+ }
+
+ if ('file' == this._scheme) {
+ state = 'file host';
+ } else {
+ state = 'authority ignore slashes';
+ }
+ } else {
+ if ('file' != this._scheme) {
+ this._host = base._host;
+ this._port = base._port;
+ this._username = base._username;
+ this._password = base._password;
+ }
- case 'relative slash':
- if ('/' == c || '\\' == c) {
- if ('\\' == c) {
- err('\\ is an invalid code point.');
+ state = 'relative path';
+ continue;
}
- if ('file' == this._scheme) {
- state = 'file host';
+ break;
+
+ case 'authority first slash':
+ if ('/' == c) {
+ state = 'authority second slash';
} else {
+ err("Expected '/', got: " + c);
state = 'authority ignore slashes';
+ continue;
}
- } else {
- if ('file' != this._scheme) {
- this._host = base._host;
- this._port = base._port;
- this._username = base._username;
- this._password = base._password;
- }
-
- state = 'relative path';
- continue;
- }
- break;
+ break;
- case 'authority first slash':
- if ('/' == c) {
- state = 'authority second slash';
- } else {
- err("Expected '/', got: " + c);
+ case 'authority second slash':
state = 'authority ignore slashes';
- continue;
- }
-
- break;
-
- case 'authority second slash':
- state = 'authority ignore slashes';
- if ('/' != c) {
- err("Expected '/', got: " + c);
- continue;
- }
+ if ('/' != c) {
+ err("Expected '/', got: " + c);
+ continue;
+ }
- break;
+ break;
- case 'authority ignore slashes':
- if ('/' != c && '\\' != c) {
- state = 'authority';
- continue;
- } else {
- err('Expected authority, got: ' + c);
- }
+ case 'authority ignore slashes':
+ if ('/' != c && '\\' != c) {
+ state = 'authority';
+ continue;
+ } else {
+ err('Expected authority, got: ' + c);
+ }
- break;
+ break;
- case 'authority':
- if ('@' == c) {
- if (seenAt) {
- err('@ already seen.');
- buffer += '%40';
- }
+ case 'authority':
+ if ('@' == c) {
+ if (seenAt) {
+ err('@ already seen.');
+ buffer += '%40';
+ }
- seenAt = true;
+ seenAt = true;
- for (var i = 0; i < buffer.length; i++) {
- var cp = buffer[i];
+ for (var i = 0; i < buffer.length; i++) {
+ var cp = buffer[i];
- if ('\t' == cp || '\n' == cp || '\r' == cp) {
- err('Invalid whitespace in authority.');
- continue;
- } // XXX check URL code points
+ if ('\t' == cp || '\n' == cp || '\r' == cp) {
+ err('Invalid whitespace in authority.');
+ continue;
+ } // XXX check URL code points
+ if (':' == cp && null === this._password) {
+ this._password = '';
+ continue;
+ }
- if (':' == cp && null === this._password) {
- this._password = '';
- continue;
+ var tempC = percentEscape(cp);
+ null !== this._password ? (this._password += tempC) : (this._username += tempC);
}
- var tempC = percentEscape(cp);
- null !== this._password ? this._password += tempC : this._username += tempC;
+ buffer = '';
+ } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
+ cursor -= buffer.length;
+ buffer = '';
+ state = 'host';
+ continue;
+ } else {
+ buffer += c;
}
- buffer = '';
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- cursor -= buffer.length;
- buffer = '';
- state = 'host';
- continue;
- } else {
- buffer += c;
- }
-
- break;
-
- case 'file host':
- if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':' || buffer[1] == '|')) {
- state = 'relative path';
- } else if (buffer.length == 0) {
- state = 'relative path start';
+ break;
+
+ case 'file host':
+ if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
+ if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':' || buffer[1] == '|')) {
+ state = 'relative path';
+ } else if (buffer.length == 0) {
+ state = 'relative path start';
+ } else {
+ this._host = IDNAToASCII.call(this, buffer);
+ buffer = '';
+ state = 'relative path start';
+ }
+
+ continue;
+ } else if ('\t' == c || '\n' == c || '\r' == c) {
+ err('Invalid whitespace in file host.');
} else {
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'relative path start';
+ buffer += c;
}
- continue;
- } else if ('\t' == c || '\n' == c || '\r' == c) {
- err('Invalid whitespace in file host.');
- } else {
- buffer += c;
- }
+ break;
- break;
+ case 'host':
+ case 'hostname':
+ if (':' == c && !seenBracket) {
+ // XXX host parsing
+ this._host = IDNAToASCII.call(this, buffer);
+ buffer = '';
+ state = 'port';
- case 'host':
- case 'hostname':
- if (':' == c && !seenBracket) {
- // XXX host parsing
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'port';
+ if ('hostname' == stateOverride) {
+ break loop;
+ }
+ } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
+ this._host = IDNAToASCII.call(this, buffer);
+ buffer = '';
+ state = 'relative path start';
- if ('hostname' == stateOverride) {
- break loop;
- }
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'relative path start';
+ if (stateOverride) {
+ break loop;
+ }
- if (stateOverride) {
- break loop;
- }
+ continue;
+ } else if ('\t' != c && '\n' != c && '\r' != c) {
+ if ('[' == c) {
+ seenBracket = true;
+ } else if (']' == c) {
+ seenBracket = false;
+ }
- continue;
- } else if ('\t' != c && '\n' != c && '\r' != c) {
- if ('[' == c) {
- seenBracket = true;
- } else if (']' == c) {
- seenBracket = false;
+ buffer += c;
+ } else {
+ err('Invalid code point in host/hostname: ' + c);
}
- buffer += c;
- } else {
- err('Invalid code point in host/hostname: ' + c);
- }
+ break;
- break;
+ case 'port':
+ if (/[0-9]/.test(c)) {
+ buffer += c;
+ } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c || stateOverride) {
+ if ('' != buffer) {
+ var temp = parseInt(buffer, 10);
- case 'port':
- if (/[0-9]/.test(c)) {
- buffer += c;
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c || stateOverride) {
- if ('' != buffer) {
- var temp = parseInt(buffer, 10);
+ if (temp != relative[this._scheme]) {
+ this._port = temp + '';
+ }
- if (temp != relative[this._scheme]) {
- this._port = temp + '';
+ buffer = '';
}
- buffer = '';
- }
+ if (stateOverride) {
+ break loop;
+ }
- if (stateOverride) {
- break loop;
+ state = 'relative path start';
+ continue;
+ } else if ('\t' == c || '\n' == c || '\r' == c) {
+ err('Invalid code point in port: ' + c);
+ } else {
+ invalid.call(this);
}
- state = 'relative path start';
- continue;
- } else if ('\t' == c || '\n' == c || '\r' == c) {
- err('Invalid code point in port: ' + c);
- } else {
- invalid.call(this);
- }
+ break;
- break;
-
- case 'relative path start':
- if ('\\' == c) err("'\\' not allowed in path.");
- state = 'relative path';
+ case 'relative path start':
+ if ('\\' == c) err("'\\' not allowed in path.");
+ state = 'relative path';
- if ('/' != c && '\\' != c) {
- continue;
- }
+ if ('/' != c && '\\' != c) {
+ continue;
+ }
- break;
+ break;
- case 'relative path':
- if (EOF == c || '/' == c || '\\' == c || !stateOverride && ('?' == c || '#' == c)) {
- if ('\\' == c) {
- err('\\ not allowed in relative path.');
- }
+ case 'relative path':
+ if (EOF == c || '/' == c || '\\' == c || (!stateOverride && ('?' == c || '#' == c))) {
+ if ('\\' == c) {
+ err('\\ not allowed in relative path.');
+ }
- var tmp;
+ var tmp;
- if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
- buffer = tmp;
- }
+ if ((tmp = relativePathDotMapping[buffer.toLowerCase()])) {
+ buffer = tmp;
+ }
- if ('..' == buffer) {
- this._path.pop();
+ if ('..' == buffer) {
+ this._path.pop();
- if ('/' != c && '\\' != c) {
+ if ('/' != c && '\\' != c) {
+ this._path.push('');
+ }
+ } else if ('.' == buffer && '/' != c && '\\' != c) {
this._path.push('');
- }
- } else if ('.' == buffer && '/' != c && '\\' != c) {
- this._path.push('');
- } else if ('.' != buffer) {
- if ('file' == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == '|') {
- buffer = buffer[0] + ':';
+ } else if ('.' != buffer) {
+ if (
+ 'file' == this._scheme &&
+ this._path.length == 0 &&
+ buffer.length == 2 &&
+ ALPHA.test(buffer[0]) &&
+ buffer[1] == '|'
+ ) {
+ buffer = buffer[0] + ':';
+ }
+
+ this._path.push(buffer);
}
- this._path.push(buffer);
+ buffer = '';
+
+ if ('?' == c) {
+ this._query = '?';
+ state = 'query';
+ } else if ('#' == c) {
+ this._fragment = '#';
+ state = 'fragment';
+ }
+ } else if ('\t' != c && '\n' != c && '\r' != c) {
+ buffer += percentEscape(c);
}
- buffer = '';
+ break;
- if ('?' == c) {
- this._query = '?';
- state = 'query';
- } else if ('#' == c) {
+ case 'query':
+ if (!stateOverride && '#' == c) {
this._fragment = '#';
state = 'fragment';
+ } else if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
+ this._query += percentEscapeQuery(c);
}
- } else if ('\t' != c && '\n' != c && '\r' != c) {
- buffer += percentEscape(c);
- }
-
- break;
- case 'query':
- if (!stateOverride && '#' == c) {
- this._fragment = '#';
- state = 'fragment';
- } else if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._query += percentEscapeQuery(c);
- }
+ break;
- break;
+ case 'fragment':
+ if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
+ this._fragment += c;
+ }
- case 'fragment':
- if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._fragment += c;
- }
+ break;
+ }
- break;
+ cursor++;
}
-
- cursor++;
}
- }
- function clear() {
- this._scheme = '';
- this._schemeData = '';
- this._username = '';
- this._password = null;
- this._host = '';
- this._port = '';
- this._path = [];
- this._query = '';
- this._fragment = '';
- this._isInvalid = false;
- this._isRelative = false;
- } // Does not process domain names or IP addresses.
- // Does not handle encoding for the query parameter.
-
- /**
- * @constructor
- * @extends {URL}
- * @param {!string} url
- * @param {(URL|string)=} base
- */
-
-
- function jURL(url, base
- /* , encoding */
- ) {
- if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base));
- this._url = '' + url;
- clear.call(this);
-
- var input = this._url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); // encoding = encoding || 'utf-8'
-
-
- parse.call(this, input, null, base);
- }
-
- jURL.prototype = Object.defineProperties({
- toString: function toString() {
- return this.href;
+ function clear() {
+ this._scheme = '';
+ this._schemeData = '';
+ this._username = '';
+ this._password = null;
+ this._host = '';
+ this._port = '';
+ this._path = [];
+ this._query = '';
+ this._fragment = '';
+ this._isInvalid = false;
+ this._isRelative = false;
+ } // Does not process domain names or IP addresses.
+ // Does not handle encoding for the query parameter.
+
+ /**
+ * @constructor
+ * @extends {URL}
+ * @param {!string} url
+ * @param {(URL|string)=} base
+ */
+
+ function jURL(
+ url,
+ base
+ /* , encoding */
+ ) {
+ if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base));
+ this._url = '' + url;
+ clear.call(this);
+
+ var input = this._url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); // encoding = encoding || 'utf-8'
+
+ parse.call(this, input, null, base);
}
- }, {
- href: {
- get: function get() {
- if (this._isInvalid) return this._url;
- var authority = '';
-
- if ('' != this._username || null != this._password) {
- authority = this._username + (null != this._password ? ':' + this._password : '') + '@';
- }
- return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
- },
- set: function set(href) {
- clear.call(this);
- parse.call(this, href);
- },
- configurable: true,
- enumerable: true
- },
- protocol: {
- get: function get() {
- return this._scheme + ':';
- },
- set: function set(protocol) {
- if (this._isInvalid) return;
- parse.call(this, protocol + ':', 'scheme start');
- },
- configurable: true,
- enumerable: true
- },
- host: {
- get: function get() {
- return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
- },
- set: function set(host) {
- if (this._isInvalid || !this._isRelative) return;
- parse.call(this, host, 'host');
- },
- configurable: true,
- enumerable: true
- },
- hostname: {
- get: function get() {
- return this._host;
- },
- set: function set(hostname) {
- if (this._isInvalid || !this._isRelative) return;
- parse.call(this, hostname, 'hostname');
- },
- configurable: true,
- enumerable: true
- },
- port: {
- get: function get() {
- return this._port;
- },
- set: function set(port) {
- if (this._isInvalid || !this._isRelative) return;
- parse.call(this, port, 'port');
+ jURL.prototype = Object.defineProperties(
+ {
+ toString: function toString() {
+ return this.href;
+ },
},
- configurable: true,
- enumerable: true
- },
- pathname: {
- get: function get() {
- return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
- },
- set: function set(pathname) {
- if (this._isInvalid || !this._isRelative) return;
- this._path = [];
- parse.call(this, pathname, 'relative path start');
- },
- configurable: true,
- enumerable: true
- },
- search: {
- get: function get() {
- return this._isInvalid || !this._query || '?' == this._query ? '' : this._query;
- },
- set: function set(search) {
- if (this._isInvalid || !this._isRelative) return;
- this._query = '?';
- if ('?' == search[0]) search = search.slice(1);
- parse.call(this, search, 'query');
- },
- configurable: true,
- enumerable: true
- },
- hash: {
- get: function get() {
- return this._isInvalid || !this._fragment || '#' == this._fragment ? '' : this._fragment;
- },
- set: function set(hash) {
- if (this._isInvalid) return;
+ {
+ href: {
+ get: function get() {
+ if (this._isInvalid) return this._url;
+ var authority = '';
+
+ if ('' != this._username || null != this._password) {
+ authority = this._username + (null != this._password ? ':' + this._password : '') + '@';
+ }
- if (!hash) {
- this._fragment = '';
- return;
- }
+ return (
+ this.protocol +
+ (this._isRelative ? '//' + authority + this.host : '') +
+ this.pathname +
+ this._query +
+ this._fragment
+ );
+ },
+ set: function set(href) {
+ clear.call(this);
+ parse.call(this, href);
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ protocol: {
+ get: function get() {
+ return this._scheme + ':';
+ },
+ set: function set(protocol) {
+ if (this._isInvalid) return;
+ parse.call(this, protocol + ':', 'scheme start');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ host: {
+ get: function get() {
+ return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
+ },
+ set: function set(host) {
+ if (this._isInvalid || !this._isRelative) return;
+ parse.call(this, host, 'host');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ hostname: {
+ get: function get() {
+ return this._host;
+ },
+ set: function set(hostname) {
+ if (this._isInvalid || !this._isRelative) return;
+ parse.call(this, hostname, 'hostname');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ port: {
+ get: function get() {
+ return this._port;
+ },
+ set: function set(port) {
+ if (this._isInvalid || !this._isRelative) return;
+ parse.call(this, port, 'port');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ pathname: {
+ get: function get() {
+ return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
+ },
+ set: function set(pathname) {
+ if (this._isInvalid || !this._isRelative) return;
+ this._path = [];
+ parse.call(this, pathname, 'relative path start');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ search: {
+ get: function get() {
+ return this._isInvalid || !this._query || '?' == this._query ? '' : this._query;
+ },
+ set: function set(search) {
+ if (this._isInvalid || !this._isRelative) return;
+ this._query = '?';
+ if ('?' == search[0]) search = search.slice(1);
+ parse.call(this, search, 'query');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ hash: {
+ get: function get() {
+ return this._isInvalid || !this._fragment || '#' == this._fragment ? '' : this._fragment;
+ },
+ set: function set(hash) {
+ if (this._isInvalid) return;
+
+ if (!hash) {
+ this._fragment = '';
+ return;
+ }
- this._fragment = '#';
- if ('#' == hash[0]) hash = hash.slice(1);
- parse.call(this, hash, 'fragment');
- },
- configurable: true,
- enumerable: true
- },
- origin: {
- get: function get() {
- var host;
-
- if (this._isInvalid || !this._scheme) {
- return '';
- } // javascript: Gecko returns String(""), WebKit/Blink String("null")
- // Gecko throws error for "data://"
- // data: Gecko returns "", Blink returns "data://", WebKit returns "null"
- // Gecko returns String("") for file: mailto:
- // WebKit/Blink returns String("SCHEME://") for file: mailto:
-
-
- switch (this._scheme) {
- case 'data':
- case 'file':
- case 'javascript':
- case 'mailto':
- return 'null';
- }
+ this._fragment = '#';
+ if ('#' == hash[0]) hash = hash.slice(1);
+ parse.call(this, hash, 'fragment');
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ origin: {
+ get: function get() {
+ var host;
+
+ if (this._isInvalid || !this._scheme) {
+ return '';
+ } // javascript: Gecko returns String(""), WebKit/Blink String("null")
+ // Gecko throws error for "data://"
+ // data: Gecko returns "", Blink returns "data://", WebKit returns "null"
+ // Gecko returns String("") for file: mailto:
+ // WebKit/Blink returns String("SCHEME://") for file: mailto:
+
+ switch (this._scheme) {
+ case 'data':
+ case 'file':
+ case 'javascript':
+ case 'mailto':
+ return 'null';
+ }
- host = this.host;
+ host = this.host;
- if (!host) {
- return '';
- }
+ if (!host) {
+ return '';
+ }
- return this._scheme + '://' + host;
- },
- configurable: true,
- enumerable: true
- }
- }); // Copy over the static methods
+ return this._scheme + '://' + host;
+ },
+ configurable: true,
+ enumerable: true,
+ },
+ }
+ ); // Copy over the static methods
- var OriginalURL = scope.URL;
+ var OriginalURL = scope.URL;
- if (OriginalURL) {
- jURL['createObjectURL'] = function (blob) {
- // IE extension allows a second optional options argument.
- // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
- return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
- };
+ if (OriginalURL) {
+ jURL['createObjectURL'] = function (blob) {
+ // IE extension allows a second optional options argument.
+ // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
+ return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
+ };
- jURL['revokeObjectURL'] = function (url) {
- OriginalURL.revokeObjectURL(url);
- };
- }
+ jURL['revokeObjectURL'] = function (url) {
+ OriginalURL.revokeObjectURL(url);
+ };
+ }
- scope.URL = jURL;
+ scope.URL = jURL;
-// -- https://github.com/contributorpw/google-apps-script-snippets --
-// })(window)
-})(typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : this));
\ No newline at end of file
+ // -- https://github.com/contributorpw/google-apps-script-snippets --
+ // })(window)
+ }
+)(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this);
diff --git a/shims/URLSearchParams.js b/shims/URLSearchParams.js
index 4bf489a..b840f4b 100644
--- a/shims/URLSearchParams.js
+++ b/shims/URLSearchParams.js
@@ -6,331 +6,348 @@
*
*/
-(function(self) {
- 'use strict';
-
- var nativeURLSearchParams = (self.URLSearchParams && self.URLSearchParams.prototype.get) ? self.URLSearchParams : null,
- isSupportObjectConstructor = nativeURLSearchParams && (new nativeURLSearchParams({a: 1})).toString() === 'a=1',
- // There is a bug in safari 10.1 (and earlier) that incorrectly decodes `%2B` as an empty space and not a plus.
- decodesPlusesCorrectly = nativeURLSearchParams && (new nativeURLSearchParams('s=%2B').get('s') === '+'),
- __URLSearchParams__ = "__URLSearchParams__",
- // Fix bug in Edge which cannot encode ' &' correctly
- encodesAmpersandsCorrectly = nativeURLSearchParams ? (function() {
- var ampersandTest = new nativeURLSearchParams();
- ampersandTest.append('s', ' &');
- return ampersandTest.toString() === 's=+%26';
- })() : true,
- prototype = URLSearchParamsPolyfill.prototype,
- iterable = !!(self.Symbol && self.Symbol.iterator);
-
- if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly) {
- return;
+(function (self) {
+ 'use strict';
+
+ var nativeURLSearchParams = self.URLSearchParams && self.URLSearchParams.prototype.get ? self.URLSearchParams : null,
+ isSupportObjectConstructor = nativeURLSearchParams && new nativeURLSearchParams({ a: 1 }).toString() === 'a=1',
+ // There is a bug in safari 10.1 (and earlier) that incorrectly decodes `%2B` as an empty space and not a plus.
+ decodesPlusesCorrectly = nativeURLSearchParams && new nativeURLSearchParams('s=%2B').get('s') === '+',
+ __URLSearchParams__ = '__URLSearchParams__',
+ // Fix bug in Edge which cannot encode ' &' correctly
+ encodesAmpersandsCorrectly = nativeURLSearchParams
+ ? (function () {
+ var ampersandTest = new nativeURLSearchParams();
+ ampersandTest.append('s', ' &');
+ return ampersandTest.toString() === 's=+%26';
+ })()
+ : true,
+ prototype = URLSearchParamsPolyfill.prototype,
+ iterable = !!(self.Symbol && self.Symbol.iterator);
+
+ if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly) {
+ return;
+ }
+
+ /**
+ * Make a URLSearchParams instance
+ *
+ * @param {object|string|URLSearchParams} search
+ * @constructor
+ */
+ function URLSearchParamsPolyfill(search) {
+ search = search || '';
+
+ // support construct object with another URLSearchParams instance
+ if (search instanceof URLSearchParams || search instanceof URLSearchParamsPolyfill) {
+ search = search.toString();
}
-
-
- /**
- * Make a URLSearchParams instance
- *
- * @param {object|string|URLSearchParams} search
- * @constructor
- */
- function URLSearchParamsPolyfill(search) {
- search = search || "";
-
- // support construct object with another URLSearchParams instance
- if (search instanceof URLSearchParams || search instanceof URLSearchParamsPolyfill) {
- search = search.toString();
- }
- this [__URLSearchParams__] = parseToDict(search);
+ this[__URLSearchParams__] = parseToDict(search);
+ }
+
+ /**
+ * Appends a specified key/value pair as a new search parameter.
+ *
+ * @param {string} name
+ * @param {string} value
+ */
+ prototype.append = function (name, value) {
+ appendTo(this[__URLSearchParams__], name, value);
+ };
+
+ /**
+ * Deletes the given search parameter, and its associated value,
+ * from the list of all search parameters.
+ *
+ * @param {string} name
+ */
+ prototype['delete'] = function (name) {
+ delete this[__URLSearchParams__][name];
+ };
+
+ /**
+ * Returns the first value associated to the given search parameter.
+ *
+ * @param {string} name
+ * @return {string|null}
+ */
+ prototype.get = function (name) {
+ var dict = this[__URLSearchParams__];
+ return name in dict ? dict[name][0] : null;
+ };
+
+ /**
+ * Returns all the values association with a given search parameter.
+ *
+ * @param {string} name
+ * @return {Array}
+ */
+ prototype.getAll = function (name) {
+ var dict = this[__URLSearchParams__];
+ return name in dict ? dict[name].slice(0) : [];
+ };
+
+ /**
+ * Returns a Boolean indicating if such a search parameter exists.
+ *
+ * @param {string} name
+ * @return {boolean}
+ */
+ prototype.has = function (name) {
+ return name in this[__URLSearchParams__];
+ };
+
+ /**
+ * Sets the value associated to a given search parameter to
+ * the given value. If there were several values, delete the
+ * others.
+ *
+ * @param {string} name
+ * @param {string} value
+ */
+ prototype.set = function set(name, value) {
+ this[__URLSearchParams__][name] = ['' + value];
+ };
+
+ /**
+ * Returns a string containg a query string suitable for use in a URL.
+ *
+ * @return {string}
+ */
+ prototype.toString = function () {
+ var dict = this[__URLSearchParams__],
+ query = [],
+ i,
+ key,
+ name,
+ value;
+ for (key in dict) {
+ name = encode(key);
+ for (i = 0, value = dict[key]; i < value.length; i++) {
+ query.push(name + '=' + encode(value[i]));
+ }
}
-
-
- /**
- * Appends a specified key/value pair as a new search parameter.
- *
- * @param {string} name
- * @param {string} value
- */
- prototype.append = function(name, value) {
- appendTo(this [__URLSearchParams__], name, value);
- };
-
- /**
- * Deletes the given search parameter, and its associated value,
- * from the list of all search parameters.
- *
- * @param {string} name
- */
- prototype['delete'] = function(name) {
- delete this [__URLSearchParams__] [name];
- };
-
- /**
- * Returns the first value associated to the given search parameter.
- *
- * @param {string} name
- * @return {string|null}
- */
- prototype.get = function(name) {
- var dict = this [__URLSearchParams__];
- return name in dict ? dict[name][0] : null;
- };
-
- /**
- * Returns all the values association with a given search parameter.
- *
- * @param {string} name
- * @return {Array}
- */
- prototype.getAll = function(name) {
- var dict = this [__URLSearchParams__];
- return name in dict ? dict [name].slice(0) : [];
- };
-
- /**
- * Returns a Boolean indicating if such a search parameter exists.
- *
- * @param {string} name
- * @return {boolean}
- */
- prototype.has = function(name) {
- return name in this [__URLSearchParams__];
- };
-
- /**
- * Sets the value associated to a given search parameter to
- * the given value. If there were several values, delete the
- * others.
- *
- * @param {string} name
- * @param {string} value
- */
- prototype.set = function set(name, value) {
- this [__URLSearchParams__][name] = ['' + value];
+ return query.join('&');
+ };
+
+ // There is a bug in Safari 10.1 and `Proxy`ing it is not enough.
+ var forSureUsePolyfill = !decodesPlusesCorrectly;
+ var useProxy = !forSureUsePolyfill && nativeURLSearchParams && !isSupportObjectConstructor && self.Proxy;
+ /*
+ * Apply polifill to global object and append other prototype into it
+ */
+ Object.defineProperty(self, 'URLSearchParams', {
+ value: useProxy
+ ? // Safari 10.0 doesn't support Proxy, so it won't extend URLSearchParams on safari 10.0
+ new Proxy(nativeURLSearchParams, {
+ construct: function (target, args) {
+ return new target(new URLSearchParamsPolyfill(args[0]).toString());
+ },
+ })
+ : URLSearchParamsPolyfill,
+ });
+
+ var USPProto = self.URLSearchParams.prototype;
+
+ USPProto.polyfill = true;
+
+ /**
+ *
+ * @param {function} callback
+ * @param {object} thisArg
+ */
+ USPProto.forEach =
+ USPProto.forEach ||
+ function (callback, thisArg) {
+ var dict = parseToDict(this.toString());
+ Object.getOwnPropertyNames(dict).forEach(function (name) {
+ dict[name].forEach(function (value) {
+ callback.call(thisArg, value, name, this);
+ }, this);
+ }, this);
};
- /**
- * Returns a string containg a query string suitable for use in a URL.
- *
- * @return {string}
- */
- prototype.toString = function() {
- var dict = this[__URLSearchParams__], query = [], i, key, name, value;
- for (key in dict) {
- name = encode(key);
- for (i = 0, value = dict[key]; i < value.length; i++) {
- query.push(name + '=' + encode(value[i]));
- }
+ /**
+ * Sort all name-value pairs
+ */
+ USPProto.sort =
+ USPProto.sort ||
+ function () {
+ var dict = parseToDict(this.toString()),
+ keys = [],
+ k,
+ i,
+ j;
+ for (k in dict) {
+ keys.push(k);
+ }
+ keys.sort();
+
+ for (i = 0; i < keys.length; i++) {
+ this['delete'](keys[i]);
+ }
+ for (i = 0; i < keys.length; i++) {
+ var key = keys[i],
+ values = dict[key];
+ for (j = 0; j < values.length; j++) {
+ this.append(key, values[j]);
}
- return query.join('&');
+ }
};
- // There is a bug in Safari 10.1 and `Proxy`ing it is not enough.
- var forSureUsePolyfill = !decodesPlusesCorrectly;
- var useProxy = (!forSureUsePolyfill && nativeURLSearchParams && !isSupportObjectConstructor && self.Proxy)
- /*
- * Apply polifill to global object and append other prototype into it
- */
- Object.defineProperty(self, 'URLSearchParams', {
- value: (useProxy ?
- // Safari 10.0 doesn't support Proxy, so it won't extend URLSearchParams on safari 10.0
- new Proxy(nativeURLSearchParams, {
- construct: function(target, args) {
- return new target((new URLSearchParamsPolyfill(args[0]).toString()));
- }
- }) :
- URLSearchParamsPolyfill)
- });
-
- var USPProto = self.URLSearchParams.prototype;
-
- USPProto.polyfill = true;
-
- /**
- *
- * @param {function} callback
- * @param {object} thisArg
- */
- USPProto.forEach = USPProto.forEach || function(callback, thisArg) {
- var dict = parseToDict(this.toString());
- Object.getOwnPropertyNames(dict).forEach(function(name) {
- dict[name].forEach(function(value) {
- callback.call(thisArg, value, name, this);
- }, this);
- }, this);
+ /**
+ * Returns an iterator allowing to go through all keys of
+ * the key/value pairs contained in this object.
+ *
+ * @return {function}
+ */
+ USPProto.keys =
+ USPProto.keys ||
+ function () {
+ var items = [];
+ this.forEach(function (item, name) {
+ items.push(name);
+ });
+ return makeIterator(items);
};
- /**
- * Sort all name-value pairs
- */
- USPProto.sort = USPProto.sort || function() {
- var dict = parseToDict(this.toString()), keys = [], k, i, j;
- for (k in dict) {
- keys.push(k);
- }
- keys.sort();
-
- for (i = 0; i < keys.length; i++) {
- this['delete'](keys[i]);
- }
- for (i = 0; i < keys.length; i++) {
- var key = keys[i], values = dict[key];
- for (j = 0; j < values.length; j++) {
- this.append(key, values[j]);
- }
- }
+ /**
+ * Returns an iterator allowing to go through all values of
+ * the key/value pairs contained in this object.
+ *
+ * @return {function}
+ */
+ USPProto.values =
+ USPProto.values ||
+ function () {
+ var items = [];
+ this.forEach(function (item) {
+ items.push(item);
+ });
+ return makeIterator(items);
};
- /**
- * Returns an iterator allowing to go through all keys of
- * the key/value pairs contained in this object.
- *
- * @return {function}
- */
- USPProto.keys = USPProto.keys || function() {
- var items = [];
- this.forEach(function(item, name) {
- items.push(name);
- });
- return makeIterator(items);
+ /**
+ * Returns an iterator allowing to go through all key/value
+ * pairs contained in this object.
+ *
+ * @return {function}
+ */
+ USPProto.entries =
+ USPProto.entries ||
+ function () {
+ var items = [];
+ this.forEach(function (item, name) {
+ items.push([name, item]);
+ });
+ return makeIterator(items);
};
- /**
- * Returns an iterator allowing to go through all values of
- * the key/value pairs contained in this object.
- *
- * @return {function}
- */
- USPProto.values = USPProto.values || function() {
- var items = [];
- this.forEach(function(item) {
- items.push(item);
- });
- return makeIterator(items);
+ if (iterable) {
+ USPProto[self.Symbol.iterator] = USPProto[self.Symbol.iterator] || USPProto.entries;
+ }
+
+ function encode(str) {
+ var replace = {
+ '!': '%21',
+ "'": '%27',
+ '(': '%28',
+ ')': '%29',
+ '~': '%7E',
+ '%20': '+',
+ '%00': '\x00',
};
+ return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function (match) {
+ return replace[match];
+ });
+ }
- /**
- * Returns an iterator allowing to go through all key/value
- * pairs contained in this object.
- *
- * @return {function}
- */
- USPProto.entries = USPProto.entries || function() {
- var items = [];
- this.forEach(function(item, name) {
- items.push([name, item]);
- });
- return makeIterator(items);
+ function decode(str) {
+ return str.replace(/[ +]/g, '%20').replace(/(%[a-f0-9]{2})+/gi, function (match) {
+ return decodeURIComponent(match);
+ });
+ }
+
+ function makeIterator(arr) {
+ var iterator = {
+ next: function () {
+ var value = arr.shift();
+ return { done: value === undefined, value: value };
+ },
};
-
if (iterable) {
- USPProto[self.Symbol.iterator] = USPProto[self.Symbol.iterator] || USPProto.entries;
- }
-
-
- function encode(str) {
- var replace = {
- '!': '%21',
- "'": '%27',
- '(': '%28',
- ')': '%29',
- '~': '%7E',
- '%20': '+',
- '%00': '\x00'
- };
- return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function(match) {
- return replace[match];
- });
- }
-
- function decode(str) {
- return str
- .replace(/[ +]/g, '%20')
- .replace(/(%[a-f0-9]{2})+/ig, function(match) {
- return decodeURIComponent(match);
- });
- }
-
- function makeIterator(arr) {
- var iterator = {
- next: function() {
- var value = arr.shift();
- return {done: value === undefined, value: value};
- }
- };
-
- if (iterable) {
- iterator[self.Symbol.iterator] = function() {
- return iterator;
- };
- }
-
+ iterator[self.Symbol.iterator] = function () {
return iterator;
+ };
}
- function parseToDict(search) {
- var dict = {};
-
- if (typeof search === "object") {
- // if `search` is an array, treat it as a sequence
- if (isArray(search)) {
- for (var i = 0; i < search.length; i++) {
- var item = search[i];
- if (isArray(item) && item.length === 2) {
- appendTo(dict, item[0], item[1]);
- } else {
- throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
- }
- }
-
- } else {
- for (var key in search) {
- if (search.hasOwnProperty(key)) {
- appendTo(dict, key, search[key]);
- }
- }
- }
-
- } else {
- // remove first '?'
- if (search.indexOf("?") === 0) {
- search = search.slice(1);
- }
-
- var pairs = search.split("&");
- for (var j = 0; j < pairs.length; j++) {
- var value = pairs [j],
- index = value.indexOf('=');
-
- if (-1 < index) {
- appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
-
- } else {
- if (value) {
- appendTo(dict, decode(value), '');
- }
- }
- }
+ return iterator;
+ }
+
+ function parseToDict(search) {
+ var dict = {};
+
+ if (typeof search === 'object') {
+ // if `search` is an array, treat it as a sequence
+ if (isArray(search)) {
+ for (var i = 0; i < search.length; i++) {
+ var item = search[i];
+ if (isArray(item) && item.length === 2) {
+ appendTo(dict, item[0], item[1]);
+ } else {
+ throw new TypeError(
+ "Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements"
+ );
+ }
}
-
- return dict;
- }
-
- function appendTo(dict, name, value) {
- var val = typeof value === 'string' ? value : (
- value !== null && value !== undefined && typeof value.toString === 'function' ? value.toString() : JSON.stringify(value)
- )
-
- if (name in dict) {
- dict[name].push(val);
+ } else {
+ for (var key in search) {
+ if (search.hasOwnProperty(key)) {
+ appendTo(dict, key, search[key]);
+ }
+ }
+ }
+ } else {
+ // remove first '?'
+ if (search.indexOf('?') === 0) {
+ search = search.slice(1);
+ }
+
+ var pairs = search.split('&');
+ for (var j = 0; j < pairs.length; j++) {
+ var value = pairs[j],
+ index = value.indexOf('=');
+
+ if (-1 < index) {
+ appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
} else {
- dict[name] = [val];
+ if (value) {
+ appendTo(dict, decode(value), '');
+ }
}
+ }
}
- function isArray(val) {
- return !!val && '[object Array]' === Object.prototype.toString.call(val);
+ return dict;
+ }
+
+ function appendTo(dict, name, value) {
+ var val =
+ typeof value === 'string'
+ ? value
+ : value !== null && value !== undefined && typeof value.toString === 'function'
+ ? value.toString()
+ : JSON.stringify(value);
+
+ if (name in dict) {
+ dict[name].push(val);
+ } else {
+ dict[name] = [val];
}
+ }
-})(typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : this));
+ function isArray(val) {
+ return !!val && '[object Array]' === Object.prototype.toString.call(val);
+ }
+})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this);
diff --git a/shims/jsonata.js b/shims/jsonata.js
index 928f907..d83fda6 100644
--- a/shims/jsonata.js
+++ b/shims/jsonata.js
@@ -6,15 +6,15 @@
*/
var runtime = (function (exports) {
- "use strict";
+ 'use strict';
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
+ var $Symbol = typeof Symbol === 'function' ? Symbol : {};
+ var iteratorSymbol = $Symbol.iterator || '@@iterator';
+ var asyncIteratorSymbol = $Symbol.asyncIterator || '@@asyncIterator';
+ var toStringTagSymbol = $Symbol.toStringTag || '@@toStringTag';
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
@@ -42,16 +42,16 @@ var runtime = (function (exports) {
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
- return { type: "normal", arg: fn.call(obj, arg) };
+ return { type: 'normal', arg: fn.call(obj, arg) };
} catch (err) {
- return { type: "throw", arg: err };
+ return { type: 'throw', arg: err };
}
}
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
+ var GenStateSuspendedStart = 'suspendedStart';
+ var GenStateSuspendedYield = 'suspendedYield';
+ var GenStateExecuting = 'executing';
+ var GenStateCompleted = 'completed';
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
@@ -74,48 +74,48 @@ var runtime = (function (exports) {
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
- if (NativeIteratorPrototype &&
- NativeIteratorPrototype !== Op &&
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
+ if (
+ NativeIteratorPrototype &&
+ NativeIteratorPrototype !== Op &&
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)
+ ) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
- var Gp = GeneratorFunctionPrototype.prototype =
- Generator.prototype = Object.create(IteratorPrototype);
+ var Gp = (GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype));
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
- GeneratorFunctionPrototype[toStringTagSymbol] =
- GeneratorFunction.displayName = "GeneratorFunction";
+ GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = 'GeneratorFunction';
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- prototype[method] = function(arg) {
+ ['next', 'throw', 'return'].forEach(function (method) {
+ prototype[method] = function (arg) {
return this._invoke(method, arg);
};
});
}
- exports.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
+ exports.isGeneratorFunction = function (genFun) {
+ var ctor = typeof genFun === 'function' && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
+ // For the native GeneratorFunction constructor, the best we can
+ // do is to check its .name property.
+ (ctor.displayName || ctor.name) === 'GeneratorFunction'
: false;
};
- exports.mark = function(genFun) {
+ exports.mark = function (genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
- genFun[toStringTagSymbol] = "GeneratorFunction";
+ genFun[toStringTagSymbol] = 'GeneratorFunction';
}
}
genFun.prototype = Object.create(Gp);
@@ -126,39 +126,43 @@ var runtime = (function (exports) {
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
- exports.awrap = function(arg) {
+ exports.awrap = function (arg) {
return { __await: arg };
};
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
+ if (record.type === 'throw') {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
- if (value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")) {
- return Promise.resolve(value.__await).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
-
- return Promise.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration.
- result.value = unwrapped;
- resolve(result);
- }, function(error) {
- // If a rejected Promise was yielded, throw the rejection back
- // into the async generator function so it can be handled there.
- return invoke("throw", error, resolve, reject);
- });
+ if (value && typeof value === 'object' && hasOwn.call(value, '__await')) {
+ return Promise.resolve(value.__await).then(
+ function (value) {
+ invoke('next', value, resolve, reject);
+ },
+ function (err) {
+ invoke('throw', err, resolve, reject);
+ }
+ );
+ }
+
+ return Promise.resolve(value).then(
+ function (unwrapped) {
+ // When a yielded Promise is resolved, its final value becomes
+ // the .value of the Promise<{value,done}> result for the
+ // current iteration.
+ result.value = unwrapped;
+ resolve(result);
+ },
+ function (error) {
+ // If a rejected Promise was yielded, throw the rejection back
+ // into the async generator function so it can be handled there.
+ return invoke('throw', error, resolve, reject);
+ }
+ );
}
}
@@ -166,12 +170,12 @@ var runtime = (function (exports) {
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
- return previousPromise =
+ return (previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
@@ -184,12 +188,14 @@ var runtime = (function (exports) {
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
+ previousPromise
+ ? previousPromise.then(
+ callInvokeWithMethodAndArg,
+ // Avoid propagating failures to Promises returned by later
+ // invocations of the iterator.
+ callInvokeWithMethodAndArg
+ )
+ : callInvokeWithMethodAndArg());
}
// Define the unified helper method that is used to implement .next,
@@ -206,14 +212,12 @@ var runtime = (function (exports) {
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
- exports.async = function(innerFn, outerFn, self, tryLocsList) {
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList)
- );
+ exports.async = function (innerFn, outerFn, self, tryLocsList) {
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
return exports.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
+ : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
};
@@ -223,11 +227,11 @@ var runtime = (function (exports) {
return function invoke(method, arg) {
if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
+ throw new Error('Generator is already running');
}
if (state === GenStateCompleted) {
- if (method === "throw") {
+ if (method === 'throw') {
throw arg;
}
@@ -249,32 +253,28 @@ var runtime = (function (exports) {
}
}
- if (context.method === "next") {
+ if (context.method === 'next') {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;
-
- } else if (context.method === "throw") {
+ } else if (context.method === 'throw') {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}
context.dispatchException(context.arg);
-
- } else if (context.method === "return") {
- context.abrupt("return", context.arg);
+ } else if (context.method === 'return') {
+ context.abrupt('return', context.arg);
}
state = GenStateExecuting;
var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
+ if (record.type === 'normal') {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
if (record.arg === ContinueSentinel) {
continue;
@@ -282,14 +282,13 @@ var runtime = (function (exports) {
return {
value: record.arg,
- done: context.done
+ done: context.done,
};
-
- } else if (record.type === "throw") {
+ } else if (record.type === 'throw') {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
- context.method = "throw";
+ context.method = 'throw';
context.arg = record.arg;
}
}
@@ -307,25 +306,24 @@ var runtime = (function (exports) {
// method always terminates the yield* loop.
context.delegate = null;
- if (context.method === "throw") {
+ if (context.method === 'throw') {
// Note: ["return"] must be used for ES3 parsing compatibility.
- if (delegate.iterator["return"]) {
+ if (delegate.iterator['return']) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
- context.method = "return";
+ context.method = 'return';
context.arg = undefined;
maybeInvokeDelegate(delegate, context);
- if (context.method === "throw") {
+ if (context.method === 'throw') {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}
- context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method");
+ context.method = 'throw';
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
@@ -333,8 +331,8 @@ var runtime = (function (exports) {
var record = tryCatch(method, delegate.iterator, context.arg);
- if (record.type === "throw") {
- context.method = "throw";
+ if (record.type === 'throw') {
+ context.method = 'throw';
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
@@ -342,9 +340,9 @@ var runtime = (function (exports) {
var info = record.arg;
- if (! info) {
- context.method = "throw";
- context.arg = new TypeError("iterator result is not an object");
+ if (!info) {
+ context.method = 'throw';
+ context.arg = new TypeError('iterator result is not an object');
context.delegate = null;
return ContinueSentinel;
}
@@ -363,11 +361,10 @@ var runtime = (function (exports) {
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
- if (context.method !== "return") {
- context.method = "next";
+ if (context.method !== 'return') {
+ context.method = 'next';
context.arg = undefined;
}
-
} else {
// Re-yield the result returned by the delegate method.
return info;
@@ -383,19 +380,19 @@ var runtime = (function (exports) {
// unified ._invoke helper method.
defineIteratorMethods(Gp);
- Gp[toStringTagSymbol] = "Generator";
+ Gp[toStringTagSymbol] = 'Generator';
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
- Gp[iteratorSymbol] = function() {
+ Gp[iteratorSymbol] = function () {
return this;
};
- Gp.toString = function() {
- return "[object Generator]";
+ Gp.toString = function () {
+ return '[object Generator]';
};
function pushTryEntry(locs) {
@@ -415,7 +412,7 @@ var runtime = (function (exports) {
function resetTryEntry(entry) {
var record = entry.completion || {};
- record.type = "normal";
+ record.type = 'normal';
delete record.arg;
entry.completion = record;
}
@@ -424,12 +421,12 @@ var runtime = (function (exports) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
+ this.tryEntries = [{ tryLoc: 'root' }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}
- exports.keys = function(object) {
+ exports.keys = function (object) {
var keys = [];
for (var key in object) {
keys.push(key);
@@ -463,27 +460,28 @@ var runtime = (function (exports) {
return iteratorMethod.call(iterable);
}
- if (typeof iterable.next === "function") {
+ if (typeof iterable.next === 'function') {
return iterable;
}
if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
+ var i = -1,
+ next = function next() {
+ while (++i < iterable.length) {
+ if (hasOwn.call(iterable, i)) {
+ next.value = iterable[i];
+ next.done = false;
+ return next;
+ }
}
- }
- next.value = undefined;
- next.done = true;
+ next.value = undefined;
+ next.done = true;
- return next;
- };
+ return next;
+ };
- return next.next = next;
+ return (next.next = next);
}
}
@@ -499,7 +497,7 @@ var runtime = (function (exports) {
Context.prototype = {
constructor: Context,
- reset: function(skipTempReset) {
+ reset: function (skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
@@ -508,7 +506,7 @@ var runtime = (function (exports) {
this.done = false;
this.delegate = null;
- this.method = "next";
+ this.method = 'next';
this.arg = undefined;
this.tryEntries.forEach(resetTryEntry);
@@ -516,62 +514,60 @@ var runtime = (function (exports) {
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
+ if (name.charAt(0) === 't' && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
- stop: function() {
+ stop: function () {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
+ if (rootRecord.type === 'throw') {
throw rootRecord.arg;
}
return this.rval;
},
- dispatchException: function(exception) {
+ dispatchException: function (exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
- record.type = "throw";
+ record.type = 'throw';
record.arg = exception;
context.next = loc;
if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
- context.method = "next";
+ context.method = 'next';
context.arg = undefined;
}
- return !! caught;
+ return !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
- if (entry.tryLoc === "root") {
+ if (entry.tryLoc === 'root') {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
- return handle("end");
+ return handle('end');
}
if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
+ var hasCatch = hasOwn.call(entry, 'catchLoc');
+ var hasFinally = hasOwn.call(entry, 'finallyLoc');
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
@@ -579,40 +575,36 @@ var runtime = (function (exports) {
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
-
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
-
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
-
} else {
- throw new Error("try statement without catch or finally");
+ throw new Error('try statement without catch or finally');
}
}
}
},
- abrupt: function(type, arg) {
+ abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, 'finallyLoc') && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
+ if (
+ finallyEntry &&
+ (type === 'break' || type === 'continue') &&
+ finallyEntry.tryLoc <= arg &&
+ arg <= finallyEntry.finallyLoc
+ ) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
@@ -623,7 +615,7 @@ var runtime = (function (exports) {
record.arg = arg;
if (finallyEntry) {
- this.method = "next";
+ this.method = 'next';
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}
@@ -631,26 +623,25 @@ var runtime = (function (exports) {
return this.complete(record);
},
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
+ complete: function (record, afterLoc) {
+ if (record.type === 'throw') {
throw record.arg;
}
- if (record.type === "break" ||
- record.type === "continue") {
+ if (record.type === 'break' || record.type === 'continue') {
this.next = record.arg;
- } else if (record.type === "return") {
+ } else if (record.type === 'return') {
this.rval = this.arg = record.arg;
- this.method = "return";
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
+ this.method = 'return';
+ this.next = 'end';
+ } else if (record.type === 'normal' && afterLoc) {
this.next = afterLoc;
}
return ContinueSentinel;
},
- finish: function(finallyLoc) {
+ finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
@@ -661,12 +652,12 @@ var runtime = (function (exports) {
}
},
- "catch": function(tryLoc) {
+ catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
- if (record.type === "throw") {
+ if (record.type === 'throw') {
var thrown = record.arg;
resetTryEntry(entry);
}
@@ -676,24 +667,24 @@ var runtime = (function (exports) {
// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
+ throw new Error('illegal catch attempt');
},
- delegateYield: function(iterable, resultName, nextLoc) {
+ delegateYield: function (iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
- nextLoc: nextLoc
+ nextLoc: nextLoc,
};
- if (this.method === "next") {
+ if (this.method === 'next') {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}
return ContinueSentinel;
- }
+ },
};
// Regardless of whether this script is executing as a CommonJS module
@@ -701,14 +692,13 @@ var runtime = (function (exports) {
// regeneratorRuntime in the outer scope, which allows this module to be
// injected easily by `bin/regenerator --include-runtime script.js`.
return exports;
-
-}(
+})(
// If this script is executing as a CommonJS module, use module.exports
// as the regeneratorRuntime namespace. Otherwise create a new empty
// object. Either way, the resulting object will be used to initialize
// the regeneratorRuntime variable at the top of this file.
- typeof module === "object" ? module.exports : {}
-));
+ typeof module === 'object' ? module.exports : {}
+);
try {
regeneratorRuntime = runtime;
@@ -722,7 +712,7 @@ try {
// you've misconfigured your bundler to force strict mode and applied a
// CSP to forbid Function, and you're not willing to fix either of those
// problems, please detail your unique predicament in a GitHub issue.
- Function("r", "regeneratorRuntime = r")(runtime);
+ Function('r', 'regeneratorRuntime = r')(runtime);
}
/**
@@ -731,13 +721,14 @@ try {
* This project is licensed under the MIT License, see LICENSE
*/
// This file contains polyfills (cut and pasted from MDN docs) required for the ES5 package
-Number.isInteger = Number.isInteger || function (value) {
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
-}; // Production steps of ECMA-262, Edition 6, 22.1.2.1
-
+Number.isInteger =
+ Number.isInteger ||
+ function (value) {
+ return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
+ }; // Production steps of ECMA-262, Edition 6, 22.1.2.1
if (!Array.from) {
- Array.from = function () {
+ Array.from = (function () {
'use strict';
var toStr = Object.prototype.toString;
@@ -765,9 +756,9 @@ if (!Array.from) {
return len >>> 0;
}; // The length property of the from method is 1.
-
- return function from(arrayLike
- /*, mapFn, thisArg */
+ return function from(
+ arrayLike
+ /*, mapFn, thisArg */
) {
// 1. Let C be the this value.
var C = this; // 2. Let items be ToObject(arrayLike).
@@ -778,7 +769,6 @@ if (!Array.from) {
throw new TypeError('Array.from requires an array-like object - not null or undefined');
} // 4. If mapfn is undefined, then let mapping be false.
-
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
@@ -789,14 +779,12 @@ if (!Array.from) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
} // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
-
if (arguments.length > 2) {
T = arguments[2];
}
} // 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
-
var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
@@ -820,59 +808,61 @@ if (!Array.from) {
k += 1;
} // 18. Let putStatus be Put(A, "length", len, true).
-
A.length = len; // 20. Return A.
return A;
};
- }();
+ })();
}
-if (!String.fromCodePoint) (function (stringFromCharCode) {
- var fromCodePoint = function (_) {
- var codeUnits = [],
+if (!String.fromCodePoint)
+ (function (stringFromCharCode) {
+ var fromCodePoint = function (_) {
+ var codeUnits = [],
codeLen = 0,
- result = "";
+ result = '';
- for (var index = 0, len = arguments.length; index !== len; ++index) {
- var codePoint = +arguments[index]; // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`
- // The surrounding `!(...)` is required to correctly handle `NaN` cases
- // The (codePoint>>>0) === codePoint clause handles decimals and negatives
+ for (var index = 0, len = arguments.length; index !== len; ++index) {
+ var codePoint = +arguments[index]; // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`
+ // The surrounding `!(...)` is required to correctly handle `NaN` cases
+ // The (codePoint>>>0) === codePoint clause handles decimals and negatives
- if (!(codePoint < 0x10FFFF && codePoint >>> 0 === codePoint)) throw RangeError("Invalid code point: " + codePoint);
+ if (!(codePoint < 0x10ffff && codePoint >>> 0 === codePoint))
+ throw RangeError('Invalid code point: ' + codePoint);
- if (codePoint <= 0xFFFF) {
- // BMP code point
- codeLen = codeUnits.push(codePoint);
- } else {
- // Astral code point; split in surrogate halves
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- codePoint -= 0x10000;
- codeLen = codeUnits.push((codePoint >> 10) + 0xD800, // highSurrogate
- codePoint % 0x400 + 0xDC00 // lowSurrogate
- );
- }
+ if (codePoint <= 0xffff) {
+ // BMP code point
+ codeLen = codeUnits.push(codePoint);
+ } else {
+ // Astral code point; split in surrogate halves
+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ codePoint -= 0x10000;
+ codeLen = codeUnits.push(
+ (codePoint >> 10) + 0xd800, // highSurrogate
+ (codePoint % 0x400) + 0xdc00 // lowSurrogate
+ );
+ }
- if (codeLen >= 0x3fff) {
- result += stringFromCharCode.apply(null, codeUnits);
- codeUnits.length = 0;
+ if (codeLen >= 0x3fff) {
+ result += stringFromCharCode.apply(null, codeUnits);
+ codeUnits.length = 0;
+ }
}
- }
- return result + stringFromCharCode.apply(null, codeUnits);
- };
+ return result + stringFromCharCode.apply(null, codeUnits);
+ };
- try {
- // IE 8 only supports `Object.defineProperty` on DOM elements
- Object.defineProperty(String, "fromCodePoint", {
- "value": fromCodePoint,
- "configurable": true,
- "writable": true
- });
- } catch (e) {
- String.fromCodePoint = fromCodePoint;
- }
-})(String.fromCharCode);
+ try {
+ // IE 8 only supports `Object.defineProperty` on DOM elements
+ Object.defineProperty(String, 'fromCodePoint', {
+ value: fromCodePoint,
+ configurable: true,
+ writable: true,
+ });
+ } catch (e) {
+ String.fromCodePoint = fromCodePoint;
+ }
+ })(String.fromCharCode);
if (!Object.is) {
Object.is = function (x, y) {
@@ -889,12 +879,11 @@ if (!Object.is) {
}
/*! https://mths.be/codepointat v0.2.0 by @mathias */
-
if (!String.prototype.codePointAt) {
(function () {
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
- var defineProperty = function () {
+ var defineProperty = (function () {
// IE 8 only supports `Object.defineProperty` on DOM elements
try {
var object = {};
@@ -903,7 +892,7 @@ if (!String.prototype.codePointAt) {
} catch (error) {}
return result;
- }();
+ })();
var codePointAt = function (position) {
if (this == null) {
@@ -920,36 +909,36 @@ if (!String.prototype.codePointAt) {
index = 0;
} // Account for out-of-bounds indices:
-
if (index < 0 || index >= size) {
return undefined;
} // Get the first code unit
-
var first = string.charCodeAt(index);
var second;
- if ( // check if it’s the start of a surrogate pair
- first >= 0xD800 && first <= 0xDBFF && // high surrogate
- size > index + 1 // there is a next code unit
+ if (
+ // check if it’s the start of a surrogate pair
+ first >= 0xd800 &&
+ first <= 0xdbff && // high surrogate
+ size > index + 1 // there is a next code unit
) {
- second = string.charCodeAt(index + 1);
+ second = string.charCodeAt(index + 1);
- if (second >= 0xDC00 && second <= 0xDFFF) {
- // low surrogate
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
- }
+ if (second >= 0xdc00 && second <= 0xdfff) {
+ // low surrogate
+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000;
}
+ }
return first;
};
if (defineProperty) {
defineProperty(String.prototype, 'codePointAt', {
- 'value': codePointAt,
- 'configurable': true,
- 'writable': true
+ value: codePointAt,
+ configurable: true,
+ writable: true,
});
} else {
String.prototype.codePointAt = codePointAt;
@@ -957,9861 +946,10300 @@ if (!String.prototype.codePointAt) {
})();
}
-Math.log10 = Math.log10 || function (x) {
- return Math.log(x) * Math.LOG10E;
-};
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsonata = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) {
+ words += '-' + lookup(remainder, false, ord);
+ } else if (ord) {
+ words = words.substring(0, words.length - 1) + 'ieth';
+ }
+ } else if (num < 1000) {
+ var hundreds = Math.floor(num / 100);
-/**
- * © Copyright IBM Corp. 2018 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
+ var _remainder = num % 100;
-/**
- * DateTime formatting and parsing functions
- * Implements the xpath-functions format-date-time specification
- * @type {{formatInteger, formatDateTime, parseInteger, parseDateTime}}
- */
-var dateTime = function () {
- 'use strict';
+ words = (prev ? ', ' : '') + few[hundreds] + ' Hundred';
- var few = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
- var ordinals = ['Zeroth', 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth', 'Thirteenth', 'Fourteenth', 'Fifteenth', 'Sixteenth', 'Seventeenth', 'Eighteenth', 'Nineteenth'];
- var decades = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety', 'Hundred'];
- var magnitudes = ['Thousand', 'Million', 'Billion', 'Trillion'];
- /**
- * converts a number into english words
- * @param {string} value - the value to format
- * @param {boolean} ordinal - ordinal or cardinal form
- * @returns {string} - representation in words
- */
-
- function numberToWords(value, ordinal) {
- var lookup = function lookup(num, prev, ord) {
- var words = '';
-
- if (num <= 19) {
- words = (prev ? ' and ' : '') + (ord ? ordinals[num] : few[num]);
- } else if (num < 100) {
- var tens = Math.floor(num / 10);
- var remainder = num % 10;
- words = (prev ? ' and ' : '') + decades[tens - 2];
-
- if (remainder > 0) {
- words += '-' + lookup(remainder, false, ord);
- } else if (ord) {
- words = words.substring(0, words.length - 1) + 'ieth';
- }
- } else if (num < 1000) {
- var hundreds = Math.floor(num / 100);
+ if (_remainder > 0) {
+ words += lookup(_remainder, true, ord);
+ } else if (ord) {
+ words += 'th';
+ }
+ } else {
+ var mag = Math.floor(Math.log10(num) / 3);
- var _remainder = num % 100;
+ if (mag > magnitudes.length) {
+ mag = magnitudes.length; // the largest word
+ }
- words = (prev ? ', ' : '') + few[hundreds] + ' Hundred';
+ var factor = Math.pow(10, mag * 3);
+ var mant = Math.floor(num / factor);
- if (_remainder > 0) {
- words += lookup(_remainder, true, ord);
- } else if (ord) {
- words += 'th';
- }
- } else {
- var mag = Math.floor(Math.log10(num) / 3);
+ var _remainder2 = num - mant * factor;
- if (mag > magnitudes.length) {
- mag = magnitudes.length; // the largest word
- }
+ words = (prev ? ', ' : '') + lookup(mant, false, false) + ' ' + magnitudes[mag - 1];
- var factor = Math.pow(10, mag * 3);
- var mant = Math.floor(num / factor);
+ if (_remainder2 > 0) {
+ words += lookup(_remainder2, true, ord);
+ } else if (ord) {
+ words += 'th';
+ }
+ }
- var _remainder2 = num - mant * factor;
+ return words;
+ };
- words = (prev ? ', ' : '') + lookup(mant, false, false) + ' ' + magnitudes[mag - 1];
+ var words = lookup(value, false, ordinal);
+ return words;
+ }
- if (_remainder2 > 0) {
- words += lookup(_remainder2, true, ord);
- } else if (ord) {
- words += 'th';
- }
- }
+ var wordValues = {};
+ few.forEach(function (word, index) {
+ wordValues[word.toLowerCase()] = index;
+ });
+ ordinals.forEach(function (word, index) {
+ wordValues[word.toLowerCase()] = index;
+ });
+ decades.forEach(function (word, index) {
+ var lword = word.toLowerCase();
+ wordValues[lword] = (index + 2) * 10;
+ wordValues[lword.substring(0, word.length - 1) + 'ieth'] = wordValues[lword];
+ });
+ wordValues.hundredth = 100;
+ magnitudes.forEach(function (word, index) {
+ var lword = word.toLowerCase();
+ var val = Math.pow(10, (index + 1) * 3);
+ wordValues[lword] = val;
+ wordValues[lword + 'th'] = val;
+ });
+ /**
+ * Converts a number in english words to numeric value
+ * @param {string} text - the number in words
+ * @returns {number} - the numeric value
+ */
+
+ function wordsToNumber(text) {
+ var parts = text.split(/,\s|\sand\s|[\s\\-]/);
+ var values = parts.map(function (part) {
+ return wordValues[part];
+ });
+ var segs = [0];
+ values.forEach(function (value) {
+ if (value < 100) {
+ var top = segs.pop();
+
+ if (top >= 1000) {
+ segs.push(top);
+ top = 0;
+ }
- return words;
- };
+ segs.push(top + value);
+ } else {
+ segs.push(segs.pop() * value);
+ }
+ });
+ var result = segs.reduce(function (a, b) {
+ return a + b;
+ }, 0);
+ return result;
+ }
+
+ var romanNumerals = [
+ [1000, 'm'],
+ [900, 'cm'],
+ [500, 'd'],
+ [400, 'cd'],
+ [100, 'c'],
+ [90, 'xc'],
+ [50, 'l'],
+ [40, 'xl'],
+ [10, 'x'],
+ [9, 'ix'],
+ [5, 'v'],
+ [4, 'iv'],
+ [1, 'i'],
+ ];
+ var romanValues = {
+ M: 1000,
+ D: 500,
+ C: 100,
+ L: 50,
+ X: 10,
+ V: 5,
+ I: 1,
+ };
+ /**
+ * converts a number to roman numerals
+ * @param {number} value - the number
+ * @returns {string} - the number in roman numerals
+ */
+
+ function decimalToRoman(value) {
+ for (var index = 0; index < romanNumerals.length; index++) {
+ var numeral = romanNumerals[index];
+
+ if (value >= numeral[0]) {
+ return numeral[1] + decimalToRoman(value - numeral[0]);
+ }
+ }
- var words = lookup(value, false, ordinal);
- return words;
- }
+ return '';
+ }
+ /**
+ * converts roman numerals to a number
+ * @param {string} roman - roman number
+ * @returns {number} - the numeric value
+ */
- var wordValues = {};
- few.forEach(function (word, index) {
- wordValues[word.toLowerCase()] = index;
- });
- ordinals.forEach(function (word, index) {
- wordValues[word.toLowerCase()] = index;
- });
- decades.forEach(function (word, index) {
- var lword = word.toLowerCase();
- wordValues[lword] = (index + 2) * 10;
- wordValues[lword.substring(0, word.length - 1) + 'ieth'] = wordValues[lword];
- });
- wordValues.hundredth = 100;
- magnitudes.forEach(function (word, index) {
- var lword = word.toLowerCase();
- var val = Math.pow(10, (index + 1) * 3);
- wordValues[lword] = val;
- wordValues[lword + 'th'] = val;
- });
- /**
- * Converts a number in english words to numeric value
- * @param {string} text - the number in words
- * @returns {number} - the numeric value
- */
-
- function wordsToNumber(text) {
- var parts = text.split(/,\s|\sand\s|[\s\\-]/);
- var values = parts.map(function (part) {
- return wordValues[part];
- });
- var segs = [0];
- values.forEach(function (value) {
- if (value < 100) {
- var top = segs.pop();
-
- if (top >= 1000) {
- segs.push(top);
- top = 0;
- }
+ function romanToDecimal(roman) {
+ var decimal = 0;
+ var max = 1;
- segs.push(top + value);
- } else {
- segs.push(segs.pop() * value);
- }
- });
- var result = segs.reduce(function (a, b) {
- return a + b;
- }, 0);
- return result;
- }
+ for (var i = roman.length - 1; i >= 0; i--) {
+ var digit = roman[i];
+ var value = romanValues[digit];
- var romanNumerals = [[1000, 'm'], [900, 'cm'], [500, 'd'], [400, 'cd'], [100, 'c'], [90, 'xc'], [50, 'l'], [40, 'xl'], [10, 'x'], [9, 'ix'], [5, 'v'], [4, 'iv'], [1, 'i']];
- var romanValues = {
- 'M': 1000,
- 'D': 500,
- 'C': 100,
- 'L': 50,
- 'X': 10,
- 'V': 5,
- 'I': 1
- };
- /**
- * converts a number to roman numerals
- * @param {number} value - the number
- * @returns {string} - the number in roman numerals
- */
-
- function decimalToRoman(value) {
- for (var index = 0; index < romanNumerals.length; index++) {
- var numeral = romanNumerals[index];
-
- if (value >= numeral[0]) {
- return numeral[1] + decimalToRoman(value - numeral[0]);
- }
- }
+ if (value < max) {
+ decimal -= value;
+ } else {
+ max = value;
+ decimal += value;
+ }
+ }
- return '';
- }
- /**
- * converts roman numerals to a number
- * @param {string} roman - roman number
- * @returns {number} - the numeric value
- */
+ return decimal;
+ }
+ /**
+ * converts a number to spreadsheet style letters
+ * @param {number} value - the number
+ * @param {string} aChar - the character representing the start of the sequence, e.g. 'A'
+ * @returns {string} - the letters
+ */
+ function decimalToLetters(value, aChar) {
+ var letters = [];
+ var aCode = aChar.charCodeAt(0);
- function romanToDecimal(roman) {
- var decimal = 0;
- var max = 1;
+ while (value > 0) {
+ letters.unshift(String.fromCharCode(((value - 1) % 26) + aCode));
+ value = Math.floor((value - 1) / 26);
+ }
- for (var i = roman.length - 1; i >= 0; i--) {
- var digit = roman[i];
- var value = romanValues[digit];
+ return letters.join('');
+ }
+ /**
+ * converts spreadsheet style letters to a number
+ * @param {string} letters - the letters
+ * @param {string} aChar - the character representing the start of the sequence, e.g. 'A'
+ * @returns {number} - the numeric value
+ */
- if (value < max) {
- decimal -= value;
- } else {
- max = value;
- decimal += value;
- }
- }
+ function lettersToDecimal(letters, aChar) {
+ var aCode = aChar.charCodeAt(0);
+ var decimal = 0;
- return decimal;
- }
- /**
- * converts a number to spreadsheet style letters
- * @param {number} value - the number
- * @param {string} aChar - the character representing the start of the sequence, e.g. 'A'
- * @returns {string} - the letters
- */
+ for (var i = 0; i < letters.length; i++) {
+ decimal += (letters.charCodeAt(letters.length - i - 1) - aCode + 1) * Math.pow(26, i);
+ }
+ return decimal;
+ }
+ /**
+ * Formats an integer as specified by the XPath fn:format-integer function
+ * See https://www.w3.org/TR/xpath-functions-31/#func-format-integer
+ * @param {number} value - the number to be formatted
+ * @param {string} picture - the picture string that specifies the format
+ * @returns {string} - the formatted number
+ */
- function decimalToLetters(value, aChar) {
- var letters = [];
- var aCode = aChar.charCodeAt(0);
+ function formatInteger(value, picture) {
+ if (typeof value === 'undefined') {
+ return undefined;
+ }
- while (value > 0) {
- letters.unshift(String.fromCharCode((value - 1) % 26 + aCode));
- value = Math.floor((value - 1) / 26);
- }
+ value = Math.floor(value);
+ var format = analyseIntegerPicture(picture);
+ return _formatInteger(value, format);
+ }
- return letters.join('');
- }
- /**
- * converts spreadsheet style letters to a number
- * @param {string} letters - the letters
- * @param {string} aChar - the character representing the start of the sequence, e.g. 'A'
- * @returns {number} - the numeric value
- */
+ var formats = {
+ DECIMAL: 'decimal',
+ LETTERS: 'letters',
+ ROMAN: 'roman',
+ WORDS: 'words',
+ SEQUENCE: 'sequence',
+ };
+ var tcase = {
+ UPPER: 'upper',
+ LOWER: 'lower',
+ TITLE: 'title',
+ };
+ /**
+ * formats an integer using a preprocessed representation of the picture string
+ * @param {number} value - the number to be formatted
+ * @param {object} format - the preprocessed representation of the pucture string
+ * @returns {string} - the formatted number
+ * @private
+ */
+
+ function _formatInteger(value, format) {
+ var formattedInteger;
+ var negative = value < 0;
+ value = Math.abs(value);
+
+ switch (format.primary) {
+ case formats.LETTERS:
+ formattedInteger = decimalToLetters(value, format['case'] === tcase.UPPER ? 'A' : 'a');
+ break;
+
+ case formats.ROMAN:
+ formattedInteger = decimalToRoman(value);
+
+ if (format['case'] === tcase.UPPER) {
+ formattedInteger = formattedInteger.toUpperCase();
+ }
+ break;
- function lettersToDecimal(letters, aChar) {
- var aCode = aChar.charCodeAt(0);
- var decimal = 0;
+ case formats.WORDS:
+ formattedInteger = numberToWords(value, format.ordinal);
- for (var i = 0; i < letters.length; i++) {
- decimal += (letters.charCodeAt(letters.length - i - 1) - aCode + 1) * Math.pow(26, i);
- }
+ if (format['case'] === tcase.UPPER) {
+ formattedInteger = formattedInteger.toUpperCase();
+ } else if (format['case'] === tcase.LOWER) {
+ formattedInteger = formattedInteger.toLowerCase();
+ }
- return decimal;
- }
- /**
- * Formats an integer as specified by the XPath fn:format-integer function
- * See https://www.w3.org/TR/xpath-functions-31/#func-format-integer
- * @param {number} value - the number to be formatted
- * @param {string} picture - the picture string that specifies the format
- * @returns {string} - the formatted number
- */
-
-
- function formatInteger(value, picture) {
- if (typeof value === 'undefined') {
- return undefined;
- }
+ break;
- value = Math.floor(value);
- var format = analyseIntegerPicture(picture);
- return _formatInteger(value, format);
- }
+ case formats.DECIMAL:
+ formattedInteger = '' + value; // TODO use functionPad
- var formats = {
- DECIMAL: 'decimal',
- LETTERS: 'letters',
- ROMAN: 'roman',
- WORDS: 'words',
- SEQUENCE: 'sequence'
- };
- var tcase = {
- UPPER: 'upper',
- LOWER: 'lower',
- TITLE: 'title'
- };
- /**
- * formats an integer using a preprocessed representation of the picture string
- * @param {number} value - the number to be formatted
- * @param {object} format - the preprocessed representation of the pucture string
- * @returns {string} - the formatted number
- * @private
- */
-
- function _formatInteger(value, format) {
- var formattedInteger;
- var negative = value < 0;
- value = Math.abs(value);
-
- switch (format.primary) {
- case formats.LETTERS:
- formattedInteger = decimalToLetters(value, format["case"] === tcase.UPPER ? 'A' : 'a');
- break;
-
- case formats.ROMAN:
- formattedInteger = decimalToRoman(value);
-
- if (format["case"] === tcase.UPPER) {
- formattedInteger = formattedInteger.toUpperCase();
- }
+ var padLength = format.mandatoryDigits - formattedInteger.length;
- break;
+ if (padLength > 0) {
+ var padding = new Array(padLength + 1).join('0');
+ formattedInteger = padding + formattedInteger;
+ }
- case formats.WORDS:
- formattedInteger = numberToWords(value, format.ordinal);
+ if (format.zeroCode !== 0x30) {
+ formattedInteger = Array.from(formattedInteger)
+ .map(function (code) {
+ return String.fromCodePoint(code.codePointAt(0) + format.zeroCode - 0x30);
+ })
+ .join('');
+ } // insert the grouping-separator-signs, if any
+
+ if (format.regular) {
+ var n = Math.floor((formattedInteger.length - 1) / format.groupingSeparators.position);
+
+ for (var ii = n; ii > 0; ii--) {
+ var pos = formattedInteger.length - ii * format.groupingSeparators.position;
+ formattedInteger =
+ formattedInteger.substr(0, pos) +
+ format.groupingSeparators.character +
+ formattedInteger.substr(pos);
+ }
+ } else {
+ format.groupingSeparators.reverse().forEach(function (separator) {
+ var pos = formattedInteger.length - separator.position;
+ formattedInteger =
+ formattedInteger.substr(0, pos) + separator.character + formattedInteger.substr(pos);
+ });
+ }
- if (format["case"] === tcase.UPPER) {
- formattedInteger = formattedInteger.toUpperCase();
- } else if (format["case"] === tcase.LOWER) {
- formattedInteger = formattedInteger.toLowerCase();
- }
+ if (format.ordinal) {
+ var suffix123 = {
+ 1: 'st',
+ 2: 'nd',
+ 3: 'rd',
+ };
+ var lastDigit = formattedInteger[formattedInteger.length - 1];
+ var suffix = suffix123[lastDigit];
+
+ if (
+ !suffix ||
+ (formattedInteger.length > 1 && formattedInteger[formattedInteger.length - 2] === '1')
+ ) {
+ suffix = 'th';
+ }
- break;
+ formattedInteger = formattedInteger + suffix;
+ }
- case formats.DECIMAL:
- formattedInteger = '' + value; // TODO use functionPad
+ break;
- var padLength = format.mandatoryDigits - formattedInteger.length;
+ case formats.SEQUENCE:
+ throw {
+ code: 'D3130',
+ value: format.token,
+ };
+ }
- if (padLength > 0) {
- var padding = new Array(padLength + 1).join('0');
- formattedInteger = padding + formattedInteger;
- }
+ if (negative) {
+ formattedInteger = '-' + formattedInteger;
+ }
- if (format.zeroCode !== 0x30) {
- formattedInteger = Array.from(formattedInteger).map(function (code) {
- return String.fromCodePoint(code.codePointAt(0) + format.zeroCode - 0x30);
- }).join('');
- } // insert the grouping-separator-signs, if any
+ return formattedInteger;
+ } //TODO what about decimal groups in the unicode supplementary planes (surrogate pairs) ???
+
+ var decimalGroups = [
+ 0x30, 0x0660, 0x06f0, 0x07c0, 0x0966, 0x09e6, 0x0a66, 0x0ae6, 0x0b66, 0x0be6, 0x0c66, 0x0ce6, 0x0d66,
+ 0x0de6, 0x0e50, 0x0ed0, 0x0f20, 0x1040, 0x1090, 0x17e0, 0x1810, 0x1946, 0x19d0, 0x1a80, 0x1a90, 0x1b50,
+ 0x1bb0, 0x1c40, 0x1c50, 0xa620, 0xa8d0, 0xa900, 0xa9d0, 0xa9f0, 0xaa50, 0xabf0, 0xff10,
+ ];
+ /**
+ * preprocesses the picture string
+ * @param {string} picture - picture string
+ * @returns {{type: string, primary: string, case: string, ordinal: boolean}} - analysed picture
+ */
+
+ function analyseIntegerPicture(picture) {
+ var format = {
+ type: 'integer',
+ primary: formats.DECIMAL,
+ case: tcase.LOWER,
+ ordinal: false,
+ };
+ var primaryFormat, formatModifier;
+ var semicolon = picture.lastIndexOf(';');
+ if (semicolon === -1) {
+ primaryFormat = picture;
+ } else {
+ primaryFormat = picture.substring(0, semicolon);
+ formatModifier = picture.substring(semicolon + 1);
- if (format.regular) {
- var n = Math.floor((formattedInteger.length - 1) / format.groupingSeparators.position);
+ if (formatModifier[0] === 'o') {
+ format.ordinal = true;
+ }
+ }
+ /* eslnt-disable-next no-fallthrough */
+
+ switch (primaryFormat) {
+ case 'A':
+ format['case'] = tcase.UPPER;
+
+ /* eslnt-disable-next-line no-fallthrough */
+
+ case 'a':
+ format.primary = formats.LETTERS;
+ break;
+
+ case 'I':
+ format['case'] = tcase.UPPER;
+
+ /* eslnt-disable-next-line no-fallthrough */
+
+ case 'i':
+ format.primary = formats.ROMAN;
+ break;
+
+ case 'W':
+ format['case'] = tcase.UPPER;
+ format.primary = formats.WORDS;
+ break;
+
+ case 'Ww':
+ format['case'] = tcase.TITLE;
+ format.primary = formats.WORDS;
+ break;
+
+ case 'w':
+ format.primary = formats.WORDS;
+ break;
+
+ default: {
+ // this is a decimal-digit-pattern if it contains a decimal digit (from any unicode decimal digit group)
+ var zeroCode = null;
+ var mandatoryDigits = 0;
+ var optionalDigits = 0;
+ var groupingSeparators = [];
+ var separatorPosition = 0;
+ var formatCodepoints = Array.from(primaryFormat, function (c) {
+ return c.codePointAt(0);
+ }).reverse(); // reverse the array to determine positions of grouping-separator-signs
+
+ formatCodepoints.forEach(function (codePoint) {
+ // step though each char in the picture to determine the digit group
+ var digit = false;
+
+ for (var ii = 0; ii < decimalGroups.length; ii++) {
+ var group = decimalGroups[ii];
+
+ if (codePoint >= group && codePoint <= group + 9) {
+ // codepoint is part of this decimal group
+ digit = true;
+ mandatoryDigits++;
+ separatorPosition++;
+
+ if (zeroCode === null) {
+ zeroCode = group;
+ } else if (group !== zeroCode) {
+ // error! different decimal groups in the same pattern
+ throw {
+ code: 'D3131',
+ };
+ }
- for (var ii = n; ii > 0; ii--) {
- var pos = formattedInteger.length - ii * format.groupingSeparators.position;
- formattedInteger = formattedInteger.substr(0, pos) + format.groupingSeparators.character + formattedInteger.substr(pos);
- }
- } else {
- format.groupingSeparators.reverse().forEach(function (separator) {
- var pos = formattedInteger.length - separator.position;
- formattedInteger = formattedInteger.substr(0, pos) + separator.character + formattedInteger.substr(pos);
- });
- }
+ break;
+ }
+ }
- if (format.ordinal) {
- var suffix123 = {
- '1': 'st',
- '2': 'nd',
- '3': 'rd'
- };
- var lastDigit = formattedInteger[formattedInteger.length - 1];
- var suffix = suffix123[lastDigit];
+ if (!digit) {
+ if (codePoint === 0x23) {
+ // # - optional-digit-sign
+ separatorPosition++;
+ optionalDigits++;
+ } else {
+ // neither a decimal-digit-sign ot optional-digit-sign, assume it is a grouping-separator-sign
+ groupingSeparators.push({
+ position: separatorPosition,
+ character: String.fromCodePoint(codePoint),
+ });
+ }
+ }
+ });
- if (!suffix || formattedInteger.length > 1 && formattedInteger[formattedInteger.length - 2] === '1') {
- suffix = 'th';
- }
+ if (mandatoryDigits > 0) {
+ format.primary = formats.DECIMAL; // TODO validate decimal-digit-pattern
+ // the decimal digit family (codepoint offset)
- formattedInteger = formattedInteger + suffix;
- }
+ format.zeroCode = zeroCode; // the number of mandatory digits
- break;
+ format.mandatoryDigits = mandatoryDigits; // the number of optional digits
- case formats.SEQUENCE:
- throw {
- code: 'D3130',
- value: format.token
- };
- }
+ format.optionalDigits = optionalDigits; // grouping separator template
+ // are the grouping-separator-signs 'regular'?
- if (negative) {
- formattedInteger = '-' + formattedInteger;
- }
+ var regularRepeat = function regularRepeat(separators) {
+ // are the grouping positions regular? i.e. same interval between each of them
+ // is there at least one separator?
+ if (separators.length === 0) {
+ return 0;
+ } // are all the characters the same?
- return formattedInteger;
- } //TODO what about decimal groups in the unicode supplementary planes (surrogate pairs) ???
+ var sepChar = separators[0].character;
+ for (var ii = 1; ii < separators.length; ii++) {
+ if (separators[ii].character !== sepChar) {
+ return 0;
+ }
+ } // are they equally spaced?
- var decimalGroups = [0x30, 0x0660, 0x06F0, 0x07C0, 0x0966, 0x09E6, 0x0A66, 0x0AE6, 0x0B66, 0x0BE6, 0x0C66, 0x0CE6, 0x0D66, 0x0DE6, 0x0E50, 0x0ED0, 0x0F20, 0x1040, 0x1090, 0x17E0, 0x1810, 0x1946, 0x19D0, 0x1A80, 0x1A90, 0x1B50, 0x1BB0, 0x1C40, 0x1C50, 0xA620, 0xA8D0, 0xA900, 0xA9D0, 0xA9F0, 0xAA50, 0xABF0, 0xFF10];
- /**
- * preprocesses the picture string
- * @param {string} picture - picture string
- * @returns {{type: string, primary: string, case: string, ordinal: boolean}} - analysed picture
- */
+ var indexes = separators.map(function (separator) {
+ return separator.position;
+ });
- function analyseIntegerPicture(picture) {
- var format = {
- type: 'integer',
- primary: formats.DECIMAL,
- "case": tcase.LOWER,
- ordinal: false
- };
- var primaryFormat, formatModifier;
- var semicolon = picture.lastIndexOf(';');
+ var gcd = function gcd(a, b) {
+ return b === 0 ? a : gcd(b, a % b);
+ }; // find the greatest common divisor of all the positions
- if (semicolon === -1) {
- primaryFormat = picture;
- } else {
- primaryFormat = picture.substring(0, semicolon);
- formatModifier = picture.substring(semicolon + 1);
+ var factor = indexes.reduce(gcd); // is every position separated by this divisor? If so, it's regular
- if (formatModifier[0] === 'o') {
- format.ordinal = true;
- }
- }
- /* eslnt-disable-next no-fallthrough */
-
-
- switch (primaryFormat) {
- case 'A':
- format["case"] = tcase.UPPER;
-
- /* eslnt-disable-next-line no-fallthrough */
-
- case 'a':
- format.primary = formats.LETTERS;
- break;
-
- case 'I':
- format["case"] = tcase.UPPER;
-
- /* eslnt-disable-next-line no-fallthrough */
-
- case 'i':
- format.primary = formats.ROMAN;
- break;
-
- case 'W':
- format["case"] = tcase.UPPER;
- format.primary = formats.WORDS;
- break;
-
- case 'Ww':
- format["case"] = tcase.TITLE;
- format.primary = formats.WORDS;
- break;
-
- case 'w':
- format.primary = formats.WORDS;
- break;
-
- default:
- {
- // this is a decimal-digit-pattern if it contains a decimal digit (from any unicode decimal digit group)
- var zeroCode = null;
- var mandatoryDigits = 0;
- var optionalDigits = 0;
- var groupingSeparators = [];
- var separatorPosition = 0;
- var formatCodepoints = Array.from(primaryFormat, function (c) {
- return c.codePointAt(0);
- }).reverse(); // reverse the array to determine positions of grouping-separator-signs
-
- formatCodepoints.forEach(function (codePoint) {
- // step though each char in the picture to determine the digit group
- var digit = false;
-
- for (var ii = 0; ii < decimalGroups.length; ii++) {
- var group = decimalGroups[ii];
-
- if (codePoint >= group && codePoint <= group + 9) {
- // codepoint is part of this decimal group
- digit = true;
- mandatoryDigits++;
- separatorPosition++;
-
- if (zeroCode === null) {
- zeroCode = group;
- } else if (group !== zeroCode) {
- // error! different decimal groups in the same pattern
- throw {
- code: 'D3131'
- };
- }
+ for (var index = 1; index <= indexes.length; index++) {
+ if (indexes.indexOf(index * factor) === -1) {
+ return 0;
+ }
+ }
- break;
- }
- }
+ return factor;
+ };
- if (!digit) {
- if (codePoint === 0x23) {
- // # - optional-digit-sign
- separatorPosition++;
- optionalDigits++;
- } else {
- // neither a decimal-digit-sign ot optional-digit-sign, assume it is a grouping-separator-sign
- groupingSeparators.push({
- position: separatorPosition,
- character: String.fromCodePoint(codePoint)
- });
+ var regular = regularRepeat(groupingSeparators);
+
+ if (regular > 0) {
+ format.regular = true;
+ format.groupingSeparators = {
+ position: regular,
+ character: groupingSeparators[0].character,
+ };
+ } else {
+ format.regular = false;
+ format.groupingSeparators = groupingSeparators;
+ }
+ } else {
+ // this is a 'numbering sequence' which the spec says is implementation-defined
+ // this implementation doesn't support any numbering sequences at the moment.
+ format.primary = formats.SEQUENCE;
+ format.token = primaryFormat;
+ }
+ }
}
- }
- });
- if (mandatoryDigits > 0) {
- format.primary = formats.DECIMAL; // TODO validate decimal-digit-pattern
- // the decimal digit family (codepoint offset)
+ return format;
+ }
+
+ var defaultPresentationModifiers = {
+ Y: '1',
+ M: '1',
+ D: '1',
+ d: '1',
+ F: 'n',
+ W: '1',
+ w: '1',
+ X: '1',
+ x: '1',
+ H: '1',
+ h: '1',
+ P: 'n',
+ m: '01',
+ s: '01',
+ f: '1',
+ Z: '01:01',
+ z: '01:01',
+ C: 'n',
+ E: 'n',
+ }; // §9.8.4.1 the format specifier is an array of string literals and variable markers
+
+ /**
+ * analyse the date-time picture string
+ * @param {string} picture - picture string
+ * @returns {{type: string, parts: Array}} - the analysed string
+ */
+
+ function analyseDateTimePicture(picture) {
+ var spec = [];
+ var format = {
+ type: 'datetime',
+ parts: spec,
+ };
- format.zeroCode = zeroCode; // the number of mandatory digits
+ var addLiteral = function addLiteral(start, end) {
+ if (end > start) {
+ var literal = picture.substring(start, end); // replace any doubled ]] with single ]
+ // what if there are instances of single ']' ? - the spec doesn't say
- format.mandatoryDigits = mandatoryDigits; // the number of optional digits
+ literal = literal.split(']]').join(']');
+ spec.push({
+ type: 'literal',
+ value: literal,
+ });
+ }
+ };
- format.optionalDigits = optionalDigits; // grouping separator template
- // are the grouping-separator-signs 'regular'?
+ var start = 0,
+ pos = 0;
+
+ while (pos < picture.length) {
+ if (picture.charAt(pos) === '[') {
+ // check it's not a doubled [[
+ if (picture.charAt(pos + 1) === '[') {
+ // literal [
+ addLiteral(start, pos);
+ spec.push({
+ type: 'literal',
+ value: '[',
+ });
+ pos += 2;
+ start = pos;
+ continue;
+ } // start of variable marker
+ // push the string literal (if there is one) onto the array
+
+ addLiteral(start, pos);
+ start = pos; // search forward to closing ]
+
+ pos = picture.indexOf(']', start); // TODO handle error case if pos === -1
+
+ if (pos === -1) {
+ // error - no closing bracket
+ throw {
+ code: 'D3135',
+ };
+ }
- var regularRepeat = function regularRepeat(separators) {
- // are the grouping positions regular? i.e. same interval between each of them
- // is there at least one separator?
- if (separators.length === 0) {
- return 0;
- } // are all the characters the same?
+ var marker = picture.substring(start + 1, pos); // whitespace within a variable marker is ignored (i.e. remove it)
+ marker = marker.split(/\s+/).join('');
+ var def = {
+ type: 'marker',
+ component: marker.charAt(0), // 1. The component specifier is always present and is always a single letter.
+ };
+ var comma = marker.lastIndexOf(','); // 2. The width modifier may be recognized by the presence of a comma
- var sepChar = separators[0].character;
+ var presMod; // the presentation modifiers
- for (var ii = 1; ii < separators.length; ii++) {
- if (separators[ii].character !== sepChar) {
- return 0;
- }
- } // are they equally spaced?
+ if (comma !== -1) {
+ // §9.8.4.2 The Width Modifier
+ var widthMod = marker.substring(comma + 1);
+ var dash = widthMod.indexOf('-');
+ var min = void 0,
+ max = void 0;
+ var parseWidth = function parseWidth(wm) {
+ if (typeof wm === 'undefined' || wm === '*') {
+ return undefined;
+ } else {
+ // TODO validate wm is an unsigned int
+ return parseInt(wm);
+ }
+ };
- var indexes = separators.map(function (separator) {
- return separator.position;
- });
+ if (dash === -1) {
+ min = widthMod;
+ } else {
+ min = widthMod.substring(0, dash);
+ max = widthMod.substring(dash + 1);
+ }
- var gcd = function gcd(a, b) {
- return b === 0 ? a : gcd(b, a % b);
- }; // find the greatest common divisor of all the positions
+ var widthDef = {
+ min: parseWidth(min),
+ max: parseWidth(max),
+ };
+ def.width = widthDef;
+ presMod = marker.substring(1, comma);
+ } else {
+ presMod = marker.substring(1);
+ }
+ if (presMod.length === 1) {
+ def.presentation1 = presMod; // first presentation modifier
+ //TODO validate the first presentation modifier - it's either N, n, Nn or it passes analyseIntegerPicture
+ } else if (presMod.length > 1) {
+ var lastChar = presMod.charAt(presMod.length - 1);
- var factor = indexes.reduce(gcd); // is every position separated by this divisor? If so, it's regular
+ if ('atco'.indexOf(lastChar) !== -1) {
+ def.presentation2 = lastChar;
- for (var index = 1; index <= indexes.length; index++) {
- if (indexes.indexOf(index * factor) === -1) {
- return 0;
- }
- }
+ if (lastChar === 'o') {
+ def.ordinal = true;
+ } // 'c' means 'cardinal' and is the default (i.e. not 'ordinal')
+ // 'a' & 't' are ignored (not sure of their relevance to English numbering)
- return factor;
- };
+ def.presentation1 = presMod.substring(0, presMod.length - 1);
+ } else {
+ def.presentation1 = presMod; //TODO validate the first presentation modifier - it's either N, n, Nn or it passes analyseIntegerPicture,
+ // doesn't use ] as grouping separator, and if grouping separator is , then must have width modifier
+ }
+ } else {
+ // no presentation modifier specified - apply the default;
+ def.presentation1 = defaultPresentationModifiers[def.component];
+ }
- var regular = regularRepeat(groupingSeparators);
+ if (typeof def.presentation1 === 'undefined') {
+ // unknown component specifier
+ throw {
+ code: 'D3132',
+ value: def.component,
+ };
+ }
- if (regular > 0) {
- format.regular = true;
- format.groupingSeparators = {
- position: regular,
- character: groupingSeparators[0].character
- };
- } else {
- format.regular = false;
- format.groupingSeparators = groupingSeparators;
- }
- } else {
- // this is a 'numbering sequence' which the spec says is implementation-defined
- // this implementation doesn't support any numbering sequences at the moment.
- format.primary = formats.SEQUENCE;
- format.token = primaryFormat;
- }
- }
- }
+ if (def.presentation1[0] === 'n') {
+ def.names = tcase.LOWER;
+ } else if (def.presentation1[0] === 'N') {
+ if (def.presentation1[1] === 'n') {
+ def.names = tcase.TITLE;
+ } else {
+ def.names = tcase.UPPER;
+ }
+ } else if ('YMDdFWwXxHhmsf'.indexOf(def.component) !== -1) {
+ var integerPattern = def.presentation1;
- return format;
- }
+ if (def.presentation2) {
+ integerPattern += ';' + def.presentation2;
+ }
- var defaultPresentationModifiers = {
- Y: '1',
- M: '1',
- D: '1',
- d: '1',
- F: 'n',
- W: '1',
- w: '1',
- X: '1',
- x: '1',
- H: '1',
- h: '1',
- P: 'n',
- m: '01',
- s: '01',
- f: '1',
- Z: '01:01',
- z: '01:01',
- C: 'n',
- E: 'n'
- }; // §9.8.4.1 the format specifier is an array of string literals and variable markers
-
- /**
- * analyse the date-time picture string
- * @param {string} picture - picture string
- * @returns {{type: string, parts: Array}} - the analysed string
- */
-
- function analyseDateTimePicture(picture) {
- var spec = [];
- var format = {
- type: 'datetime',
- parts: spec
- };
+ def.integerFormat = analyseIntegerPicture(integerPattern);
- var addLiteral = function addLiteral(start, end) {
- if (end > start) {
- var literal = picture.substring(start, end); // replace any doubled ]] with single ]
- // what if there are instances of single ']' ? - the spec doesn't say
+ if (def.width && def.width.min !== undefined) {
+ if (def.integerFormat.mandatoryDigits < def.width.min) {
+ def.integerFormat.mandatoryDigits = def.width.min;
+ }
+ }
- literal = literal.split(']]').join(']');
- spec.push({
- type: 'literal',
- value: literal
- });
- }
- };
+ if (def.component === 'Y') {
+ // §9.8.4.4
+ def.n = -1;
- var start = 0,
- pos = 0;
-
- while (pos < picture.length) {
- if (picture.charAt(pos) === '[') {
- // check it's not a doubled [[
- if (picture.charAt(pos + 1) === '[') {
- // literal [
- addLiteral(start, pos);
- spec.push({
- type: 'literal',
- value: '['
- });
- pos += 2;
- start = pos;
- continue;
- } // start of variable marker
- // push the string literal (if there is one) onto the array
-
-
- addLiteral(start, pos);
- start = pos; // search forward to closing ]
-
- pos = picture.indexOf(']', start); // TODO handle error case if pos === -1
-
- if (pos === -1) {
- // error - no closing bracket
- throw {
- code: 'D3135'
- };
- }
+ if (def.width && def.width.max !== undefined) {
+ def.n = def.width.max;
+ def.integerFormat.mandatoryDigits = def.n;
+ } else {
+ var w = def.integerFormat.mandatoryDigits + def.integerFormat.optionalDigits;
- var marker = picture.substring(start + 1, pos); // whitespace within a variable marker is ignored (i.e. remove it)
+ if (w >= 2) {
+ def.n = w;
+ }
+ }
+ }
+ }
- marker = marker.split(/\s+/).join('');
- var def = {
- type: 'marker',
- component: marker.charAt(0) // 1. The component specifier is always present and is always a single letter.
+ if (def.component === 'Z' || def.component === 'z') {
+ def.integerFormat = analyseIntegerPicture(def.presentation1);
+ }
- };
- var comma = marker.lastIndexOf(','); // 2. The width modifier may be recognized by the presence of a comma
+ spec.push(def);
+ start = pos + 1;
+ }
- var presMod; // the presentation modifiers
+ pos++;
+ }
- if (comma !== -1) {
- // §9.8.4.2 The Width Modifier
- var widthMod = marker.substring(comma + 1);
- var dash = widthMod.indexOf('-');
- var min = void 0,
- max = void 0;
+ addLiteral(start, pos);
+ return format;
+ }
+
+ var days = ['', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
+ var months = [
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December',
+ ];
+ var millisInADay = 1000 * 60 * 60 * 24;
+
+ var startOfFirstWeek = function startOfFirstWeek(ym) {
+ // ISO 8601 defines the first week of the year to be the week that contains the first Thursday
+ // XPath F&O extends this same definition for the first week of a month
+ // the week starts on a Monday - calculate the millis for the start of the first week
+ // millis for given 1st Jan of that year (at 00:00 UTC)
+ var jan1 = Date.UTC(ym.year, ym.month);
+ var dayOfJan1 = new Date(jan1).getDay();
+
+ if (dayOfJan1 === 0) {
+ dayOfJan1 = 7;
+ } // if Jan 1 is Fri, Sat or Sun, then add the number of days (in millis) to jan1 to get the start of week 1
+
+ return dayOfJan1 > 4 ? jan1 + (8 - dayOfJan1) * millisInADay : jan1 - (dayOfJan1 - 1) * millisInADay;
+ };
- var parseWidth = function parseWidth(wm) {
- if (typeof wm === 'undefined' || wm === '*') {
- return undefined;
- } else {
- // TODO validate wm is an unsigned int
- return parseInt(wm);
- }
- };
+ var yearMonth = function yearMonth(year, month) {
+ return {
+ year: year,
+ month: month,
+ nextMonth: function nextMonth() {
+ return month === 11 ? yearMonth(year + 1, 0) : yearMonth(year, month + 1);
+ },
+ previousMonth: function previousMonth() {
+ return month === 0 ? yearMonth(year - 1, 11) : yearMonth(year, month - 1);
+ },
+ nextYear: function nextYear() {
+ return yearMonth(year + 1, month);
+ },
+ previousYear: function previousYear() {
+ return yearMonth(year - 1, month);
+ },
+ };
+ };
- if (dash === -1) {
- min = widthMod;
- } else {
- min = widthMod.substring(0, dash);
- max = widthMod.substring(dash + 1);
- }
+ var deltaWeeks = function deltaWeeks(start, end) {
+ return (end - start) / (millisInADay * 7) + 1;
+ };
- var widthDef = {
- min: parseWidth(min),
- max: parseWidth(max)
- };
- def.width = widthDef;
- presMod = marker.substring(1, comma);
- } else {
- presMod = marker.substring(1);
- }
+ var getDateTimeFragment = function getDateTimeFragment(date, component) {
+ var componentValue;
+
+ switch (component) {
+ case 'Y':
+ // year
+ componentValue = date.getUTCFullYear();
+ break;
+
+ case 'M':
+ // month in year
+ componentValue = date.getUTCMonth() + 1;
+ break;
+
+ case 'D':
+ // day in month
+ componentValue = date.getUTCDate();
+ break;
+
+ case 'd': {
+ // day in year
+ // millis for given date (at 00:00 UTC)
+ var today = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); // millis for given 1st Jan of that year (at 00:00 UTC)
+
+ var firstJan = Date.UTC(date.getUTCFullYear(), 0);
+ componentValue = (today - firstJan) / millisInADay + 1;
+ break;
+ }
- if (presMod.length === 1) {
- def.presentation1 = presMod; // first presentation modifier
- //TODO validate the first presentation modifier - it's either N, n, Nn or it passes analyseIntegerPicture
- } else if (presMod.length > 1) {
- var lastChar = presMod.charAt(presMod.length - 1);
+ case 'F':
+ // day of week
+ componentValue = date.getUTCDay();
- if ('atco'.indexOf(lastChar) !== -1) {
- def.presentation2 = lastChar;
+ if (componentValue === 0) {
+ // ISO 8601 defines days 1-7: Mon-Sun
+ componentValue = 7;
+ }
- if (lastChar === 'o') {
- def.ordinal = true;
- } // 'c' means 'cardinal' and is the default (i.e. not 'ordinal')
- // 'a' & 't' are ignored (not sure of their relevance to English numbering)
+ break;
+ case 'W': {
+ // week in year
+ var thisYear = yearMonth(date.getUTCFullYear(), 0);
+ var startOfWeek1 = startOfFirstWeek(thisYear);
- def.presentation1 = presMod.substring(0, presMod.length - 1);
- } else {
- def.presentation1 = presMod; //TODO validate the first presentation modifier - it's either N, n, Nn or it passes analyseIntegerPicture,
- // doesn't use ] as grouping separator, and if grouping separator is , then must have width modifier
- }
- } else {
- // no presentation modifier specified - apply the default;
- def.presentation1 = defaultPresentationModifiers[def.component];
- }
+ var _today = Date.UTC(thisYear.year, date.getUTCMonth(), date.getUTCDate());
- if (typeof def.presentation1 === 'undefined') {
- // unknown component specifier
- throw {
- code: 'D3132',
- value: def.component
- };
- }
+ var week = deltaWeeks(startOfWeek1, _today);
- if (def.presentation1[0] === 'n') {
- def.names = tcase.LOWER;
- } else if (def.presentation1[0] === 'N') {
- if (def.presentation1[1] === 'n') {
- def.names = tcase.TITLE;
- } else {
- def.names = tcase.UPPER;
- }
- } else if ('YMDdFWwXxHhmsf'.indexOf(def.component) !== -1) {
- var integerPattern = def.presentation1;
+ if (week > 52) {
+ // might be first week of the following year
+ var startOfFollowingYear = startOfFirstWeek(thisYear.nextYear());
- if (def.presentation2) {
- integerPattern += ';' + def.presentation2;
- }
-
- def.integerFormat = analyseIntegerPicture(integerPattern);
-
- if (def.width && def.width.min !== undefined) {
- if (def.integerFormat.mandatoryDigits < def.width.min) {
- def.integerFormat.mandatoryDigits = def.width.min;
- }
- }
-
- if (def.component === 'Y') {
- // §9.8.4.4
- def.n = -1;
-
- if (def.width && def.width.max !== undefined) {
- def.n = def.width.max;
- def.integerFormat.mandatoryDigits = def.n;
- } else {
- var w = def.integerFormat.mandatoryDigits + def.integerFormat.optionalDigits;
-
- if (w >= 2) {
- def.n = w;
- }
- }
- }
- }
-
- if (def.component === 'Z' || def.component === 'z') {
- def.integerFormat = analyseIntegerPicture(def.presentation1);
- }
-
- spec.push(def);
- start = pos + 1;
- }
-
- pos++;
- }
-
- addLiteral(start, pos);
- return format;
- }
-
- var days = ['', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
- var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- var millisInADay = 1000 * 60 * 60 * 24;
-
- var startOfFirstWeek = function startOfFirstWeek(ym) {
- // ISO 8601 defines the first week of the year to be the week that contains the first Thursday
- // XPath F&O extends this same definition for the first week of a month
- // the week starts on a Monday - calculate the millis for the start of the first week
- // millis for given 1st Jan of that year (at 00:00 UTC)
- var jan1 = Date.UTC(ym.year, ym.month);
- var dayOfJan1 = new Date(jan1).getDay();
-
- if (dayOfJan1 === 0) {
- dayOfJan1 = 7;
- } // if Jan 1 is Fri, Sat or Sun, then add the number of days (in millis) to jan1 to get the start of week 1
-
-
- return dayOfJan1 > 4 ? jan1 + (8 - dayOfJan1) * millisInADay : jan1 - (dayOfJan1 - 1) * millisInADay;
- };
-
- var yearMonth = function yearMonth(year, month) {
- return {
- year: year,
- month: month,
- nextMonth: function nextMonth() {
- return month === 11 ? yearMonth(year + 1, 0) : yearMonth(year, month + 1);
- },
- previousMonth: function previousMonth() {
- return month === 0 ? yearMonth(year - 1, 11) : yearMonth(year, month - 1);
- },
- nextYear: function nextYear() {
- return yearMonth(year + 1, month);
- },
- previousYear: function previousYear() {
- return yearMonth(year - 1, month);
- }
- };
- };
-
- var deltaWeeks = function deltaWeeks(start, end) {
- return (end - start) / (millisInADay * 7) + 1;
- };
-
- var getDateTimeFragment = function getDateTimeFragment(date, component) {
- var componentValue;
-
- switch (component) {
- case 'Y':
- // year
- componentValue = date.getUTCFullYear();
- break;
-
- case 'M':
- // month in year
- componentValue = date.getUTCMonth() + 1;
- break;
-
- case 'D':
- // day in month
- componentValue = date.getUTCDate();
- break;
-
- case 'd':
- {
- // day in year
- // millis for given date (at 00:00 UTC)
- var today = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); // millis for given 1st Jan of that year (at 00:00 UTC)
-
- var firstJan = Date.UTC(date.getUTCFullYear(), 0);
- componentValue = (today - firstJan) / millisInADay + 1;
- break;
- }
-
- case 'F':
- // day of week
- componentValue = date.getUTCDay();
-
- if (componentValue === 0) {
- // ISO 8601 defines days 1-7: Mon-Sun
- componentValue = 7;
- }
-
- break;
-
- case 'W':
- {
- // week in year
- var thisYear = yearMonth(date.getUTCFullYear(), 0);
- var startOfWeek1 = startOfFirstWeek(thisYear);
-
- var _today = Date.UTC(thisYear.year, date.getUTCMonth(), date.getUTCDate());
-
- var week = deltaWeeks(startOfWeek1, _today);
-
- if (week > 52) {
- // might be first week of the following year
- var startOfFollowingYear = startOfFirstWeek(thisYear.nextYear());
-
- if (_today >= startOfFollowingYear) {
- week = 1;
- }
- } else if (week < 1) {
- // must be end of the previous year
- var startOfPreviousYear = startOfFirstWeek(thisYear.previousYear());
- week = deltaWeeks(startOfPreviousYear, _today);
- }
-
- componentValue = Math.floor(week);
- break;
- }
-
- case 'w':
- {
- // week in month
- var thisMonth = yearMonth(date.getUTCFullYear(), date.getUTCMonth());
-
- var _startOfWeek = startOfFirstWeek(thisMonth);
-
- var _today2 = Date.UTC(thisMonth.year, thisMonth.month, date.getUTCDate());
+ if (_today >= startOfFollowingYear) {
+ week = 1;
+ }
+ } else if (week < 1) {
+ // must be end of the previous year
+ var startOfPreviousYear = startOfFirstWeek(thisYear.previousYear());
+ week = deltaWeeks(startOfPreviousYear, _today);
+ }
- var _week = deltaWeeks(_startOfWeek, _today2);
+ componentValue = Math.floor(week);
+ break;
+ }
- if (_week > 4) {
- // might be first week of the following month
- var startOfFollowingMonth = startOfFirstWeek(thisMonth.nextMonth());
+ case 'w': {
+ // week in month
+ var thisMonth = yearMonth(date.getUTCFullYear(), date.getUTCMonth());
- if (_today2 >= startOfFollowingMonth) {
- _week = 1;
- }
- } else if (_week < 1) {
- // must be end of the previous month
- var startOfPreviousMonth = startOfFirstWeek(thisMonth.previousMonth());
- _week = deltaWeeks(startOfPreviousMonth, _today2);
- }
+ var _startOfWeek = startOfFirstWeek(thisMonth);
- componentValue = Math.floor(_week);
- break;
- }
+ var _today2 = Date.UTC(thisMonth.year, thisMonth.month, date.getUTCDate());
- case 'X':
- {
- // ISO week-numbering year
- // Extension: The F&O spec says nothing about how to access the year associated with the week-of-the-year
- // e.g. Sat 1 Jan 2005 is in the 53rd week of 2004.
- // The 'W' component specifier gives 53, but 'Y' will give 2005.
- // I propose to add 'X' as the component specifier to give the ISO week-numbering year (2004 in this example)
- var _thisYear = yearMonth(date.getUTCFullYear(), 0);
-
- var startOfISOYear = startOfFirstWeek(_thisYear);
- var endOfISOYear = startOfFirstWeek(_thisYear.nextYear());
- var now = date.getTime();
-
- if (now < startOfISOYear) {
- componentValue = _thisYear.year - 1;
- } else if (now >= endOfISOYear) {
- componentValue = _thisYear.year + 1;
- } else {
- componentValue = _thisYear.year;
- }
+ var _week = deltaWeeks(_startOfWeek, _today2);
- break;
- }
+ if (_week > 4) {
+ // might be first week of the following month
+ var startOfFollowingMonth = startOfFirstWeek(thisMonth.nextMonth());
- case 'x':
- {
- // ISO week-numbering month
- // Extension: The F&O spec says nothing about how to access the month associated with the week-of-the-month
- // e.g. Sat 1 Jan 2005 is in the 5th week of December 2004.
- // The 'w' component specifier gives 5, but 'W' will give January and 'Y' will give 2005.
- // I propose to add 'x' as the component specifier to give the 'week-numbering' month (December in this example)
- var _thisMonth = yearMonth(date.getUTCFullYear(), date.getUTCMonth());
+ if (_today2 >= startOfFollowingMonth) {
+ _week = 1;
+ }
+ } else if (_week < 1) {
+ // must be end of the previous month
+ var startOfPreviousMonth = startOfFirstWeek(thisMonth.previousMonth());
+ _week = deltaWeeks(startOfPreviousMonth, _today2);
+ }
- var startOfISOMonth = startOfFirstWeek(_thisMonth);
+ componentValue = Math.floor(_week);
+ break;
+ }
- var nextMonth = _thisMonth.nextMonth();
+ case 'X': {
+ // ISO week-numbering year
+ // Extension: The F&O spec says nothing about how to access the year associated with the week-of-the-year
+ // e.g. Sat 1 Jan 2005 is in the 53rd week of 2004.
+ // The 'W' component specifier gives 53, but 'Y' will give 2005.
+ // I propose to add 'X' as the component specifier to give the ISO week-numbering year (2004 in this example)
+ var _thisYear = yearMonth(date.getUTCFullYear(), 0);
+
+ var startOfISOYear = startOfFirstWeek(_thisYear);
+ var endOfISOYear = startOfFirstWeek(_thisYear.nextYear());
+ var now = date.getTime();
+
+ if (now < startOfISOYear) {
+ componentValue = _thisYear.year - 1;
+ } else if (now >= endOfISOYear) {
+ componentValue = _thisYear.year + 1;
+ } else {
+ componentValue = _thisYear.year;
+ }
- var endOfISOMonth = startOfFirstWeek(nextMonth);
+ break;
+ }
- var _now = date.getTime();
+ case 'x': {
+ // ISO week-numbering month
+ // Extension: The F&O spec says nothing about how to access the month associated with the week-of-the-month
+ // e.g. Sat 1 Jan 2005 is in the 5th week of December 2004.
+ // The 'w' component specifier gives 5, but 'W' will give January and 'Y' will give 2005.
+ // I propose to add 'x' as the component specifier to give the 'week-numbering' month (December in this example)
+ var _thisMonth = yearMonth(date.getUTCFullYear(), date.getUTCMonth());
- if (_now < startOfISOMonth) {
- componentValue = _thisMonth.previousMonth().month + 1;
- } else if (_now >= endOfISOMonth) {
- componentValue = nextMonth.month + 1;
- } else {
- componentValue = _thisMonth.month + 1;
- }
+ var startOfISOMonth = startOfFirstWeek(_thisMonth);
- break;
- }
+ var nextMonth = _thisMonth.nextMonth();
- case 'H':
- // hour in day (24 hours)
- componentValue = date.getUTCHours();
- break;
+ var endOfISOMonth = startOfFirstWeek(nextMonth);
- case 'h':
- // hour in half-day (12 hours)
- componentValue = date.getUTCHours();
- componentValue = componentValue % 12;
+ var _now = date.getTime();
- if (componentValue === 0) {
- componentValue = 12;
- }
+ if (_now < startOfISOMonth) {
+ componentValue = _thisMonth.previousMonth().month + 1;
+ } else if (_now >= endOfISOMonth) {
+ componentValue = nextMonth.month + 1;
+ } else {
+ componentValue = _thisMonth.month + 1;
+ }
- break;
+ break;
+ }
- case 'P':
- // am/pm marker
- componentValue = date.getUTCHours() >= 12 ? 'pm' : 'am';
- break;
+ case 'H':
+ // hour in day (24 hours)
+ componentValue = date.getUTCHours();
+ break;
- case 'm':
- // minute in hour
- componentValue = date.getUTCMinutes();
- break;
+ case 'h':
+ // hour in half-day (12 hours)
+ componentValue = date.getUTCHours();
+ componentValue = componentValue % 12;
- case 's':
- // second in minute
- componentValue = date.getUTCSeconds();
- break;
+ if (componentValue === 0) {
+ componentValue = 12;
+ }
- case 'f':
- // fractional seconds
- componentValue = date.getUTCMilliseconds();
- break;
+ break;
- case 'Z': // timezone
+ case 'P':
+ // am/pm marker
+ componentValue = date.getUTCHours() >= 12 ? 'pm' : 'am';
+ break;
- case 'z':
- // since the date object is constructed from epoch millis, the TZ component is always be UTC.
- break;
+ case 'm':
+ // minute in hour
+ componentValue = date.getUTCMinutes();
+ break;
- case 'C':
- // calendar name
- componentValue = 'ISO';
- break;
+ case 's':
+ // second in minute
+ componentValue = date.getUTCSeconds();
+ break;
- case 'E':
- // era
- componentValue = 'ISO';
- break;
- }
+ case 'f':
+ // fractional seconds
+ componentValue = date.getUTCMilliseconds();
+ break;
- return componentValue;
- };
+ case 'Z': // timezone
- var iso8601Spec = analyseDateTimePicture('[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]');
- /**
- * formats the date/time as specified by the XPath fn:format-dateTime function
- * @param {number} millis - the timestamp to be formatted, in millis since the epoch
- * @param {string} picture - the picture string that specifies the format
- * @param {string} timezone - the timezone to use
- * @returns {string} - the formatted timestamp
- */
-
- function formatDateTime(millis, picture, timezone) {
- var offsetHours = 0;
- var offsetMinutes = 0;
-
- if (typeof timezone !== 'undefined') {
- // parse the hour and minute offsets
- // assume for now the format supplied is +hhmm
- var offset = parseInt(timezone);
- offsetHours = Math.floor(offset / 100);
- offsetMinutes = offset % 100;
- }
+ case 'z':
+ // since the date object is constructed from epoch millis, the TZ component is always be UTC.
+ break;
- var formatComponent = function formatComponent(date, markerSpec) {
- var componentValue = getDateTimeFragment(date, markerSpec.component); // §9.8.4.3 Formatting Integer-Valued Date/Time Components
+ case 'C':
+ // calendar name
+ componentValue = 'ISO';
+ break;
- if ('YMDdFWwXxHhms'.indexOf(markerSpec.component) !== -1) {
- if (markerSpec.component === 'Y') {
- // §9.8.4.4 Formatting the Year Component
- if (markerSpec.n !== -1) {
- componentValue = componentValue % Math.pow(10, markerSpec.n);
- }
- }
+ case 'E':
+ // era
+ componentValue = 'ISO';
+ break;
+ }
- if (markerSpec.names) {
- if (markerSpec.component === 'M' || markerSpec.component === 'x') {
- componentValue = months[componentValue - 1];
- } else if (markerSpec.component === 'F') {
- componentValue = days[componentValue];
- } else {
- throw {
- code: 'D3133',
- value: markerSpec.component
+ return componentValue;
};
- }
-
- if (markerSpec.names === tcase.UPPER) {
- componentValue = componentValue.toUpperCase();
- } else if (markerSpec.names === tcase.LOWER) {
- componentValue = componentValue.toLowerCase();
- }
- if (markerSpec.width && componentValue.length > markerSpec.width.max) {
- componentValue = componentValue.substring(0, markerSpec.width.max);
- }
- } else {
- componentValue = _formatInteger(componentValue, markerSpec.integerFormat);
- }
- } else if (markerSpec.component === 'f') {
- // TODO §9.8.4.5 Formatting Fractional Seconds
- componentValue = _formatInteger(componentValue, markerSpec.integerFormat);
- } else if (markerSpec.component === 'Z' || markerSpec.component === 'z') {
- // §9.8.4.6 Formatting timezones
- var _offset = offsetHours * 100 + offsetMinutes;
-
- if (markerSpec.integerFormat.regular) {
- componentValue = _formatInteger(_offset, markerSpec.integerFormat);
- } else {
- var numDigits = markerSpec.integerFormat.mandatoryDigits;
+ var iso8601Spec = analyseDateTimePicture('[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]');
+ /**
+ * formats the date/time as specified by the XPath fn:format-dateTime function
+ * @param {number} millis - the timestamp to be formatted, in millis since the epoch
+ * @param {string} picture - the picture string that specifies the format
+ * @param {string} timezone - the timezone to use
+ * @returns {string} - the formatted timestamp
+ */
+
+ function formatDateTime(millis, picture, timezone) {
+ var offsetHours = 0;
+ var offsetMinutes = 0;
+
+ if (typeof timezone !== 'undefined') {
+ // parse the hour and minute offsets
+ // assume for now the format supplied is +hhmm
+ var offset = parseInt(timezone);
+ offsetHours = Math.floor(offset / 100);
+ offsetMinutes = offset % 100;
+ }
- if (numDigits === 1 || numDigits === 2) {
- componentValue = _formatInteger(offsetHours, markerSpec.integerFormat);
+ var formatComponent = function formatComponent(date, markerSpec) {
+ var componentValue = getDateTimeFragment(date, markerSpec.component); // §9.8.4.3 Formatting Integer-Valued Date/Time Components
- if (offsetMinutes !== 0) {
- componentValue += ':' + formatInteger(offsetMinutes, '00');
- }
- } else if (numDigits === 3 || numDigits === 4) {
- componentValue = _formatInteger(_offset, markerSpec.integerFormat);
- } else {
- throw {
- code: 'D3134',
- value: numDigits
- };
- }
- }
+ if ('YMDdFWwXxHhms'.indexOf(markerSpec.component) !== -1) {
+ if (markerSpec.component === 'Y') {
+ // §9.8.4.4 Formatting the Year Component
+ if (markerSpec.n !== -1) {
+ componentValue = componentValue % Math.pow(10, markerSpec.n);
+ }
+ }
- if (_offset >= 0) {
- componentValue = '+' + componentValue;
- }
+ if (markerSpec.names) {
+ if (markerSpec.component === 'M' || markerSpec.component === 'x') {
+ componentValue = months[componentValue - 1];
+ } else if (markerSpec.component === 'F') {
+ componentValue = days[componentValue];
+ } else {
+ throw {
+ code: 'D3133',
+ value: markerSpec.component,
+ };
+ }
- if (markerSpec.component === 'z') {
- componentValue = 'GMT' + componentValue;
- }
+ if (markerSpec.names === tcase.UPPER) {
+ componentValue = componentValue.toUpperCase();
+ } else if (markerSpec.names === tcase.LOWER) {
+ componentValue = componentValue.toLowerCase();
+ }
- if (_offset === 0 && markerSpec.presentation2 === 't') {
- componentValue = 'Z';
- }
- }
+ if (markerSpec.width && componentValue.length > markerSpec.width.max) {
+ componentValue = componentValue.substring(0, markerSpec.width.max);
+ }
+ } else {
+ componentValue = _formatInteger(componentValue, markerSpec.integerFormat);
+ }
+ } else if (markerSpec.component === 'f') {
+ // TODO §9.8.4.5 Formatting Fractional Seconds
+ componentValue = _formatInteger(componentValue, markerSpec.integerFormat);
+ } else if (markerSpec.component === 'Z' || markerSpec.component === 'z') {
+ // §9.8.4.6 Formatting timezones
+ var _offset = offsetHours * 100 + offsetMinutes;
+
+ if (markerSpec.integerFormat.regular) {
+ componentValue = _formatInteger(_offset, markerSpec.integerFormat);
+ } else {
+ var numDigits = markerSpec.integerFormat.mandatoryDigits;
- return componentValue;
- };
+ if (numDigits === 1 || numDigits === 2) {
+ componentValue = _formatInteger(offsetHours, markerSpec.integerFormat);
- var formatSpec;
+ if (offsetMinutes !== 0) {
+ componentValue += ':' + formatInteger(offsetMinutes, '00');
+ }
+ } else if (numDigits === 3 || numDigits === 4) {
+ componentValue = _formatInteger(_offset, markerSpec.integerFormat);
+ } else {
+ throw {
+ code: 'D3134',
+ value: numDigits,
+ };
+ }
+ }
- if (typeof picture === 'undefined') {
- // default to ISO 8601 format
- formatSpec = iso8601Spec;
- } else {
- formatSpec = analyseDateTimePicture(picture);
- }
+ if (_offset >= 0) {
+ componentValue = '+' + componentValue;
+ }
- var offsetMillis = (60 * offsetHours + offsetMinutes) * 60 * 1000;
- var dateTime = new Date(millis + offsetMillis);
- var result = '';
- formatSpec.parts.forEach(function (part) {
- if (part.type === 'literal') {
- result += part.value;
- } else {
- result += formatComponent(dateTime, part);
- }
- });
- return result;
- }
- /**
- * Generate a regex to parse integers or timestamps
- * @param {object} formatSpec - object representing the format
- * @returns {object} - regex
- */
+ if (markerSpec.component === 'z') {
+ componentValue = 'GMT' + componentValue;
+ }
+ if (_offset === 0 && markerSpec.presentation2 === 't') {
+ componentValue = 'Z';
+ }
+ }
- function generateRegex(formatSpec) {
- var matcher = {};
+ return componentValue;
+ };
- if (formatSpec.type === 'datetime') {
- matcher.type = 'datetime';
- matcher.parts = formatSpec.parts.map(function (part) {
- var res = {};
+ var formatSpec;
- if (part.type === 'literal') {
- res.regex = part.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- } else if (part.integerFormat) {
- res = generateRegex(part.integerFormat);
- } else {
- // must be a month or day name
- res.regex = '[a-zA-Z]+';
- var lookup = {};
-
- if (part.component === 'M' || part.component === 'x') {
- // months
- months.forEach(function (name, index) {
- if (part.width && part.width.max) {
- lookup[name.substring(0, part.width.max)] = index + 1;
+ if (typeof picture === 'undefined') {
+ // default to ISO 8601 format
+ formatSpec = iso8601Spec;
} else {
- lookup[name] = index + 1;
+ formatSpec = analyseDateTimePicture(picture);
}
- });
- } else if (part.component === 'F') {
- // days
- days.forEach(function (name, index) {
- if (index > 0) {
- if (part.width && part.width.max) {
- lookup[name.substring(0, part.width.max)] = index;
+
+ var offsetMillis = (60 * offsetHours + offsetMinutes) * 60 * 1000;
+ var dateTime = new Date(millis + offsetMillis);
+ var result = '';
+ formatSpec.parts.forEach(function (part) {
+ if (part.type === 'literal') {
+ result += part.value;
} else {
- lookup[name] = index;
+ result += formatComponent(dateTime, part);
}
- }
- });
- } else if (part.component === 'P') {
- lookup = {
- 'am': 0,
- 'AM': 0,
- 'pm': 1,
- 'PM': 1
- };
- } else {
- // unsupported 'name' option for this component
- throw {
- code: 'D3133',
- value: part.component
- };
- }
-
- res.parse = function (value) {
- return lookup[value];
- };
- }
-
- res.component = part.component;
- return res;
- });
- } else {
- // type === 'integer'
- matcher.type = 'integer';
- var isUpper = formatSpec["case"] === tcase.UPPER;
-
- switch (formatSpec.primary) {
- case formats.LETTERS:
- matcher.regex = isUpper ? '[A-Z]+' : '[a-z]+';
-
- matcher.parse = function (value) {
- return lettersToDecimal(value, isUpper ? 'A' : 'a');
- };
-
- break;
-
- case formats.ROMAN:
- matcher.regex = isUpper ? '[MDCLXVI]+' : '[mdclxvi]+';
-
- matcher.parse = function (value) {
- return romanToDecimal(isUpper ? value : value.toUpperCase());
- };
-
- break;
-
- case formats.WORDS:
- matcher.regex = '(?:' + Object.keys(wordValues).concat('and', '[\\-, ]').join('|') + ')+';
-
- matcher.parse = function (value) {
- return wordsToNumber(value.toLowerCase());
- };
-
- break;
-
- case formats.DECIMAL:
- matcher.regex = '[0-9]+';
-
- if (formatSpec.ordinal) {
- // ordinals
- matcher.regex += '(?:th|st|nd|rd)';
- }
-
- matcher.parse = function (value) {
- var digits = value;
-
- if (formatSpec.ordinal) {
- // strip off the suffix
- digits = value.substring(0, value.length - 2);
- } // strip out the separators
-
-
- if (formatSpec.regular) {
- digits = digits.split(',').join('');
- } else {
- formatSpec.groupingSeparators.forEach(function (sep) {
- digits = digits.split(sep.character).join('');
});
- }
-
- if (formatSpec.zeroCode !== 0x30) {
- // apply offset
- digits = digits.split('').map(function (_char) {
- return String.fromCodePoint(_char.codePointAt(0) - formatSpec.zeroCode + 0x30);
- }).join('');
- }
-
- return parseInt(digits);
- };
-
- }
- }
-
- return matcher;
- }
- /**
- * parse a string containing an integer as specified by the picture string
- * @param {string} value - the string to parse
- * @param {string} picture - the picture string
- * @returns {number} - the parsed number
- */
-
-
- function parseInteger(value, picture) {
- if (typeof value === 'undefined') {
- return undefined;
- }
-
- var formatSpec = analyseIntegerPicture(picture);
- var matchSpec = generateRegex(formatSpec); //const fullRegex = '^' + matchSpec.regex + '$';
- //const matcher = new RegExp(fullRegex);
- // TODO validate input based on the matcher regex
-
- var result = matchSpec.parse(value);
- return result;
- }
- /**
- * parse a string containing a timestamp as specified by the picture string
- * @param {string} timestamp - the string to parse
- * @param {string} picture - the picture string
- * @returns {number} - the parsed timestamp in millis since the epoch
- */
-
-
- function parseDateTime(timestamp, picture) {
- var formatSpec = analyseDateTimePicture(picture);
- var matchSpec = generateRegex(formatSpec);
- var fullRegex = '^' + matchSpec.parts.map(function (part) {
- return '(' + part.regex + ')';
- }).join('') + '$';
- var matcher = new RegExp(fullRegex, 'i'); // TODO can cache this against the picture
-
- var info = matcher.exec(timestamp);
-
- if (info !== null) {
- // validate what we've just parsed - do we have enough information to create a timestamp?
- // rules:
- // The date is specified by one of:
- // {Y, M, D} (dateA)
- // or {Y, d} (dateB)
- // or {Y, x, w, F} (dateC)
- // or {X, W, F} (dateD)
- // The time is specified by one of:
- // {H, m, s, f} (timeA)
- // or {P, h, m, s, f} (timeB)
- // All sets can have an optional Z
- // To create a timestamp (epoch millis) we need both date and time, but we can default missing
- // information according to the following rules:
- // - line up one combination of the above from date, and one from time, most significant value (MSV) to least significant (LSV
- // - for the values that have been captured, if there are any gaps between MSV and LSV, then throw an error
- // (e.g.) if hour and seconds, but not minutes is given - throw
- // (e.g.) if month, hour and minutes, but not day-of-month is given - throw
- // - anything right of the LSV should be defaulted to zero
- // (e.g.) if hour and minutes given, default seconds and fractional seconds to zero
- // (e.g.) if date only given, default the time to 0:00:00.000 (midnight)
- // - anything left of the MSV should be defaulted to the value of that component returned by $now()
- // (e.g.) if time only given, default the date to today
- // (e.g.) if month and date given, default to this year (and midnight, by previous rule)
- // -- default values for X, x, W, w, F will be derived from the values returned by $now()
- // implement the above rules
- // determine which of the above date/time combinations we have by using bit masks
- // Y X M x W w d D F P H h m s f Z
- // dateA 1 0 1 0 0 0 0 1 ? 0 - must not appear
- // dateB 1 0 0 0 0 0 1 0 ? 1 - can appear - relevant
- // dateC 0 1 0 1 0 1 0 0 1 ? - can appear - ignored
- // dateD 0 1 0 0 1 0 0 0 1
- // timeA 0 1 0 1 1 1
- // timeB 1 0 1 1 1 1
- // create bitmasks based on the above
- // date mask YXMxWwdD
- var dmA = 161; // binary 10100001
-
- var dmB = 130; // binary 10000010
-
- var dmC = 84; // binary 01010100
-
- var dmD = 72; // binary 01001000
- // time mask PHhmsf
-
- var tmA = 23; // binary 010111
-
- var tmB = 47; // binary 101111
-
- var components = {};
-
- for (var i = 1; i < info.length; i++) {
- var mpart = matchSpec.parts[i - 1];
-
- if (mpart.parse) {
- components[mpart.component] = mpart.parse(info[i]);
- }
- }
-
- if (Object.getOwnPropertyNames(components).length === 0) {
- // nothing specified
- return undefined;
- }
-
- var mask = 0;
-
- var shift = function shift(bit) {
- mask <<= 1;
- mask += bit ? 1 : 0;
- };
+ return result;
+ }
+ /**
+ * Generate a regex to parse integers or timestamps
+ * @param {object} formatSpec - object representing the format
+ * @returns {object} - regex
+ */
+
+ function generateRegex(formatSpec) {
+ var matcher = {};
+
+ if (formatSpec.type === 'datetime') {
+ matcher.type = 'datetime';
+ matcher.parts = formatSpec.parts.map(function (part) {
+ var res = {};
+
+ if (part.type === 'literal') {
+ res.regex = part.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ } else if (part.integerFormat) {
+ res = generateRegex(part.integerFormat);
+ } else {
+ // must be a month or day name
+ res.regex = '[a-zA-Z]+';
+ var lookup = {};
+
+ if (part.component === 'M' || part.component === 'x') {
+ // months
+ months.forEach(function (name, index) {
+ if (part.width && part.width.max) {
+ lookup[name.substring(0, part.width.max)] = index + 1;
+ } else {
+ lookup[name] = index + 1;
+ }
+ });
+ } else if (part.component === 'F') {
+ // days
+ days.forEach(function (name, index) {
+ if (index > 0) {
+ if (part.width && part.width.max) {
+ lookup[name.substring(0, part.width.max)] = index;
+ } else {
+ lookup[name] = index;
+ }
+ }
+ });
+ } else if (part.component === 'P') {
+ lookup = {
+ am: 0,
+ AM: 0,
+ pm: 1,
+ PM: 1,
+ };
+ } else {
+ // unsupported 'name' option for this component
+ throw {
+ code: 'D3133',
+ value: part.component,
+ };
+ }
- var isType = function isType(type) {
- // shouldn't match any 0's, must match at least one 1
- return !(~type & mask) && !!(type & mask);
- };
+ res.parse = function (value) {
+ return lookup[value];
+ };
+ }
- 'YXMxWwdD'.split('').forEach(function (part) {
- return shift(components[part]);
- });
- var dateA = isType(dmA);
- var dateB = !dateA && isType(dmB);
- var dateC = isType(dmC);
- var dateD = !dateC && isType(dmD);
- mask = 0;
- 'PHhmsf'.split('').forEach(function (part) {
- return shift(components[part]);
- });
- var timeA = isType(tmA);
- var timeB = !timeA && isType(tmB); // should only be zero or one date type and zero or one time type
-
- var dateComps = dateB ? 'YD' : dateC ? 'XxwF' : dateD ? 'XWF' : 'YMD';
- var timeComps = timeB ? 'Phmsf' : 'Hmsf';
- var comps = dateComps + timeComps; // step through the candidate parts from most significant to least significant
- // default the most significant unspecified parts to current timestamp component
- // default the least significant unspecified parts to zero
- // if any gaps in between the specified parts, throw an error
-
- var now = this.environment.timestamp; // must get the fixed timestamp from jsonata
-
- var startSpecified = false;
- var endSpecified = false;
- comps.split('').forEach(function (part) {
- if (typeof components[part] === 'undefined') {
- if (startSpecified) {
- // past the specified block - default to zero
- components[part] = 'MDd'.indexOf(part) !== -1 ? 1 : 0;
- endSpecified = true;
- } else {
- // haven't hit the specified block yet, default to current timestamp
- components[part] = getDateTimeFragment(now, part);
- }
- } else {
- startSpecified = true;
+ res.component = part.component;
+ return res;
+ });
+ } else {
+ // type === 'integer'
+ matcher.type = 'integer';
+ var isUpper = formatSpec['case'] === tcase.UPPER;
- if (endSpecified) {
- throw {
- code: 'D3136'
- };
- }
- }
- }); // validate and fill in components
+ switch (formatSpec.primary) {
+ case formats.LETTERS:
+ matcher.regex = isUpper ? '[A-Z]+' : '[a-z]+';
- if (components.M > 0) {
- components.M -= 1; // Date.UTC requires a zero-indexed month
- } else {
- components.M = 0; // default to January
- }
+ matcher.parse = function (value) {
+ return lettersToDecimal(value, isUpper ? 'A' : 'a');
+ };
- if (dateB) {
- // millis for given 1st Jan of that year (at 00:00 UTC)
- var firstJan = Date.UTC(components.Y, 0);
- var offsetMillis = (components.d - 1) * 1000 * 60 * 60 * 24;
- var derivedDate = new Date(firstJan + offsetMillis);
- components.M = derivedDate.getMonth();
- components.D = derivedDate.getDate();
- }
+ break;
- if (dateC) {
- // TODO implement this
- // parsing this format not currently supported
- throw {
- code: 'D3136'
- };
- }
+ case formats.ROMAN:
+ matcher.regex = isUpper ? '[MDCLXVI]+' : '[mdclxvi]+';
- if (dateD) {
- // TODO implement this
- // parsing this format (ISO week date) not currently supported
- throw {
- code: 'D3136'
- };
- }
+ matcher.parse = function (value) {
+ return romanToDecimal(isUpper ? value : value.toUpperCase());
+ };
- if (timeB) {
- // 12hr to 24hr
- components.H = components.h === 12 ? 0 : components.h;
+ break;
- if (components.P === 1) {
- components.H += 12;
- }
- }
+ case formats.WORDS:
+ matcher.regex = '(?:' + Object.keys(wordValues).concat('and', '[\\-, ]').join('|') + ')+';
- var millis = Date.UTC(components.Y, components.M, components.D, components.H, components.m, components.s, components.f);
- return millis;
- }
- } // Regular expression to match an ISO 8601 formatted timestamp
-
-
- var iso8601regex = new RegExp('^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$');
- /**
- * Converts an ISO 8601 timestamp to milliseconds since the epoch
- *
- * @param {string} timestamp - the timestamp to be converted
- * @param {string} [picture] - the picture string defining the format of the timestamp (defaults to ISO 8601)
- * @returns {Number} - milliseconds since the epoch
- */
-
- function toMillis(timestamp, picture) {
- // undefined inputs always return undefined
- if (typeof timestamp === 'undefined') {
- return undefined;
- }
+ matcher.parse = function (value) {
+ return wordsToNumber(value.toLowerCase());
+ };
- if (typeof picture === 'undefined') {
- if (!iso8601regex.test(timestamp)) {
- throw {
- stack: new Error().stack,
- code: "D3110",
- value: timestamp
- };
- }
+ break;
- return Date.parse(timestamp);
- } else {
- return parseDateTime.call(this, timestamp, picture);
- }
- }
- /**
- * Converts milliseconds since the epoch to an ISO 8601 timestamp
- * @param {Number} millis - milliseconds since the epoch to be converted
- * @param {string} [picture] - the picture string defining the format of the timestamp (defaults to ISO 8601)
- * @param {string} [timezone] - the timezone to format the timestamp in (defaults to UTC)
- * @returns {String} - the formatted timestamp
- */
-
-
- function fromMillis(millis, picture, timezone) {
- // undefined inputs always return undefined
- if (typeof millis === 'undefined') {
- return undefined;
- }
+ case formats.DECIMAL:
+ matcher.regex = '[0-9]+';
- return formatDateTime.call(this, millis, picture, timezone);
- }
+ if (formatSpec.ordinal) {
+ // ordinals
+ matcher.regex += '(?:th|st|nd|rd)';
+ }
- return {
- formatInteger: formatInteger,
- parseInteger: parseInteger,
- fromMillis: fromMillis,
- toMillis: toMillis
- };
-}();
+ matcher.parse = function (value) {
+ var digits = value;
-module.exports = dateTime;
-},{}],2:[function(require,module,exports){
-(function (global){
-"use strict";
+ if (formatSpec.ordinal) {
+ // strip off the suffix
+ digits = value.substring(0, value.length - 2);
+ } // strip out the separators
-function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
+ if (formatSpec.regular) {
+ digits = digits.split(',').join('');
+ } else {
+ formatSpec.groupingSeparators.forEach(function (sep) {
+ digits = digits.split(sep.character).join('');
+ });
+ }
-function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
+ if (formatSpec.zeroCode !== 0x30) {
+ // apply offset
+ digits = digits
+ .split('')
+ .map(function (_char) {
+ return String.fromCodePoint(_char.codePointAt(0) - formatSpec.zeroCode + 0x30);
+ })
+ .join('');
+ }
-function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
+ return parseInt(digits);
+ };
+ }
+ }
-function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
+ return matcher;
+ }
+ /**
+ * parse a string containing an integer as specified by the picture string
+ * @param {string} value - the string to parse
+ * @param {string} picture - the picture string
+ * @returns {number} - the parsed number
+ */
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+ function parseInteger(value, picture) {
+ if (typeof value === 'undefined') {
+ return undefined;
+ }
-/**
- * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
-var utils = require('./utils');
+ var formatSpec = analyseIntegerPicture(picture);
+ var matchSpec = generateRegex(formatSpec); //const fullRegex = '^' + matchSpec.regex + '$';
+ //const matcher = new RegExp(fullRegex);
+ // TODO validate input based on the matcher regex
+
+ var result = matchSpec.parse(value);
+ return result;
+ }
+ /**
+ * parse a string containing a timestamp as specified by the picture string
+ * @param {string} timestamp - the string to parse
+ * @param {string} picture - the picture string
+ * @returns {number} - the parsed timestamp in millis since the epoch
+ */
+
+ function parseDateTime(timestamp, picture) {
+ var formatSpec = analyseDateTimePicture(picture);
+ var matchSpec = generateRegex(formatSpec);
+ var fullRegex =
+ '^' +
+ matchSpec.parts
+ .map(function (part) {
+ return '(' + part.regex + ')';
+ })
+ .join('') +
+ '$';
+ var matcher = new RegExp(fullRegex, 'i'); // TODO can cache this against the picture
+
+ var info = matcher.exec(timestamp);
+
+ if (info !== null) {
+ // validate what we've just parsed - do we have enough information to create a timestamp?
+ // rules:
+ // The date is specified by one of:
+ // {Y, M, D} (dateA)
+ // or {Y, d} (dateB)
+ // or {Y, x, w, F} (dateC)
+ // or {X, W, F} (dateD)
+ // The time is specified by one of:
+ // {H, m, s, f} (timeA)
+ // or {P, h, m, s, f} (timeB)
+ // All sets can have an optional Z
+ // To create a timestamp (epoch millis) we need both date and time, but we can default missing
+ // information according to the following rules:
+ // - line up one combination of the above from date, and one from time, most significant value (MSV) to least significant (LSV
+ // - for the values that have been captured, if there are any gaps between MSV and LSV, then throw an error
+ // (e.g.) if hour and seconds, but not minutes is given - throw
+ // (e.g.) if month, hour and minutes, but not day-of-month is given - throw
+ // - anything right of the LSV should be defaulted to zero
+ // (e.g.) if hour and minutes given, default seconds and fractional seconds to zero
+ // (e.g.) if date only given, default the time to 0:00:00.000 (midnight)
+ // - anything left of the MSV should be defaulted to the value of that component returned by $now()
+ // (e.g.) if time only given, default the date to today
+ // (e.g.) if month and date given, default to this year (and midnight, by previous rule)
+ // -- default values for X, x, W, w, F will be derived from the values returned by $now()
+ // implement the above rules
+ // determine which of the above date/time combinations we have by using bit masks
+ // Y X M x W w d D F P H h m s f Z
+ // dateA 1 0 1 0 0 0 0 1 ? 0 - must not appear
+ // dateB 1 0 0 0 0 0 1 0 ? 1 - can appear - relevant
+ // dateC 0 1 0 1 0 1 0 0 1 ? - can appear - ignored
+ // dateD 0 1 0 0 1 0 0 0 1
+ // timeA 0 1 0 1 1 1
+ // timeB 1 0 1 1 1 1
+ // create bitmasks based on the above
+ // date mask YXMxWwdD
+ var dmA = 161; // binary 10100001
+
+ var dmB = 130; // binary 10000010
+
+ var dmC = 84; // binary 01010100
+
+ var dmD = 72; // binary 01001000
+ // time mask PHhmsf
+
+ var tmA = 23; // binary 010111
+
+ var tmB = 47; // binary 101111
+
+ var components = {};
+
+ for (var i = 1; i < info.length; i++) {
+ var mpart = matchSpec.parts[i - 1];
+
+ if (mpart.parse) {
+ components[mpart.component] = mpart.parse(info[i]);
+ }
+ }
-var functions = function () {
- 'use strict';
+ if (Object.getOwnPropertyNames(components).length === 0) {
+ // nothing specified
+ return undefined;
+ }
- var _marked =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateMatcher),
- _marked2 =
- /*#__PURE__*/
- regeneratorRuntime.mark(contains),
- _marked3 =
- /*#__PURE__*/
- regeneratorRuntime.mark(match),
- _marked4 =
- /*#__PURE__*/
- regeneratorRuntime.mark(replace),
- _marked5 =
- /*#__PURE__*/
- regeneratorRuntime.mark(split),
- _marked6 =
- /*#__PURE__*/
- regeneratorRuntime.mark(map),
- _marked7 =
- /*#__PURE__*/
- regeneratorRuntime.mark(filter),
- _marked8 =
- /*#__PURE__*/
- regeneratorRuntime.mark(single),
- _marked9 =
- /*#__PURE__*/
- regeneratorRuntime.mark(foldLeft),
- _marked10 =
- /*#__PURE__*/
- regeneratorRuntime.mark(each),
- _marked11 =
- /*#__PURE__*/
- regeneratorRuntime.mark(sort),
- _marked12 =
- /*#__PURE__*/
- regeneratorRuntime.mark(sift);
-
- var isNumeric = utils.isNumeric;
- var isArrayOfStrings = utils.isArrayOfStrings;
- var isArrayOfNumbers = utils.isArrayOfNumbers;
- var createSequence = utils.createSequence;
- var isSequence = utils.isSequence;
- var isFunction = utils.isFunction;
- var isLambda = utils.isLambda;
- var isIterable = utils.isIterable;
- var getFunctionArity = utils.getFunctionArity;
- var deepEquals = utils.isDeepEqual;
- /**
- * Sum function
- * @param {Object} args - Arguments
- * @returns {number} Total value of arguments
- */
-
- function sum(args) {
- // undefined inputs always return undefined
- if (typeof args === 'undefined') {
- return undefined;
- }
+ var mask = 0;
- var total = 0;
- args.forEach(function (num) {
- total += num;
- });
- return total;
- }
- /**
- * Count function
- * @param {Object} args - Arguments
- * @returns {number} Number of elements in the array
- */
+ var shift = function shift(bit) {
+ mask <<= 1;
+ mask += bit ? 1 : 0;
+ };
+ var isType = function isType(type) {
+ // shouldn't match any 0's, must match at least one 1
+ return !(~type & mask) && !!(type & mask);
+ };
- function count(args) {
- // undefined inputs always return undefined
- if (typeof args === 'undefined') {
- return 0;
- }
-
- return args.length;
- }
- /**
- * Max function
- * @param {Object} args - Arguments
- * @returns {number} Max element in the array
- */
-
-
- function max(args) {
- // undefined inputs always return undefined
- if (typeof args === 'undefined' || args.length === 0) {
- return undefined;
- }
-
- return Math.max.apply(Math, args);
- }
- /**
- * Min function
- * @param {Object} args - Arguments
- * @returns {number} Min element in the array
- */
-
-
- function min(args) {
- // undefined inputs always return undefined
- if (typeof args === 'undefined' || args.length === 0) {
- return undefined;
- }
-
- return Math.min.apply(Math, args);
- }
- /**
- * Average function
- * @param {Object} args - Arguments
- * @returns {number} Average element in the array
- */
-
-
- function average(args) {
- // undefined inputs always return undefined
- if (typeof args === 'undefined' || args.length === 0) {
- return undefined;
- }
-
- var total = 0;
- args.forEach(function (num) {
- total += num;
- });
- return total / args.length;
- }
- /**
- * Stringify arguments
- * @param {Object} arg - Arguments
- * @param {boolean} [prettify] - Pretty print the result
- * @returns {String} String from arguments
- */
-
-
- function string(arg) {
- var prettify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
-
- // undefined inputs always return undefined
- if (typeof arg === 'undefined') {
- return undefined;
- }
-
- var str;
-
- if (typeof arg === 'string') {
- // already a string
- str = arg;
- } else if (isFunction(arg)) {
- // functions (built-in and lambda convert to empty string
- str = '';
- } else if (typeof arg === 'number' && !isFinite(arg)) {
- throw {
- code: "D3001",
- value: arg,
- stack: new Error().stack
- };
- } else {
- var space = prettify ? 2 : 0;
- str = JSON.stringify(arg, function (key, val) {
- return typeof val !== 'undefined' && val !== null && val.toPrecision && isNumeric(val) ? Number(val.toPrecision(15)) : val && isFunction(val) ? '' : val;
- }, space);
- }
-
- return str;
- }
- /**
- * Create substring based on character number and length
- * @param {String} str - String to evaluate
- * @param {Integer} start - Character number to start substring
- * @param {Integer} [length] - Number of characters in substring
- * @returns {string|*} Substring
- */
-
-
- function substring(str, start, length) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- var strArray = Array.from(str);
- var strLength = strArray.length;
-
- if (strLength + start < 0) {
- start = 0;
- }
-
- if (typeof length !== 'undefined') {
- if (length <= 0) {
- return '';
- }
-
- var end = start >= 0 ? start + length : strLength + start + length;
- return strArray.slice(start, end).join('');
- }
-
- return strArray.slice(start).join('');
- }
- /**
- * Create substring up until a character
- * @param {String} str - String to evaluate
- * @param {String} chars - Character to define substring boundary
- * @returns {*} Substring
- */
-
-
- function substringBefore(str, chars) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- var pos = str.indexOf(chars);
-
- if (pos > -1) {
- return str.substr(0, pos);
- } else {
- return str;
- }
- }
- /**
- * Create substring after a character
- * @param {String} str - String to evaluate
- * @param {String} chars - Character to define substring boundary
- * @returns {*} Substring
- */
-
-
- function substringAfter(str, chars) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- var pos = str.indexOf(chars);
-
- if (pos > -1) {
- return str.substr(pos + chars.length);
- } else {
- return str;
- }
- }
- /**
- * Lowercase a string
- * @param {String} str - String to evaluate
- * @returns {string} Lowercase string
- */
-
-
- function lowercase(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- return str.toLowerCase();
- }
- /**
- * Uppercase a string
- * @param {String} str - String to evaluate
- * @returns {string} Uppercase string
- */
-
-
- function uppercase(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- return str.toUpperCase();
- }
- /**
- * length of a string
- * @param {String} str - string
- * @returns {Number} The number of characters in the string
- */
-
-
- function length(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- return Array.from(str).length;
- }
- /**
- * Normalize and trim whitespace within a string
- * @param {string} str - string to be trimmed
- * @returns {string} - trimmed string
- */
-
-
- function trim(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // normalize whitespace
-
-
- var result = str.replace(/[ \t\n\r]+/gm, ' ');
-
- if (result.charAt(0) === ' ') {
- // strip leading space
- result = result.substring(1);
- }
-
- if (result.charAt(result.length - 1) === ' ') {
- // strip trailing space
- result = result.substring(0, result.length - 1);
- }
-
- return result;
- }
- /**
- * Pad a string to a minimum width by adding characters to the start or end
- * @param {string} str - string to be padded
- * @param {number} width - the minimum width; +ve pads to the right, -ve pads to the left
- * @param {string} [char] - the pad character(s); defaults to ' '
- * @returns {string} - padded string
- */
-
-
- function pad(str, width, _char) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- }
-
- if (typeof _char === 'undefined' || _char.length === 0) {
- _char = ' ';
- }
-
- var result;
- var padLength = Math.abs(width) - length(str);
-
- if (padLength > 0) {
- var padding = new Array(padLength + 1).join(_char);
-
- if (_char.length > 1) {
- padding = substring(padding, 0, padLength);
- }
-
- if (width > 0) {
- result = str + padding;
- } else {
- result = padding + str;
- }
- } else {
- result = str;
- }
-
- return result;
- }
- /**
- * Evaluate the matcher function against the str arg
- *
- * @param {*} matcher - matching function (native or lambda)
- * @param {string} str - the string to match against
- * @returns {object} - structure that represents the match(es)
- */
-
-
- function evaluateMatcher(matcher, str) {
- var result;
- return regeneratorRuntime.wrap(function evaluateMatcher$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- result = matcher.apply(this, [str]); // eslint-disable-line no-useless-call
-
- if (!isIterable(result)) {
- _context.next = 4;
- break;
- }
-
- return _context.delegateYield(result, "t0", 3);
-
- case 3:
- result = _context.t0;
-
- case 4:
- if (!(result && !(typeof result.start === 'number' || result.end === 'number' || Array.isArray(result.groups) || isFunction(result.next)))) {
- _context.next = 6;
- break;
- }
-
- throw {
- code: "T1010",
- stack: new Error().stack
- };
-
- case 6:
- return _context.abrupt("return", result);
-
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _marked, this);
- }
- /**
- * Tests if the str contains the token
- * @param {String} str - string to test
- * @param {String} token - substring or regex to find
- * @returns {Boolean} - true if str contains token
- */
-
-
- function contains(str, token) {
- var result, matches;
- return regeneratorRuntime.wrap(function contains$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- if (!(typeof str === 'undefined')) {
- _context2.next = 2;
- break;
- }
-
- return _context2.abrupt("return", undefined);
-
- case 2:
- if (!(typeof token === 'string')) {
- _context2.next = 6;
- break;
- }
-
- result = str.indexOf(token) !== -1;
- _context2.next = 9;
- break;
-
- case 6:
- return _context2.delegateYield(evaluateMatcher(token, str), "t0", 7);
-
- case 7:
- matches = _context2.t0;
- result = typeof matches !== 'undefined';
-
- case 9:
- return _context2.abrupt("return", result);
-
- case 10:
- case "end":
- return _context2.stop();
- }
- }
- }, _marked2);
- }
- /**
- * Match a string with a regex returning an array of object containing details of each match
- * @param {String} str - string
- * @param {String} regex - the regex applied to the string
- * @param {Integer} [limit] - max number of matches to return
- * @returns {Array} The array of match objects
- */
-
-
- function match(str, regex, limit) {
- var result, count, matches;
- return regeneratorRuntime.wrap(function match$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (!(typeof str === 'undefined')) {
- _context3.next = 2;
- break;
- }
-
- return _context3.abrupt("return", undefined);
-
- case 2:
- if (!(limit < 0)) {
- _context3.next = 4;
- break;
- }
-
- throw {
- stack: new Error().stack,
- value: limit,
- code: 'D3040',
- index: 3
- };
-
- case 4:
- result = createSequence();
-
- if (!(typeof limit === 'undefined' || limit > 0)) {
- _context3.next = 17;
- break;
- }
-
- count = 0;
- return _context3.delegateYield(evaluateMatcher(regex, str), "t0", 8);
-
- case 8:
- matches = _context3.t0;
-
- if (!(typeof matches !== 'undefined')) {
- _context3.next = 17;
- break;
- }
-
- case 10:
- if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
- _context3.next = 17;
- break;
- }
-
- result.push({
- match: matches.match,
- index: matches.start,
- groups: matches.groups
- });
- return _context3.delegateYield(evaluateMatcher(matches.next), "t1", 13);
-
- case 13:
- matches = _context3.t1;
- count++;
- _context3.next = 10;
- break;
-
- case 17:
- return _context3.abrupt("return", result);
-
- case 18:
- case "end":
- return _context3.stop();
- }
- }
- }, _marked3);
- }
- /**
- * Match a string with a regex returning an array of object containing details of each match
- * @param {String} str - string
- * @param {String} pattern - the substring/regex applied to the string
- * @param {String} replacement - text to replace the matched substrings
- * @param {Integer} [limit] - max number of matches to return
- * @returns {Array} The array of match objects
- */
-
-
- function replace(str, pattern, replacement, limit) {
- var self, replacer, result, position, count, index, matches, replacedWith;
- return regeneratorRuntime.wrap(function replace$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- if (!(typeof str === 'undefined')) {
- _context4.next = 2;
- break;
- }
-
- return _context4.abrupt("return", undefined);
-
- case 2:
- self = this; // pattern cannot be an empty string
-
- if (!(pattern === '')) {
- _context4.next = 5;
- break;
- }
-
- throw {
- code: "D3010",
- stack: new Error().stack,
- value: pattern,
- index: 2
- };
-
- case 5:
- if (!(limit < 0)) {
- _context4.next = 7;
- break;
- }
-
- throw {
- code: "D3011",
- stack: new Error().stack,
- value: limit,
- index: 4
- };
-
- case 7:
- if (typeof replacement === 'string') {
- replacer = function replacer(regexMatch) {
- var substitute = ''; // scan forward, copying the replacement text into the substitute string
- // and replace any occurrence of $n with the values matched by the regex
-
- var position = 0;
- var index = replacement.indexOf('$', position);
-
- while (index !== -1 && position < replacement.length) {
- substitute += replacement.substring(position, index);
- position = index + 1;
- var dollarVal = replacement.charAt(position);
-
- if (dollarVal === '$') {
- // literal $
- substitute += '$';
- position++;
- } else if (dollarVal === '0') {
- substitute += regexMatch.match;
- position++;
- } else {
- var maxDigits;
-
- if (regexMatch.groups.length === 0) {
- // no sub-matches; any $ followed by a digit will be replaced by an empty string
- maxDigits = 1;
- } else {
- // max number of digits to parse following the $
- maxDigits = Math.floor(Math.log(regexMatch.groups.length) * Math.LOG10E) + 1;
- }
-
- index = parseInt(replacement.substring(position, position + maxDigits), 10);
-
- if (maxDigits > 1 && index > regexMatch.groups.length) {
- index = parseInt(replacement.substring(position, position + maxDigits - 1), 10);
- }
-
- if (!isNaN(index)) {
- if (regexMatch.groups.length > 0) {
- var submatch = regexMatch.groups[index - 1];
-
- if (typeof submatch !== 'undefined') {
- substitute += submatch;
- }
- }
-
- position += index.toString().length;
- } else {
- // not a capture group, treat the $ as literal
- substitute += '$';
- }
- }
-
- index = replacement.indexOf('$', position);
- }
-
- substitute += replacement.substring(position);
- return substitute;
- };
- } else {
- replacer = replacement;
- }
-
- result = '';
- position = 0;
-
- if (!(typeof limit === 'undefined' || limit > 0)) {
- _context4.next = 44;
- break;
- }
-
- count = 0;
-
- if (!(typeof pattern === 'string')) {
- _context4.next = 18;
- break;
- }
-
- index = str.indexOf(pattern, position);
-
- while (index !== -1 && (typeof limit === 'undefined' || count < limit)) {
- result += str.substring(position, index);
- result += replacement;
- position = index + pattern.length;
- count++;
- index = str.indexOf(pattern, position);
- }
-
- result += str.substring(position);
- _context4.next = 42;
- break;
-
- case 18:
- return _context4.delegateYield(evaluateMatcher(pattern, str), "t0", 19);
-
- case 19:
- matches = _context4.t0;
-
- if (!(typeof matches !== 'undefined')) {
- _context4.next = 41;
- break;
- }
-
- case 21:
- if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
- _context4.next = 38;
- break;
- }
-
- result += str.substring(position, matches.start);
- replacedWith = replacer.apply(self, [matches]);
-
- if (!isIterable(replacedWith)) {
- _context4.next = 27;
- break;
- }
-
- return _context4.delegateYield(replacedWith, "t1", 26);
-
- case 26:
- replacedWith = _context4.t1;
-
- case 27:
- if (!(typeof replacedWith === 'string')) {
- _context4.next = 31;
- break;
- }
-
- result += replacedWith;
- _context4.next = 32;
- break;
-
- case 31:
- throw {
- code: "D3012",
- stack: new Error().stack,
- value: replacedWith
- };
-
- case 32:
- position = matches.start + matches.match.length;
- count++;
- return _context4.delegateYield(evaluateMatcher(matches.next), "t2", 35);
-
- case 35:
- matches = _context4.t2;
- _context4.next = 21;
- break;
-
- case 38:
- result += str.substring(position);
- _context4.next = 42;
- break;
-
- case 41:
- result = str;
-
- case 42:
- _context4.next = 45;
- break;
-
- case 44:
- result = str;
-
- case 45:
- return _context4.abrupt("return", result);
-
- case 46:
- case "end":
- return _context4.stop();
- }
- }
- }, _marked4, this);
- }
- /**
- * Base64 encode a string
- * @param {String} str - string
- * @returns {String} Base 64 encoding of the binary data
- */
-
-
- function base64encode(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Use btoa in a browser, or Buffer in Node.js
-
-
- var btoa = typeof window !== 'undefined' ?
- /* istanbul ignore next */
- window.btoa : function (str) {
- // Simply doing `new Buffer` at this point causes Browserify to pull
- // in the entire Buffer browser library, which is large and unnecessary.
- // Using `global.Buffer` defeats this.
- return new global.Buffer.from(str, 'binary').toString('base64'); // eslint-disable-line new-cap
- };
- return btoa(str);
- }
- /**
- * Base64 decode a string
- * @param {String} str - string
- * @returns {String} Base 64 encoding of the binary data
- */
-
-
- function base64decode(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Use btoa in a browser, or Buffer in Node.js
-
-
- var atob = typeof window !== 'undefined' ?
- /* istanbul ignore next */
- window.atob : function (str) {
- // Simply doing `new Buffer` at this point causes Browserify to pull
- // in the entire Buffer browser library, which is large and unnecessary.
- // Using `global.Buffer` defeats this.
- return new global.Buffer(str, 'base64').toString('binary');
- };
- return atob(str);
- }
- /**
- * Encode a string into a component for a url
- * @param {String} str - String to encode
- * @returns {string} Encoded string
- */
-
-
- function encodeUrlComponent(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Catch URIErrors when URI sequence is malformed
-
-
- var returnVal;
-
- try {
- returnVal = encodeURIComponent(str);
- } catch (e) {
- throw {
- code: "D3140",
- stack: new Error().stack,
- value: str,
- functionName: "encodeUrlComponent"
- };
- }
-
- return returnVal;
- }
- /**
- * Encode a string into a url
- * @param {String} str - String to encode
- * @returns {string} Encoded string
- */
-
-
- function encodeUrl(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Catch URIErrors when URI sequence is malformed
-
-
- var returnVal;
-
- try {
- returnVal = encodeURI(str);
- } catch (e) {
- throw {
- code: "D3140",
- stack: new Error().stack,
- value: str,
- functionName: "encodeUrl"
- };
- }
-
- return returnVal;
- }
- /**
- * Decode a string from a component for a url
- * @param {String} str - String to decode
- * @returns {string} Decoded string
- */
-
-
- function decodeUrlComponent(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Catch URIErrors when URI sequence is malformed
-
-
- var returnVal;
-
- try {
- returnVal = decodeURIComponent(str);
- } catch (e) {
- throw {
- code: "D3140",
- stack: new Error().stack,
- value: str,
- functionName: "decodeUrlComponent"
- };
- }
-
- return returnVal;
- }
- /**
- * Decode a string from a url
- * @param {String} str - String to decode
- * @returns {string} Decoded string
- */
-
-
- function decodeUrl(str) {
- // undefined inputs always return undefined
- if (typeof str === 'undefined') {
- return undefined;
- } // Catch URIErrors when URI sequence is malformed
-
-
- var returnVal;
-
- try {
- returnVal = decodeURI(str);
- } catch (e) {
- throw {
- code: "D3140",
- stack: new Error().stack,
- value: str,
- functionName: "decodeUrl"
- };
- }
-
- return returnVal;
- }
- /**
- * Split a string into an array of substrings
- * @param {String} str - string
- * @param {String} separator - the token or regex that splits the string
- * @param {Integer} [limit] - max number of substrings
- * @returns {Array} The array of string
- */
-
-
- function split(str, separator, limit) {
- var result, count, matches, start;
- return regeneratorRuntime.wrap(function split$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (!(typeof str === 'undefined')) {
- _context5.next = 2;
- break;
- }
-
- return _context5.abrupt("return", undefined);
-
- case 2:
- if (!(limit < 0)) {
- _context5.next = 4;
- break;
- }
-
- throw {
- code: "D3020",
- stack: new Error().stack,
- value: limit,
- index: 3
- };
-
- case 4:
- result = [];
-
- if (!(typeof limit === 'undefined' || limit > 0)) {
- _context5.next = 27;
- break;
- }
-
- if (!(typeof separator === 'string')) {
- _context5.next = 10;
- break;
- }
-
- result = str.split(separator, limit);
- _context5.next = 27;
- break;
-
- case 10:
- count = 0;
- return _context5.delegateYield(evaluateMatcher(separator, str), "t0", 12);
-
- case 12:
- matches = _context5.t0;
-
- if (!(typeof matches !== 'undefined')) {
- _context5.next = 26;
- break;
- }
-
- start = 0;
-
- case 15:
- if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
- _context5.next = 23;
- break;
- }
-
- result.push(str.substring(start, matches.start));
- start = matches.end;
- return _context5.delegateYield(evaluateMatcher(matches.next), "t1", 19);
-
- case 19:
- matches = _context5.t1;
- count++;
- _context5.next = 15;
- break;
-
- case 23:
- if (typeof limit === 'undefined' || count < limit) {
- result.push(str.substring(start));
- }
-
- _context5.next = 27;
- break;
-
- case 26:
- result.push(str);
-
- case 27:
- return _context5.abrupt("return", result);
-
- case 28:
- case "end":
- return _context5.stop();
- }
- }
- }, _marked5);
- }
- /**
- * Join an array of strings
- * @param {Array} strs - array of string
- * @param {String} [separator] - the token that splits the string
- * @returns {String} The concatenated string
- */
-
-
- function join(strs, separator) {
- // undefined inputs always return undefined
- if (typeof strs === 'undefined') {
- return undefined;
- } // if separator is not specified, default to empty string
-
-
- if (typeof separator === 'undefined') {
- separator = "";
- }
-
- return strs.join(separator);
- }
- /**
- * Formats a number into a decimal string representation using XPath 3.1 F&O fn:format-number spec
- * @param {number} value - number to format
- * @param {String} picture - picture string definition
- * @param {Object} [options] - override locale defaults
- * @returns {String} The formatted string
- */
-
-
- function formatNumber(value, picture, options) {
- // undefined inputs always return undefined
- if (typeof value === 'undefined') {
- return undefined;
- }
-
- var defaults = {
- "decimal-separator": ".",
- "grouping-separator": ",",
- "exponent-separator": "e",
- "infinity": "Infinity",
- "minus-sign": "-",
- "NaN": "NaN",
- "percent": "%",
- "per-mille": "\u2030",
- "zero-digit": "0",
- "digit": "#",
- "pattern-separator": ";"
- }; // if `options` is specified, then its entries override defaults
-
- var properties = defaults;
-
- if (typeof options !== 'undefined') {
- Object.keys(options).forEach(function (key) {
- properties[key] = options[key];
- });
- }
-
- var decimalDigitFamily = [];
- var zeroCharCode = properties['zero-digit'].charCodeAt(0);
-
- for (var ii = zeroCharCode; ii < zeroCharCode + 10; ii++) {
- decimalDigitFamily.push(String.fromCharCode(ii));
- }
-
- var activeChars = decimalDigitFamily.concat([properties['decimal-separator'], properties['exponent-separator'], properties['grouping-separator'], properties.digit, properties['pattern-separator']]);
- var subPictures = picture.split(properties['pattern-separator']);
-
- if (subPictures.length > 2) {
- throw {
- code: 'D3080',
- stack: new Error().stack
- };
- }
-
- var splitParts = function splitParts(subpicture) {
- var prefix = function () {
- var ch;
-
- for (var ii = 0; ii < subpicture.length; ii++) {
- ch = subpicture.charAt(ii);
-
- if (activeChars.indexOf(ch) !== -1 && ch !== properties['exponent-separator']) {
- return subpicture.substring(0, ii);
- }
- }
- }();
-
- var suffix = function () {
- var ch;
-
- for (var ii = subpicture.length - 1; ii >= 0; ii--) {
- ch = subpicture.charAt(ii);
-
- if (activeChars.indexOf(ch) !== -1 && ch !== properties['exponent-separator']) {
- return subpicture.substring(ii + 1);
- }
- }
- }();
-
- var activePart = subpicture.substring(prefix.length, subpicture.length - suffix.length);
- var mantissaPart, exponentPart, integerPart, fractionalPart;
- var exponentPosition = subpicture.indexOf(properties['exponent-separator'], prefix.length);
-
- if (exponentPosition === -1 || exponentPosition > subpicture.length - suffix.length) {
- mantissaPart = activePart;
- exponentPart = undefined;
- } else {
- mantissaPart = activePart.substring(0, exponentPosition);
- exponentPart = activePart.substring(exponentPosition + 1);
- }
-
- var decimalPosition = mantissaPart.indexOf(properties['decimal-separator']);
-
- if (decimalPosition === -1) {
- integerPart = mantissaPart;
- fractionalPart = suffix;
- } else {
- integerPart = mantissaPart.substring(0, decimalPosition);
- fractionalPart = mantissaPart.substring(decimalPosition + 1);
- }
-
- return {
- prefix: prefix,
- suffix: suffix,
- activePart: activePart,
- mantissaPart: mantissaPart,
- exponentPart: exponentPart,
- integerPart: integerPart,
- fractionalPart: fractionalPart,
- subpicture: subpicture
- };
- }; // validate the picture string, F&O 4.7.3
-
-
- var validate = function validate(parts) {
- var error;
- var ii;
- var subpicture = parts.subpicture;
- var decimalPos = subpicture.indexOf(properties['decimal-separator']);
-
- if (decimalPos !== subpicture.lastIndexOf(properties['decimal-separator'])) {
- error = 'D3081';
- }
-
- if (subpicture.indexOf(properties.percent) !== subpicture.lastIndexOf(properties.percent)) {
- error = 'D3082';
- }
-
- if (subpicture.indexOf(properties['per-mille']) !== subpicture.lastIndexOf(properties['per-mille'])) {
- error = 'D3083';
- }
-
- if (subpicture.indexOf(properties.percent) !== -1 && subpicture.indexOf(properties['per-mille']) !== -1) {
- error = 'D3084';
- }
-
- var valid = false;
-
- for (ii = 0; ii < parts.mantissaPart.length; ii++) {
- var ch = parts.mantissaPart.charAt(ii);
-
- if (decimalDigitFamily.indexOf(ch) !== -1 || ch === properties.digit) {
- valid = true;
- break;
- }
- }
-
- if (!valid) {
- error = 'D3085';
- }
-
- var charTypes = parts.activePart.split('').map(function (_char2) {
- return activeChars.indexOf(_char2) === -1 ? 'p' : 'a';
- }).join('');
-
- if (charTypes.indexOf('p') !== -1) {
- error = 'D3086';
- }
-
- if (decimalPos !== -1) {
- if (subpicture.charAt(decimalPos - 1) === properties['grouping-separator'] || subpicture.charAt(decimalPos + 1) === properties['grouping-separator']) {
- error = 'D3087';
- }
- } else if (parts.integerPart.charAt(parts.integerPart.length - 1) === properties['grouping-separator']) {
- error = 'D3088';
- }
-
- if (subpicture.indexOf(properties['grouping-separator'] + properties['grouping-separator']) !== -1) {
- error = 'D3089';
- }
-
- var optionalDigitPos = parts.integerPart.indexOf(properties.digit);
-
- if (optionalDigitPos !== -1 && parts.integerPart.substring(0, optionalDigitPos).split('').filter(function (_char3) {
- return decimalDigitFamily.indexOf(_char3) > -1;
- }).length > 0) {
- error = 'D3090';
- }
-
- optionalDigitPos = parts.fractionalPart.lastIndexOf(properties.digit);
-
- if (optionalDigitPos !== -1 && parts.fractionalPart.substring(optionalDigitPos).split('').filter(function (_char4) {
- return decimalDigitFamily.indexOf(_char4) > -1;
- }).length > 0) {
- error = 'D3091';
- }
-
- var exponentExists = typeof parts.exponentPart === 'string';
-
- if (exponentExists && parts.exponentPart.length > 0 && (subpicture.indexOf(properties.percent) !== -1 || subpicture.indexOf(properties['per-mille']) !== -1)) {
- error = 'D3092';
- }
-
- if (exponentExists && (parts.exponentPart.length === 0 || parts.exponentPart.split('').filter(function (_char5) {
- return decimalDigitFamily.indexOf(_char5) === -1;
- }).length > 0)) {
- error = 'D3093';
- }
-
- if (error) {
- throw {
- code: error,
- stack: new Error().stack
- };
- }
- }; // analyse the picture string, F&O 4.7.4
-
-
- var analyse = function analyse(parts) {
- var getGroupingPositions = function getGroupingPositions(part, toLeft) {
- var positions = [];
- var groupingPosition = part.indexOf(properties['grouping-separator']);
-
- while (groupingPosition !== -1) {
- var charsToTheRight = (toLeft ? part.substring(0, groupingPosition) : part.substring(groupingPosition)).split('').filter(function (_char6) {
- return decimalDigitFamily.indexOf(_char6) !== -1 || _char6 === properties.digit;
- }).length;
- positions.push(charsToTheRight);
- groupingPosition = parts.integerPart.indexOf(properties['grouping-separator'], groupingPosition + 1);
- }
-
- return positions;
- };
-
- var integerPartGroupingPositions = getGroupingPositions(parts.integerPart);
-
- var regular = function regular(indexes) {
- // are the grouping positions regular? i.e. same interval between each of them
- if (indexes.length === 0) {
- return 0;
- }
-
- var gcd = function gcd(a, b) {
- return b === 0 ? a : gcd(b, a % b);
- }; // find the greatest common divisor of all the positions
-
-
- var factor = indexes.reduce(gcd); // is every position separated by this divisor? If so, it's regular
-
- for (var index = 1; index <= indexes.length; index++) {
- if (indexes.indexOf(index * factor) === -1) {
- return 0;
- }
- }
-
- return factor;
- };
-
- var regularGrouping = regular(integerPartGroupingPositions);
- var fractionalPartGroupingPositions = getGroupingPositions(parts.fractionalPart, true);
- var minimumIntegerPartSize = parts.integerPart.split('').filter(function (_char7) {
- return decimalDigitFamily.indexOf(_char7) !== -1;
- }).length;
- var scalingFactor = minimumIntegerPartSize;
- var fractionalPartArray = parts.fractionalPart.split('');
- var minimumFactionalPartSize = fractionalPartArray.filter(function (_char8) {
- return decimalDigitFamily.indexOf(_char8) !== -1;
- }).length;
- var maximumFactionalPartSize = fractionalPartArray.filter(function (_char9) {
- return decimalDigitFamily.indexOf(_char9) !== -1 || _char9 === properties.digit;
- }).length;
- var exponentPresent = typeof parts.exponentPart === 'string';
-
- if (minimumIntegerPartSize === 0 && maximumFactionalPartSize === 0) {
- if (exponentPresent) {
- minimumFactionalPartSize = 1;
- maximumFactionalPartSize = 1;
- } else {
- minimumIntegerPartSize = 1;
- }
- }
-
- if (exponentPresent && minimumIntegerPartSize === 0 && parts.integerPart.indexOf(properties.digit) !== -1) {
- minimumIntegerPartSize = 1;
- }
-
- if (minimumIntegerPartSize === 0 && minimumFactionalPartSize === 0) {
- minimumFactionalPartSize = 1;
- }
-
- var minimumExponentSize = 0;
-
- if (exponentPresent) {
- minimumExponentSize = parts.exponentPart.split('').filter(function (_char10) {
- return decimalDigitFamily.indexOf(_char10) !== -1;
- }).length;
- }
-
- return {
- integerPartGroupingPositions: integerPartGroupingPositions,
- regularGrouping: regularGrouping,
- minimumIntegerPartSize: minimumIntegerPartSize,
- scalingFactor: scalingFactor,
- prefix: parts.prefix,
- fractionalPartGroupingPositions: fractionalPartGroupingPositions,
- minimumFactionalPartSize: minimumFactionalPartSize,
- maximumFactionalPartSize: maximumFactionalPartSize,
- minimumExponentSize: minimumExponentSize,
- suffix: parts.suffix,
- picture: parts.subpicture
- };
- };
-
- var parts = subPictures.map(splitParts);
- parts.forEach(validate);
- var variables = parts.map(analyse);
- var minus_sign = properties['minus-sign'];
- var zero_digit = properties['zero-digit'];
- var decimal_separator = properties['decimal-separator'];
- var grouping_separator = properties['grouping-separator'];
-
- if (variables.length === 1) {
- variables.push(JSON.parse(JSON.stringify(variables[0])));
- variables[1].prefix = minus_sign + variables[1].prefix;
- } // TODO cache the result of the analysis
- // format the number
- // bullet 1: TODO: NaN - not sure we'd ever get this in JSON
-
-
- var pic; // bullet 2:
-
- if (value >= 0) {
- pic = variables[0];
- } else {
- pic = variables[1];
- }
-
- var adjustedNumber; // bullet 3:
-
- if (pic.picture.indexOf(properties.percent) !== -1) {
- adjustedNumber = value * 100;
- } else if (pic.picture.indexOf(properties['per-mille']) !== -1) {
- adjustedNumber = value * 1000;
- } else {
- adjustedNumber = value;
- } // bullet 4:
- // TODO: infinity - not sure we'd ever get this in JSON
- // bullet 5:
-
-
- var mantissa, exponent;
-
- if (pic.minimumExponentSize === 0) {
- mantissa = adjustedNumber;
- } else {
- // mantissa * 10^exponent = adjustedNumber
- var maxMantissa = Math.pow(10, pic.scalingFactor);
- var minMantissa = Math.pow(10, pic.scalingFactor - 1);
- mantissa = adjustedNumber;
- exponent = 0;
-
- while (mantissa < minMantissa) {
- mantissa *= 10;
- exponent -= 1;
- }
-
- while (mantissa > maxMantissa) {
- mantissa /= 10;
- exponent += 1;
- }
- } // bullet 6:
-
-
- var roundedNumber = round(mantissa, pic.maximumFactionalPartSize); // bullet 7:
-
- var makeString = function makeString(value, dp) {
- var str = Math.abs(value).toFixed(dp);
-
- if (zero_digit !== '0') {
- str = str.split('').map(function (digit) {
- if (digit >= '0' && digit <= '9') {
- return decimalDigitFamily[digit.charCodeAt(0) - 48];
- } else {
- return digit;
- }
- }).join('');
- }
-
- return str;
- };
-
- var stringValue = makeString(roundedNumber, pic.maximumFactionalPartSize);
- var decimalPos = stringValue.indexOf('.');
-
- if (decimalPos === -1) {
- stringValue = stringValue + decimal_separator;
- } else {
- stringValue = stringValue.replace('.', decimal_separator);
- }
-
- while (stringValue.charAt(0) === zero_digit) {
- stringValue = stringValue.substring(1);
- }
-
- while (stringValue.charAt(stringValue.length - 1) === zero_digit) {
- stringValue = stringValue.substring(0, stringValue.length - 1);
- } // bullets 8 & 9:
-
-
- decimalPos = stringValue.indexOf(decimal_separator);
- var padLeft = pic.minimumIntegerPartSize - decimalPos;
- var padRight = pic.minimumFactionalPartSize - (stringValue.length - decimalPos - 1);
- stringValue = (padLeft > 0 ? new Array(padLeft + 1).join(zero_digit) : '') + stringValue;
- stringValue = stringValue + (padRight > 0 ? new Array(padRight + 1).join(zero_digit) : '');
- decimalPos = stringValue.indexOf(decimal_separator); // bullet 10:
-
- if (pic.regularGrouping > 0) {
- var groupCount = Math.floor((decimalPos - 1) / pic.regularGrouping);
-
- for (var group = 1; group <= groupCount; group++) {
- stringValue = [stringValue.slice(0, decimalPos - group * pic.regularGrouping), grouping_separator, stringValue.slice(decimalPos - group * pic.regularGrouping)].join('');
- }
- } else {
- pic.integerPartGroupingPositions.forEach(function (pos) {
- stringValue = [stringValue.slice(0, decimalPos - pos), grouping_separator, stringValue.slice(decimalPos - pos)].join('');
- decimalPos++;
- });
- } // bullet 11:
-
-
- decimalPos = stringValue.indexOf(decimal_separator);
- pic.fractionalPartGroupingPositions.forEach(function (pos) {
- stringValue = [stringValue.slice(0, pos + decimalPos + 1), grouping_separator, stringValue.slice(pos + decimalPos + 1)].join('');
- }); // bullet 12:
-
- decimalPos = stringValue.indexOf(decimal_separator);
-
- if (pic.picture.indexOf(decimal_separator) === -1 || decimalPos === stringValue.length - 1) {
- stringValue = stringValue.substring(0, stringValue.length - 1);
- } // bullet 13:
-
-
- if (typeof exponent !== 'undefined') {
- var stringExponent = makeString(exponent, 0);
- padLeft = pic.minimumExponentSize - stringExponent.length;
-
- if (padLeft > 0) {
- stringExponent = new Array(padLeft + 1).join(zero_digit) + stringExponent;
- }
-
- stringValue = stringValue + properties['exponent-separator'] + (exponent < 0 ? minus_sign : '') + stringExponent;
- } // bullet 14:
-
-
- stringValue = pic.prefix + stringValue + pic.suffix;
- return stringValue;
- }
- /**
- * Converts a number to a string using a specified number base
- * @param {number} value - the number to convert
- * @param {number} [radix] - the number base; must be between 2 and 36. Defaults to 10
- * @returns {string} - the converted string
- */
-
-
- function formatBase(value, radix) {
- // undefined inputs always return undefined
- if (typeof value === 'undefined') {
- return undefined;
- }
-
- value = round(value);
-
- if (typeof radix === 'undefined') {
- radix = 10;
- } else {
- radix = round(radix);
- }
-
- if (radix < 2 || radix > 36) {
- throw {
- code: 'D3100',
- stack: new Error().stack,
- value: radix
- };
- }
-
- var result = value.toString(radix);
- return result;
- }
- /**
- * Cast argument to number
- * @param {Object} arg - Argument
- * @returns {Number} numeric value of argument
- */
-
+ 'YXMxWwdD'.split('').forEach(function (part) {
+ return shift(components[part]);
+ });
+ var dateA = isType(dmA);
+ var dateB = !dateA && isType(dmB);
+ var dateC = isType(dmC);
+ var dateD = !dateC && isType(dmD);
+ mask = 0;
+ 'PHhmsf'.split('').forEach(function (part) {
+ return shift(components[part]);
+ });
+ var timeA = isType(tmA);
+ var timeB = !timeA && isType(tmB); // should only be zero or one date type and zero or one time type
+
+ var dateComps = dateB ? 'YD' : dateC ? 'XxwF' : dateD ? 'XWF' : 'YMD';
+ var timeComps = timeB ? 'Phmsf' : 'Hmsf';
+ var comps = dateComps + timeComps; // step through the candidate parts from most significant to least significant
+ // default the most significant unspecified parts to current timestamp component
+ // default the least significant unspecified parts to zero
+ // if any gaps in between the specified parts, throw an error
+
+ var now = this.environment.timestamp; // must get the fixed timestamp from jsonata
+
+ var startSpecified = false;
+ var endSpecified = false;
+ comps.split('').forEach(function (part) {
+ if (typeof components[part] === 'undefined') {
+ if (startSpecified) {
+ // past the specified block - default to zero
+ components[part] = 'MDd'.indexOf(part) !== -1 ? 1 : 0;
+ endSpecified = true;
+ } else {
+ // haven't hit the specified block yet, default to current timestamp
+ components[part] = getDateTimeFragment(now, part);
+ }
+ } else {
+ startSpecified = true;
- function number(arg) {
- var result; // undefined inputs always return undefined
+ if (endSpecified) {
+ throw {
+ code: 'D3136',
+ };
+ }
+ }
+ }); // validate and fill in components
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ if (components.M > 0) {
+ components.M -= 1; // Date.UTC requires a zero-indexed month
+ } else {
+ components.M = 0; // default to January
+ }
- if (typeof arg === 'number') {
- // already a number
- result = arg;
- } else if (typeof arg === 'string' && /^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(arg) && !isNaN(parseFloat(arg)) && isFinite(arg)) {
- result = parseFloat(arg);
- } else if (arg === true) {
- // boolean true casts to 1
- result = 1;
- } else if (arg === false) {
- // boolean false casts to 0
- result = 0;
- } else {
- throw {
- code: "D3030",
- value: arg,
- stack: new Error().stack,
- index: 1
- };
- }
+ if (dateB) {
+ // millis for given 1st Jan of that year (at 00:00 UTC)
+ var firstJan = Date.UTC(components.Y, 0);
+ var offsetMillis = (components.d - 1) * 1000 * 60 * 60 * 24;
+ var derivedDate = new Date(firstJan + offsetMillis);
+ components.M = derivedDate.getMonth();
+ components.D = derivedDate.getDate();
+ }
- return result;
- }
- /**
- * Absolute value of a number
- * @param {Number} arg - Argument
- * @returns {Number} absolute value of argument
- */
+ if (dateC) {
+ // TODO implement this
+ // parsing this format not currently supported
+ throw {
+ code: 'D3136',
+ };
+ }
+ if (dateD) {
+ // TODO implement this
+ // parsing this format (ISO week date) not currently supported
+ throw {
+ code: 'D3136',
+ };
+ }
- function abs(arg) {
- var result; // undefined inputs always return undefined
+ if (timeB) {
+ // 12hr to 24hr
+ components.H = components.h === 12 ? 0 : components.h;
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ if (components.P === 1) {
+ components.H += 12;
+ }
+ }
- result = Math.abs(arg);
- return result;
- }
- /**
- * Rounds a number down to integer
- * @param {Number} arg - Argument
- * @returns {Number} rounded integer
- */
+ var millis = Date.UTC(
+ components.Y,
+ components.M,
+ components.D,
+ components.H,
+ components.m,
+ components.s,
+ components.f
+ );
+ return millis;
+ }
+ } // Regular expression to match an ISO 8601 formatted timestamp
+
+ var iso8601regex = new RegExp(
+ '^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$'
+ );
+ /**
+ * Converts an ISO 8601 timestamp to milliseconds since the epoch
+ *
+ * @param {string} timestamp - the timestamp to be converted
+ * @param {string} [picture] - the picture string defining the format of the timestamp (defaults to ISO 8601)
+ * @returns {Number} - milliseconds since the epoch
+ */
+
+ function toMillis(timestamp, picture) {
+ // undefined inputs always return undefined
+ if (typeof timestamp === 'undefined') {
+ return undefined;
+ }
+ if (typeof picture === 'undefined') {
+ if (!iso8601regex.test(timestamp)) {
+ throw {
+ stack: new Error().stack,
+ code: 'D3110',
+ value: timestamp,
+ };
+ }
- function floor(arg) {
- var result; // undefined inputs always return undefined
+ return Date.parse(timestamp);
+ } else {
+ return parseDateTime.call(this, timestamp, picture);
+ }
+ }
+ /**
+ * Converts milliseconds since the epoch to an ISO 8601 timestamp
+ * @param {Number} millis - milliseconds since the epoch to be converted
+ * @param {string} [picture] - the picture string defining the format of the timestamp (defaults to ISO 8601)
+ * @param {string} [timezone] - the timezone to format the timestamp in (defaults to UTC)
+ * @returns {String} - the formatted timestamp
+ */
+
+ function fromMillis(millis, picture, timezone) {
+ // undefined inputs always return undefined
+ if (typeof millis === 'undefined') {
+ return undefined;
+ }
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ return formatDateTime.call(this, millis, picture, timezone);
+ }
- result = Math.floor(arg);
- return result;
- }
- /**
- * Rounds a number up to integer
- * @param {Number} arg - Argument
- * @returns {Number} rounded integer
- */
+ return {
+ formatInteger: formatInteger,
+ parseInteger: parseInteger,
+ fromMillis: fromMillis,
+ toMillis: toMillis,
+ };
+ })();
+ module.exports = dateTime;
+ },
+ {},
+ ],
+ 2: [
+ function (require, module, exports) {
+ (function (global) {
+ 'use strict';
- function ceil(arg) {
- var result; // undefined inputs always return undefined
+ function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
+ }
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ function _nonIterableSpread() {
+ throw new TypeError('Invalid attempt to spread non-iterable instance');
+ }
- result = Math.ceil(arg);
- return result;
- }
- /**
- * Round to half even
- * @param {Number} arg - Argument
- * @param {Number} [precision] - number of decimal places
- * @returns {Number} rounded integer
- */
+ function _iterableToArray(iter) {
+ if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === '[object Arguments]')
+ return Array.from(iter);
+ }
+ function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) {
+ for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
+ arr2[i] = arr[i];
+ }
+ return arr2;
+ }
+ }
- function round(arg, precision) {
- var result; // undefined inputs always return undefined
+ function _typeof(obj) {
+ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
+ _typeof = function _typeof(obj) {
+ return typeof obj;
+ };
+ } else {
+ _typeof = function _typeof(obj) {
+ return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
+ ? 'symbol'
+ : typeof obj;
+ };
+ }
+ return _typeof(obj);
+ }
+
+ /**
+ * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
+ * Project name: JSONata
+ * This project is licensed under the MIT License, see LICENSE
+ */
+ var utils = require('./utils');
+
+ var functions = (function () {
+ 'use strict';
+
+ var _marked =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateMatcher),
+ _marked2 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(contains),
+ _marked3 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(match),
+ _marked4 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(replace),
+ _marked5 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(split),
+ _marked6 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(map),
+ _marked7 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(filter),
+ _marked8 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(single),
+ _marked9 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(foldLeft),
+ _marked10 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(each),
+ _marked11 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(sort),
+ _marked12 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(sift);
+
+ var isNumeric = utils.isNumeric;
+ var isArrayOfStrings = utils.isArrayOfStrings;
+ var isArrayOfNumbers = utils.isArrayOfNumbers;
+ var createSequence = utils.createSequence;
+ var isSequence = utils.isSequence;
+ var isFunction = utils.isFunction;
+ var isLambda = utils.isLambda;
+ var isIterable = utils.isIterable;
+ var getFunctionArity = utils.getFunctionArity;
+ var deepEquals = utils.isDeepEqual;
+ /**
+ * Sum function
+ * @param {Object} args - Arguments
+ * @returns {number} Total value of arguments
+ */
+
+ function sum(args) {
+ // undefined inputs always return undefined
+ if (typeof args === 'undefined') {
+ return undefined;
+ }
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ var total = 0;
+ args.forEach(function (num) {
+ total += num;
+ });
+ return total;
+ }
+ /**
+ * Count function
+ * @param {Object} args - Arguments
+ * @returns {number} Number of elements in the array
+ */
+
+ function count(args) {
+ // undefined inputs always return undefined
+ if (typeof args === 'undefined') {
+ return 0;
+ }
- if (precision) {
- // shift the decimal place - this needs to be done in a string since multiplying
- // by a power of ten can introduce floating point precision errors which mess up
- // this rounding algorithm - See 'Decimal rounding' in
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
- // Shift
- var value = arg.toString().split('e');
- arg = +(value[0] + 'e' + (value[1] ? +value[1] + precision : precision));
- } // round up to nearest int
+ return args.length;
+ }
+ /**
+ * Max function
+ * @param {Object} args - Arguments
+ * @returns {number} Max element in the array
+ */
+
+ function max(args) {
+ // undefined inputs always return undefined
+ if (typeof args === 'undefined' || args.length === 0) {
+ return undefined;
+ }
+ return Math.max.apply(Math, args);
+ }
+ /**
+ * Min function
+ * @param {Object} args - Arguments
+ * @returns {number} Min element in the array
+ */
+
+ function min(args) {
+ // undefined inputs always return undefined
+ if (typeof args === 'undefined' || args.length === 0) {
+ return undefined;
+ }
- result = Math.round(arg);
- var diff = result - arg;
+ return Math.min.apply(Math, args);
+ }
+ /**
+ * Average function
+ * @param {Object} args - Arguments
+ * @returns {number} Average element in the array
+ */
+
+ function average(args) {
+ // undefined inputs always return undefined
+ if (typeof args === 'undefined' || args.length === 0) {
+ return undefined;
+ }
- if (Math.abs(diff) === 0.5 && Math.abs(result % 2) === 1) {
- // rounded the wrong way - adjust to nearest even number
- result = result - 1;
- }
+ var total = 0;
+ args.forEach(function (num) {
+ total += num;
+ });
+ return total / args.length;
+ }
+ /**
+ * Stringify arguments
+ * @param {Object} arg - Arguments
+ * @param {boolean} [prettify] - Pretty print the result
+ * @returns {String} String from arguments
+ */
+
+ function string(arg) {
+ var prettify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+
+ // undefined inputs always return undefined
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- if (precision) {
- // Shift back
- value = result.toString().split('e');
- /* istanbul ignore next */
+ var str;
- result = +(value[0] + 'e' + (value[1] ? +value[1] - precision : -precision));
- }
+ if (typeof arg === 'string') {
+ // already a string
+ str = arg;
+ } else if (isFunction(arg)) {
+ // functions (built-in and lambda convert to empty string
+ str = '';
+ } else if (typeof arg === 'number' && !isFinite(arg)) {
+ throw {
+ code: 'D3001',
+ value: arg,
+ stack: new Error().stack,
+ };
+ } else {
+ var space = prettify ? 2 : 0;
+ str = JSON.stringify(
+ arg,
+ function (key, val) {
+ return typeof val !== 'undefined' && val !== null && val.toPrecision && isNumeric(val)
+ ? Number(val.toPrecision(15))
+ : val && isFunction(val)
+ ? ''
+ : val;
+ },
+ space
+ );
+ }
- if (Object.is(result, -0)) {
- // ESLint rule 'no-compare-neg-zero' suggests this way
- // JSON doesn't do -0
- result = 0;
- }
+ return str;
+ }
+ /**
+ * Create substring based on character number and length
+ * @param {String} str - String to evaluate
+ * @param {Integer} start - Character number to start substring
+ * @param {Integer} [length] - Number of characters in substring
+ * @returns {string|*} Substring
+ */
+
+ function substring(str, start, length) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- return result;
- }
- /**
- * Square root of number
- * @param {Number} arg - Argument
- * @returns {Number} square root
- */
+ var strArray = Array.from(str);
+ var strLength = strArray.length;
+ if (strLength + start < 0) {
+ start = 0;
+ }
- function sqrt(arg) {
- var result; // undefined inputs always return undefined
+ if (typeof length !== 'undefined') {
+ if (length <= 0) {
+ return '';
+ }
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ var end = start >= 0 ? start + length : strLength + start + length;
+ return strArray.slice(start, end).join('');
+ }
- if (arg < 0) {
- throw {
- stack: new Error().stack,
- code: "D3060",
- index: 1,
- value: arg
- };
- }
+ return strArray.slice(start).join('');
+ }
+ /**
+ * Create substring up until a character
+ * @param {String} str - String to evaluate
+ * @param {String} chars - Character to define substring boundary
+ * @returns {*} Substring
+ */
+
+ function substringBefore(str, chars) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- result = Math.sqrt(arg);
- return result;
- }
- /**
- * Raises number to the power of the second number
- * @param {Number} arg - the base
- * @param {Number} exp - the exponent
- * @returns {Number} rounded integer
- */
+ var pos = str.indexOf(chars);
+ if (pos > -1) {
+ return str.substr(0, pos);
+ } else {
+ return str;
+ }
+ }
+ /**
+ * Create substring after a character
+ * @param {String} str - String to evaluate
+ * @param {String} chars - Character to define substring boundary
+ * @returns {*} Substring
+ */
+
+ function substringAfter(str, chars) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- function power(arg, exp) {
- var result; // undefined inputs always return undefined
+ var pos = str.indexOf(chars);
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ if (pos > -1) {
+ return str.substr(pos + chars.length);
+ } else {
+ return str;
+ }
+ }
+ /**
+ * Lowercase a string
+ * @param {String} str - String to evaluate
+ * @returns {string} Lowercase string
+ */
+
+ function lowercase(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- result = Math.pow(arg, exp);
+ return str.toLowerCase();
+ }
+ /**
+ * Uppercase a string
+ * @param {String} str - String to evaluate
+ * @returns {string} Uppercase string
+ */
+
+ function uppercase(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- if (!isFinite(result)) {
- throw {
- stack: new Error().stack,
- code: "D3061",
- index: 1,
- value: arg,
- exp: exp
- };
- }
+ return str.toUpperCase();
+ }
+ /**
+ * length of a string
+ * @param {String} str - string
+ * @returns {Number} The number of characters in the string
+ */
+
+ function length(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- return result;
- }
- /**
- * Returns a random number 0 <= n < 1
- * @returns {number} random number
- */
+ return Array.from(str).length;
+ }
+ /**
+ * Normalize and trim whitespace within a string
+ * @param {string} str - string to be trimmed
+ * @returns {string} - trimmed string
+ */
+
+ function trim(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // normalize whitespace
+
+ var result = str.replace(/[ \t\n\r]+/gm, ' ');
+
+ if (result.charAt(0) === ' ') {
+ // strip leading space
+ result = result.substring(1);
+ }
+ if (result.charAt(result.length - 1) === ' ') {
+ // strip trailing space
+ result = result.substring(0, result.length - 1);
+ }
- function random() {
- return Math.random();
- }
- /**
- * Evaluate an input and return a boolean
- * @param {*} arg - Arguments
- * @returns {boolean} Boolean
- */
-
-
- function _boolean(arg) {
- // cast arg to its effective boolean value
- // boolean: unchanged
- // string: zero-length -> false; otherwise -> true
- // number: 0 -> false; otherwise -> true
- // null -> false
- // array: empty -> false; length > 1 -> true
- // object: empty -> false; non-empty -> true
- // function -> false
- // undefined inputs always return undefined
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ return result;
+ }
+ /**
+ * Pad a string to a minimum width by adding characters to the start or end
+ * @param {string} str - string to be padded
+ * @param {number} width - the minimum width; +ve pads to the right, -ve pads to the left
+ * @param {string} [char] - the pad character(s); defaults to ' '
+ * @returns {string} - padded string
+ */
+
+ function pad(str, width, _char) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ }
- var result = false;
+ if (typeof _char === 'undefined' || _char.length === 0) {
+ _char = ' ';
+ }
- if (Array.isArray(arg)) {
- if (arg.length === 1) {
- result = _boolean(arg[0]);
- } else if (arg.length > 1) {
- var trues = arg.filter(function (val) {
- return _boolean(val);
- });
- result = trues.length > 0;
- }
- } else if (typeof arg === 'string') {
- if (arg.length > 0) {
- result = true;
- }
- } else if (isNumeric(arg)) {
- if (arg !== 0) {
- result = true;
- }
- } else if (arg !== null && _typeof(arg) === 'object') {
- if (Object.keys(arg).length > 0) {
- result = true;
- }
- } else if (typeof arg === 'boolean' && arg === true) {
- result = true;
- }
+ var result;
+ var padLength = Math.abs(width) - length(str);
- return result;
- }
- /**
- * returns the Boolean NOT of the arg
- * @param {*} arg - argument
- * @returns {boolean} - NOT arg
- */
+ if (padLength > 0) {
+ var padding = new Array(padLength + 1).join(_char);
+ if (_char.length > 1) {
+ padding = substring(padding, 0, padLength);
+ }
- function not(arg) {
- return !_boolean(arg);
- }
- /**
- * Helper function to build the arguments to be supplied to the function arg of the
- * HOFs map, filter, each, sift and single
- * @param {function} func - the function to be invoked
- * @param {*} arg1 - the first (required) arg - the value
- * @param {*} arg2 - the second (optional) arg - the position (index or key)
- * @param {*} arg3 - the third (optional) arg - the whole structure (array or object)
- * @returns {*[]} the argument list
- */
+ if (width > 0) {
+ result = str + padding;
+ } else {
+ result = padding + str;
+ }
+ } else {
+ result = str;
+ }
+ return result;
+ }
+ /**
+ * Evaluate the matcher function against the str arg
+ *
+ * @param {*} matcher - matching function (native or lambda)
+ * @param {string} str - the string to match against
+ * @returns {object} - structure that represents the match(es)
+ */
+
+ function evaluateMatcher(matcher, str) {
+ var result;
+ return regeneratorRuntime.wrap(
+ function evaluateMatcher$(_context) {
+ while (1) {
+ switch ((_context.prev = _context.next)) {
+ case 0:
+ result = matcher.apply(this, [str]); // eslint-disable-line no-useless-call
+
+ if (!isIterable(result)) {
+ _context.next = 4;
+ break;
+ }
- function hofFuncArgs(func, arg1, arg2, arg3) {
- var func_args = [arg1]; // the first arg (the value) is required
- // the other two are optional - only supply it if the function can take it
+ return _context.delegateYield(result, 't0', 3);
+
+ case 3:
+ result = _context.t0;
+
+ case 4:
+ if (
+ !(
+ result &&
+ !(
+ typeof result.start === 'number' ||
+ result.end === 'number' ||
+ Array.isArray(result.groups) ||
+ isFunction(result.next)
+ )
+ )
+ ) {
+ _context.next = 6;
+ break;
+ }
- var length = getFunctionArity(func);
+ throw {
+ code: 'T1010',
+ stack: new Error().stack,
+ };
- if (length >= 2) {
- func_args.push(arg2);
- }
+ case 6:
+ return _context.abrupt('return', result);
- if (length >= 3) {
- func_args.push(arg3);
- }
+ case 7:
+ case 'end':
+ return _context.stop();
+ }
+ }
+ },
+ _marked,
+ this
+ );
+ }
+ /**
+ * Tests if the str contains the token
+ * @param {String} str - string to test
+ * @param {String} token - substring or regex to find
+ * @returns {Boolean} - true if str contains token
+ */
+
+ function contains(str, token) {
+ var result, matches;
+ return regeneratorRuntime.wrap(function contains$(_context2) {
+ while (1) {
+ switch ((_context2.prev = _context2.next)) {
+ case 0:
+ if (!(typeof str === 'undefined')) {
+ _context2.next = 2;
+ break;
+ }
- return func_args;
- }
- /**
- * Create a map from an array of arguments
- * @param {Array} [arr] - array to map over
- * @param {Function} func - function to apply
- * @returns {Array} Map array
- */
-
-
- function map(arr, func) {
- var result, i, func_args, res;
- return regeneratorRuntime.wrap(function map$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- if (!(typeof arr === 'undefined')) {
- _context6.next = 2;
- break;
- }
+ return _context2.abrupt('return', undefined);
- return _context6.abrupt("return", undefined);
+ case 2:
+ if (!(typeof token === 'string')) {
+ _context2.next = 6;
+ break;
+ }
- case 2:
- result = createSequence(); // do the map - iterate over the arrays, and invoke func
+ result = str.indexOf(token) !== -1;
+ _context2.next = 9;
+ break;
- i = 0;
+ case 6:
+ return _context2.delegateYield(evaluateMatcher(token, str), 't0', 7);
- case 4:
- if (!(i < arr.length)) {
- _context6.next = 12;
- break;
- }
+ case 7:
+ matches = _context2.t0;
+ result = typeof matches !== 'undefined';
- func_args = hofFuncArgs(func, arr[i], i, arr); // invoke func
+ case 9:
+ return _context2.abrupt('return', result);
- return _context6.delegateYield(func.apply(this, func_args), "t0", 7);
+ case 10:
+ case 'end':
+ return _context2.stop();
+ }
+ }
+ }, _marked2);
+ }
+ /**
+ * Match a string with a regex returning an array of object containing details of each match
+ * @param {String} str - string
+ * @param {String} regex - the regex applied to the string
+ * @param {Integer} [limit] - max number of matches to return
+ * @returns {Array} The array of match objects
+ */
+
+ function match(str, regex, limit) {
+ var result, count, matches;
+ return regeneratorRuntime.wrap(function match$(_context3) {
+ while (1) {
+ switch ((_context3.prev = _context3.next)) {
+ case 0:
+ if (!(typeof str === 'undefined')) {
+ _context3.next = 2;
+ break;
+ }
- case 7:
- res = _context6.t0;
+ return _context3.abrupt('return', undefined);
- if (typeof res !== 'undefined') {
- result.push(res);
- }
+ case 2:
+ if (!(limit < 0)) {
+ _context3.next = 4;
+ break;
+ }
- case 9:
- i++;
- _context6.next = 4;
- break;
+ throw {
+ stack: new Error().stack,
+ value: limit,
+ code: 'D3040',
+ index: 3,
+ };
- case 12:
- return _context6.abrupt("return", result);
+ case 4:
+ result = createSequence();
- case 13:
- case "end":
- return _context6.stop();
- }
- }
- }, _marked6, this);
- }
- /**
- * Create a map from an array of arguments
- * @param {Array} [arr] - array to filter
- * @param {Function} func - predicate function
- * @returns {Array} Map array
- */
-
-
- function filter(arr, func) {
- var result, i, entry, func_args, res;
- return regeneratorRuntime.wrap(function filter$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- if (!(typeof arr === 'undefined')) {
- _context7.next = 2;
- break;
- }
+ if (!(typeof limit === 'undefined' || limit > 0)) {
+ _context3.next = 17;
+ break;
+ }
- return _context7.abrupt("return", undefined);
+ count = 0;
+ return _context3.delegateYield(evaluateMatcher(regex, str), 't0', 8);
- case 2:
- result = createSequence();
- i = 0;
+ case 8:
+ matches = _context3.t0;
- case 4:
- if (!(i < arr.length)) {
- _context7.next = 13;
- break;
- }
+ if (!(typeof matches !== 'undefined')) {
+ _context3.next = 17;
+ break;
+ }
- entry = arr[i];
- func_args = hofFuncArgs(func, entry, i, arr); // invoke func
+ case 10:
+ if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
+ _context3.next = 17;
+ break;
+ }
- return _context7.delegateYield(func.apply(this, func_args), "t0", 8);
+ result.push({
+ match: matches.match,
+ index: matches.start,
+ groups: matches.groups,
+ });
+ return _context3.delegateYield(evaluateMatcher(matches.next), 't1', 13);
- case 8:
- res = _context7.t0;
+ case 13:
+ matches = _context3.t1;
+ count++;
+ _context3.next = 10;
+ break;
- if (_boolean(res)) {
- result.push(entry);
- }
+ case 17:
+ return _context3.abrupt('return', result);
- case 10:
- i++;
- _context7.next = 4;
- break;
+ case 18:
+ case 'end':
+ return _context3.stop();
+ }
+ }
+ }, _marked3);
+ }
+ /**
+ * Match a string with a regex returning an array of object containing details of each match
+ * @param {String} str - string
+ * @param {String} pattern - the substring/regex applied to the string
+ * @param {String} replacement - text to replace the matched substrings
+ * @param {Integer} [limit] - max number of matches to return
+ * @returns {Array} The array of match objects
+ */
+
+ function replace(str, pattern, replacement, limit) {
+ var self, replacer, result, position, count, index, matches, replacedWith;
+ return regeneratorRuntime.wrap(
+ function replace$(_context4) {
+ while (1) {
+ switch ((_context4.prev = _context4.next)) {
+ case 0:
+ if (!(typeof str === 'undefined')) {
+ _context4.next = 2;
+ break;
+ }
- case 13:
- return _context7.abrupt("return", result);
+ return _context4.abrupt('return', undefined);
- case 14:
- case "end":
- return _context7.stop();
- }
- }
- }, _marked7, this);
- }
- /**
- * Given an array, find the single element matching a specified condition
- * Throws an exception if the number of matching elements is not exactly one
- * @param {Array} [arr] - array to filter
- * @param {Function} [func] - predicate function
- * @returns {*} Matching element
- */
-
-
- function single(arr, func) {
- var hasFoundMatch, result, i, entry, positiveResult, func_args, res;
- return regeneratorRuntime.wrap(function single$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (!(typeof arr === 'undefined')) {
- _context8.next = 2;
- break;
- }
+ case 2:
+ self = this; // pattern cannot be an empty string
- return _context8.abrupt("return", undefined);
+ if (!(pattern === '')) {
+ _context4.next = 5;
+ break;
+ }
- case 2:
- hasFoundMatch = false;
- i = 0;
+ throw {
+ code: 'D3010',
+ stack: new Error().stack,
+ value: pattern,
+ index: 2,
+ };
+
+ case 5:
+ if (!(limit < 0)) {
+ _context4.next = 7;
+ break;
+ }
- case 4:
- if (!(i < arr.length)) {
- _context8.next = 22;
- break;
- }
+ throw {
+ code: 'D3011',
+ stack: new Error().stack,
+ value: limit,
+ index: 4,
+ };
+
+ case 7:
+ if (typeof replacement === 'string') {
+ replacer = function replacer(regexMatch) {
+ var substitute = ''; // scan forward, copying the replacement text into the substitute string
+ // and replace any occurrence of $n with the values matched by the regex
+
+ var position = 0;
+ var index = replacement.indexOf('$', position);
+
+ while (index !== -1 && position < replacement.length) {
+ substitute += replacement.substring(position, index);
+ position = index + 1;
+ var dollarVal = replacement.charAt(position);
+
+ if (dollarVal === '$') {
+ // literal $
+ substitute += '$';
+ position++;
+ } else if (dollarVal === '0') {
+ substitute += regexMatch.match;
+ position++;
+ } else {
+ var maxDigits;
+
+ if (regexMatch.groups.length === 0) {
+ // no sub-matches; any $ followed by a digit will be replaced by an empty string
+ maxDigits = 1;
+ } else {
+ // max number of digits to parse following the $
+ maxDigits = Math.floor(Math.log(regexMatch.groups.length) * Math.LOG10E) + 1;
+ }
- entry = arr[i];
- positiveResult = true;
+ index = parseInt(replacement.substring(position, position + maxDigits), 10);
- if (!(typeof func !== 'undefined')) {
- _context8.next = 12;
- break;
- }
+ if (maxDigits > 1 && index > regexMatch.groups.length) {
+ index = parseInt(replacement.substring(position, position + maxDigits - 1), 10);
+ }
- func_args = hofFuncArgs(func, entry, i, arr); // invoke func
+ if (!isNaN(index)) {
+ if (regexMatch.groups.length > 0) {
+ var submatch = regexMatch.groups[index - 1];
- return _context8.delegateYield(func.apply(this, func_args), "t0", 10);
+ if (typeof submatch !== 'undefined') {
+ substitute += submatch;
+ }
+ }
- case 10:
- res = _context8.t0;
- positiveResult = _boolean(res);
+ position += index.toString().length;
+ } else {
+ // not a capture group, treat the $ as literal
+ substitute += '$';
+ }
+ }
- case 12:
- if (!positiveResult) {
- _context8.next = 19;
- break;
- }
+ index = replacement.indexOf('$', position);
+ }
- if (hasFoundMatch) {
- _context8.next = 18;
- break;
- }
+ substitute += replacement.substring(position);
+ return substitute;
+ };
+ } else {
+ replacer = replacement;
+ }
- result = entry;
- hasFoundMatch = true;
- _context8.next = 19;
- break;
+ result = '';
+ position = 0;
- case 18:
- throw {
- stack: new Error().stack,
- code: "D3138",
- index: i
- };
+ if (!(typeof limit === 'undefined' || limit > 0)) {
+ _context4.next = 44;
+ break;
+ }
- case 19:
- i++;
- _context8.next = 4;
- break;
+ count = 0;
- case 22:
- if (hasFoundMatch) {
- _context8.next = 24;
- break;
- }
+ if (!(typeof pattern === 'string')) {
+ _context4.next = 18;
+ break;
+ }
- throw {
- stack: new Error().stack,
- code: "D3139"
- };
+ index = str.indexOf(pattern, position);
- case 24:
- return _context8.abrupt("return", result);
+ while (index !== -1 && (typeof limit === 'undefined' || count < limit)) {
+ result += str.substring(position, index);
+ result += replacement;
+ position = index + pattern.length;
+ count++;
+ index = str.indexOf(pattern, position);
+ }
- case 25:
- case "end":
- return _context8.stop();
- }
- }
- }, _marked8, this);
- }
- /**
- * Convolves (zips) each value from a set of arrays
- * @param {Array} [args] - arrays to zip
- * @returns {Array} Zipped array
- */
+ result += str.substring(position);
+ _context4.next = 42;
+ break;
+ case 18:
+ return _context4.delegateYield(evaluateMatcher(pattern, str), 't0', 19);
- function zip() {
- // this can take a variable number of arguments
- var result = [];
- var args = Array.prototype.slice.call(arguments); // length of the shortest array
+ case 19:
+ matches = _context4.t0;
- var length = Math.min.apply(Math, args.map(function (arg) {
- if (Array.isArray(arg)) {
- return arg.length;
- }
+ if (!(typeof matches !== 'undefined')) {
+ _context4.next = 41;
+ break;
+ }
- return 0;
- }));
+ case 21:
+ if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
+ _context4.next = 38;
+ break;
+ }
- for (var i = 0; i < length; i++) {
- var tuple = args.map(function (arg) {
- return arg[i];
- });
- result.push(tuple);
- }
+ result += str.substring(position, matches.start);
+ replacedWith = replacer.apply(self, [matches]);
- return result;
- }
- /**
- * Fold left function
- * @param {Array} sequence - Sequence
- * @param {Function} func - Function
- * @param {Object} init - Initial value
- * @returns {*} Result
- */
-
-
- function foldLeft(sequence, func, init) {
- var result, arity, index, args;
- return regeneratorRuntime.wrap(function foldLeft$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- if (!(typeof sequence === 'undefined')) {
- _context9.next = 2;
- break;
- }
+ if (!isIterable(replacedWith)) {
+ _context4.next = 27;
+ break;
+ }
- return _context9.abrupt("return", undefined);
+ return _context4.delegateYield(replacedWith, 't1', 26);
- case 2:
- arity = getFunctionArity(func);
+ case 26:
+ replacedWith = _context4.t1;
- if (!(arity < 2)) {
- _context9.next = 5;
- break;
- }
+ case 27:
+ if (!(typeof replacedWith === 'string')) {
+ _context4.next = 31;
+ break;
+ }
- throw {
- stack: new Error().stack,
- code: "D3050",
- index: 1
- };
+ result += replacedWith;
+ _context4.next = 32;
+ break;
- case 5:
- if (typeof init === 'undefined' && sequence.length > 0) {
- result = sequence[0];
- index = 1;
- } else {
- result = init;
- index = 0;
- }
+ case 31:
+ throw {
+ code: 'D3012',
+ stack: new Error().stack,
+ value: replacedWith,
+ };
- case 6:
- if (!(index < sequence.length)) {
- _context9.next = 15;
- break;
- }
+ case 32:
+ position = matches.start + matches.match.length;
+ count++;
+ return _context4.delegateYield(evaluateMatcher(matches.next), 't2', 35);
- args = [result, sequence[index]];
+ case 35:
+ matches = _context4.t2;
+ _context4.next = 21;
+ break;
- if (arity >= 3) {
- args.push(index);
- }
+ case 38:
+ result += str.substring(position);
+ _context4.next = 42;
+ break;
- if (arity >= 4) {
- args.push(sequence);
- }
+ case 41:
+ result = str;
- return _context9.delegateYield(func.apply(this, args), "t0", 11);
+ case 42:
+ _context4.next = 45;
+ break;
- case 11:
- result = _context9.t0;
- index++;
- _context9.next = 6;
- break;
+ case 44:
+ result = str;
- case 15:
- return _context9.abrupt("return", result);
+ case 45:
+ return _context4.abrupt('return', result);
- case 16:
- case "end":
- return _context9.stop();
- }
- }
- }, _marked9, this);
- }
- /**
- * Return keys for an object
- * @param {Object} arg - Object
- * @returns {Array} Array of keys
- */
-
-
- function keys(arg) {
- var result = createSequence();
-
- if (Array.isArray(arg)) {
- // merge the keys of all of the items in the array
- var merge = {};
- arg.forEach(function (item) {
- var allkeys = keys(item);
- allkeys.forEach(function (key) {
- merge[key] = true;
- });
- });
- result = keys(merge);
- } else if (arg !== null && _typeof(arg) === 'object' && !isLambda(arg)) {
- Object.keys(arg).forEach(function (key) {
- return result.push(key);
- });
- }
+ case 46:
+ case 'end':
+ return _context4.stop();
+ }
+ }
+ },
+ _marked4,
+ this
+ );
+ }
+ /**
+ * Base64 encode a string
+ * @param {String} str - string
+ * @returns {String} Base 64 encoding of the binary data
+ */
+
+ function base64encode(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Use btoa in a browser, or Buffer in Node.js
+
+ var btoa =
+ typeof window !== 'undefined'
+ ? /* istanbul ignore next */
+ window.btoa
+ : function (str) {
+ // Simply doing `new Buffer` at this point causes Browserify to pull
+ // in the entire Buffer browser library, which is large and unnecessary.
+ // Using `global.Buffer` defeats this.
+ return new global.Buffer.from(str, 'binary').toString('base64'); // eslint-disable-line new-cap
+ };
+ return btoa(str);
+ }
+ /**
+ * Base64 decode a string
+ * @param {String} str - string
+ * @returns {String} Base 64 encoding of the binary data
+ */
+
+ function base64decode(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Use btoa in a browser, or Buffer in Node.js
+
+ var atob =
+ typeof window !== 'undefined'
+ ? /* istanbul ignore next */
+ window.atob
+ : function (str) {
+ // Simply doing `new Buffer` at this point causes Browserify to pull
+ // in the entire Buffer browser library, which is large and unnecessary.
+ // Using `global.Buffer` defeats this.
+ return new global.Buffer(str, 'base64').toString('binary');
+ };
+ return atob(str);
+ }
+ /**
+ * Encode a string into a component for a url
+ * @param {String} str - String to encode
+ * @returns {string} Encoded string
+ */
+
+ function encodeUrlComponent(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Catch URIErrors when URI sequence is malformed
+
+ var returnVal;
+
+ try {
+ returnVal = encodeURIComponent(str);
+ } catch (e) {
+ throw {
+ code: 'D3140',
+ stack: new Error().stack,
+ value: str,
+ functionName: 'encodeUrlComponent',
+ };
+ }
- return result;
- }
- /**
- * Return value from an object for a given key
- * @param {Object} input - Object/Array
- * @param {String} key - Key in object
- * @returns {*} Value of key in object
- */
+ return returnVal;
+ }
+ /**
+ * Encode a string into a url
+ * @param {String} str - String to encode
+ * @returns {string} Encoded string
+ */
+
+ function encodeUrl(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Catch URIErrors when URI sequence is malformed
+
+ var returnVal;
+
+ try {
+ returnVal = encodeURI(str);
+ } catch (e) {
+ throw {
+ code: 'D3140',
+ stack: new Error().stack,
+ value: str,
+ functionName: 'encodeUrl',
+ };
+ }
+ return returnVal;
+ }
+ /**
+ * Decode a string from a component for a url
+ * @param {String} str - String to decode
+ * @returns {string} Decoded string
+ */
+
+ function decodeUrlComponent(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Catch URIErrors when URI sequence is malformed
+
+ var returnVal;
+
+ try {
+ returnVal = decodeURIComponent(str);
+ } catch (e) {
+ throw {
+ code: 'D3140',
+ stack: new Error().stack,
+ value: str,
+ functionName: 'decodeUrlComponent',
+ };
+ }
- function lookup(input, key) {
- // lookup the 'name' item in the input
- var result;
+ return returnVal;
+ }
+ /**
+ * Decode a string from a url
+ * @param {String} str - String to decode
+ * @returns {string} Decoded string
+ */
+
+ function decodeUrl(str) {
+ // undefined inputs always return undefined
+ if (typeof str === 'undefined') {
+ return undefined;
+ } // Catch URIErrors when URI sequence is malformed
+
+ var returnVal;
+
+ try {
+ returnVal = decodeURI(str);
+ } catch (e) {
+ throw {
+ code: 'D3140',
+ stack: new Error().stack,
+ value: str,
+ functionName: 'decodeUrl',
+ };
+ }
- if (Array.isArray(input)) {
- result = createSequence();
+ return returnVal;
+ }
+ /**
+ * Split a string into an array of substrings
+ * @param {String} str - string
+ * @param {String} separator - the token or regex that splits the string
+ * @param {Integer} [limit] - max number of substrings
+ * @returns {Array} The array of string
+ */
+
+ function split(str, separator, limit) {
+ var result, count, matches, start;
+ return regeneratorRuntime.wrap(function split$(_context5) {
+ while (1) {
+ switch ((_context5.prev = _context5.next)) {
+ case 0:
+ if (!(typeof str === 'undefined')) {
+ _context5.next = 2;
+ break;
+ }
- for (var ii = 0; ii < input.length; ii++) {
- var res = lookup(input[ii], key);
+ return _context5.abrupt('return', undefined);
- if (typeof res !== 'undefined') {
- if (Array.isArray(res)) {
- var _result;
+ case 2:
+ if (!(limit < 0)) {
+ _context5.next = 4;
+ break;
+ }
- (_result = result).push.apply(_result, _toConsumableArray(res));
- } else {
- result.push(res);
- }
- }
- }
- } else if (input !== null && _typeof(input) === 'object') {
- result = input[key];
- }
+ throw {
+ code: 'D3020',
+ stack: new Error().stack,
+ value: limit,
+ index: 3,
+ };
- return result;
- }
- /**
- * Append second argument to first
- * @param {Array|Object} arg1 - First argument
- * @param {Array|Object} arg2 - Second argument
- * @returns {*} Appended arguments
- */
-
-
- function append(arg1, arg2) {
- // disregard undefined args
- if (typeof arg1 === 'undefined') {
- return arg2;
- }
+ case 4:
+ result = [];
- if (typeof arg2 === 'undefined') {
- return arg1;
- } // if either argument is not an array, make it so
+ if (!(typeof limit === 'undefined' || limit > 0)) {
+ _context5.next = 27;
+ break;
+ }
+ if (!(typeof separator === 'string')) {
+ _context5.next = 10;
+ break;
+ }
- if (!Array.isArray(arg1)) {
- arg1 = createSequence(arg1);
- }
+ result = str.split(separator, limit);
+ _context5.next = 27;
+ break;
- if (!Array.isArray(arg2)) {
- arg2 = [arg2];
- }
+ case 10:
+ count = 0;
+ return _context5.delegateYield(evaluateMatcher(separator, str), 't0', 12);
- return arg1.concat(arg2);
- }
- /**
- * Determines if the argument is undefined
- * @param {*} arg - argument
- * @returns {boolean} False if argument undefined, otherwise true
- */
+ case 12:
+ matches = _context5.t0;
+ if (!(typeof matches !== 'undefined')) {
+ _context5.next = 26;
+ break;
+ }
- function exists(arg) {
- if (typeof arg === 'undefined') {
- return false;
- } else {
- return true;
- }
- }
- /**
- * Splits an object into an array of object with one property each
- * @param {*} arg - the object to split
- * @returns {*} - the array
- */
+ start = 0;
+ case 15:
+ if (!(typeof matches !== 'undefined' && (typeof limit === 'undefined' || count < limit))) {
+ _context5.next = 23;
+ break;
+ }
- function spread(arg) {
- var result = createSequence();
+ result.push(str.substring(start, matches.start));
+ start = matches.end;
+ return _context5.delegateYield(evaluateMatcher(matches.next), 't1', 19);
- if (Array.isArray(arg)) {
- // spread all of the items in the array
- arg.forEach(function (item) {
- result = append(result, spread(item));
- });
- } else if (arg !== null && _typeof(arg) === 'object' && !isLambda(arg)) {
- for (var key in arg) {
- var obj = {};
- obj[key] = arg[key];
- result.push(obj);
- }
- } else {
- result = arg;
- }
+ case 19:
+ matches = _context5.t1;
+ count++;
+ _context5.next = 15;
+ break;
- return result;
- }
- /**
- * Merges an array of objects into a single object. Duplicate properties are
- * overridden by entries later in the array
- * @param {*} arg - the objects to merge
- * @returns {*} - the object
- */
-
-
- function merge(arg) {
- // undefined inputs always return undefined
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ case 23:
+ if (typeof limit === 'undefined' || count < limit) {
+ result.push(str.substring(start));
+ }
- var result = {};
- arg.forEach(function (obj) {
- for (var prop in obj) {
- result[prop] = obj[prop];
- }
- });
- return result;
- }
- /**
- * Reverses the order of items in an array
- * @param {Array} arr - the array to reverse
- * @returns {Array} - the reversed array
- */
+ _context5.next = 27;
+ break;
+ case 26:
+ result.push(str);
- function reverse(arr) {
- // undefined inputs always return undefined
- if (typeof arr === 'undefined') {
- return undefined;
- }
+ case 27:
+ return _context5.abrupt('return', result);
- if (arr.length <= 1) {
- return arr;
- }
+ case 28:
+ case 'end':
+ return _context5.stop();
+ }
+ }
+ }, _marked5);
+ }
+ /**
+ * Join an array of strings
+ * @param {Array} strs - array of string
+ * @param {String} [separator] - the token that splits the string
+ * @returns {String} The concatenated string
+ */
+
+ function join(strs, separator) {
+ // undefined inputs always return undefined
+ if (typeof strs === 'undefined') {
+ return undefined;
+ } // if separator is not specified, default to empty string
+
+ if (typeof separator === 'undefined') {
+ separator = '';
+ }
- var length = arr.length;
- var result = new Array(length);
+ return strs.join(separator);
+ }
+ /**
+ * Formats a number into a decimal string representation using XPath 3.1 F&O fn:format-number spec
+ * @param {number} value - number to format
+ * @param {String} picture - picture string definition
+ * @param {Object} [options] - override locale defaults
+ * @returns {String} The formatted string
+ */
+
+ function formatNumber(value, picture, options) {
+ // undefined inputs always return undefined
+ if (typeof value === 'undefined') {
+ return undefined;
+ }
- for (var i = 0; i < length; i++) {
- result[length - i - 1] = arr[i];
- }
+ var defaults = {
+ 'decimal-separator': '.',
+ 'grouping-separator': ',',
+ 'exponent-separator': 'e',
+ infinity: 'Infinity',
+ 'minus-sign': '-',
+ NaN: 'NaN',
+ percent: '%',
+ 'per-mille': '\u2030',
+ 'zero-digit': '0',
+ digit: '#',
+ 'pattern-separator': ';',
+ }; // if `options` is specified, then its entries override defaults
+
+ var properties = defaults;
+
+ if (typeof options !== 'undefined') {
+ Object.keys(options).forEach(function (key) {
+ properties[key] = options[key];
+ });
+ }
- return result;
- }
- /**
- *
- * @param {*} obj - the input object to iterate over
- * @param {*} func - the function to apply to each key/value pair
- * @returns {Array} - the resultant array
- */
-
-
- function each(obj, func) {
- var result, key, func_args, val;
- return regeneratorRuntime.wrap(function each$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- result = createSequence();
- _context10.t0 = regeneratorRuntime.keys(obj);
-
- case 2:
- if ((_context10.t1 = _context10.t0()).done) {
- _context10.next = 10;
- break;
- }
+ var decimalDigitFamily = [];
+ var zeroCharCode = properties['zero-digit'].charCodeAt(0);
- key = _context10.t1.value;
- func_args = hofFuncArgs(func, obj[key], key, obj); // invoke func
+ for (var ii = zeroCharCode; ii < zeroCharCode + 10; ii++) {
+ decimalDigitFamily.push(String.fromCharCode(ii));
+ }
- return _context10.delegateYield(func.apply(this, func_args), "t2", 6);
+ var activeChars = decimalDigitFamily.concat([
+ properties['decimal-separator'],
+ properties['exponent-separator'],
+ properties['grouping-separator'],
+ properties.digit,
+ properties['pattern-separator'],
+ ]);
+ var subPictures = picture.split(properties['pattern-separator']);
- case 6:
- val = _context10.t2;
+ if (subPictures.length > 2) {
+ throw {
+ code: 'D3080',
+ stack: new Error().stack,
+ };
+ }
- if (typeof val !== 'undefined') {
- result.push(val);
- }
+ var splitParts = function splitParts(subpicture) {
+ var prefix = (function () {
+ var ch;
- _context10.next = 2;
- break;
+ for (var ii = 0; ii < subpicture.length; ii++) {
+ ch = subpicture.charAt(ii);
- case 10:
- return _context10.abrupt("return", result);
+ if (activeChars.indexOf(ch) !== -1 && ch !== properties['exponent-separator']) {
+ return subpicture.substring(0, ii);
+ }
+ }
+ })();
- case 11:
- case "end":
- return _context10.stop();
- }
- }
- }, _marked10, this);
- }
- /**
- *
- * @param {string} [message] - the message to attach to the error
- * @throws custom error with code 'D3137'
- */
-
-
- function error(message) {
- throw {
- code: "D3137",
- stack: new Error().stack,
- message: message || "$error() function evaluated"
- };
- }
- /**
- *
- * @param {boolean} condition - the condition to evaluate
- * @param {string} [message] - the message to attach to the error
- * @throws custom error with code 'D3137'
- * @returns {undefined}
- */
-
-
- function assert(condition, message) {
- if (!condition) {
- throw {
- code: "D3141",
- stack: new Error().stack,
- message: message || "$assert() statement failed"
- };
- }
+ var suffix = (function () {
+ var ch;
- return undefined;
- }
- /**
- * Implements the merge sort (stable) with optional comparator function
- *
- * @param {Array} arr - the array to sort
- * @param {*} comparator - comparator function
- * @returns {Array} - sorted array
- */
-
-
- function sort(arr, comparator) {
- var comp, merge, msort, result;
- return regeneratorRuntime.wrap(function sort$(_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- if (!(typeof arr === 'undefined')) {
- _context15.next = 2;
- break;
- }
+ for (var ii = subpicture.length - 1; ii >= 0; ii--) {
+ ch = subpicture.charAt(ii);
- return _context15.abrupt("return", undefined);
+ if (activeChars.indexOf(ch) !== -1 && ch !== properties['exponent-separator']) {
+ return subpicture.substring(ii + 1);
+ }
+ }
+ })();
- case 2:
- if (!(arr.length <= 1)) {
- _context15.next = 4;
- break;
- }
+ var activePart = subpicture.substring(prefix.length, subpicture.length - suffix.length);
+ var mantissaPart, exponentPart, integerPart, fractionalPart;
+ var exponentPosition = subpicture.indexOf(properties['exponent-separator'], prefix.length);
- return _context15.abrupt("return", arr);
+ if (exponentPosition === -1 || exponentPosition > subpicture.length - suffix.length) {
+ mantissaPart = activePart;
+ exponentPart = undefined;
+ } else {
+ mantissaPart = activePart.substring(0, exponentPosition);
+ exponentPart = activePart.substring(exponentPosition + 1);
+ }
- case 4:
- if (!(typeof comparator === 'undefined')) {
- _context15.next = 10;
- break;
- }
+ var decimalPosition = mantissaPart.indexOf(properties['decimal-separator']);
- if (!(!isArrayOfNumbers(arr) && !isArrayOfStrings(arr))) {
- _context15.next = 7;
- break;
- }
+ if (decimalPosition === -1) {
+ integerPart = mantissaPart;
+ fractionalPart = suffix;
+ } else {
+ integerPart = mantissaPart.substring(0, decimalPosition);
+ fractionalPart = mantissaPart.substring(decimalPosition + 1);
+ }
- throw {
- stack: new Error().stack,
- code: "D3070",
- index: 1
- };
+ return {
+ prefix: prefix,
+ suffix: suffix,
+ activePart: activePart,
+ mantissaPart: mantissaPart,
+ exponentPart: exponentPart,
+ integerPart: integerPart,
+ fractionalPart: fractionalPart,
+ subpicture: subpicture,
+ };
+ }; // validate the picture string, F&O 4.7.3
- case 7:
- comp =
- /*#__PURE__*/
- regeneratorRuntime.mark(function comp(a, b) {
- return regeneratorRuntime.wrap(function comp$(_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- return _context11.abrupt("return", a > b);
+ var validate = function validate(parts) {
+ var error;
+ var ii;
+ var subpicture = parts.subpicture;
+ var decimalPos = subpicture.indexOf(properties['decimal-separator']);
- case 1:
- case "end":
- return _context11.stop();
+ if (decimalPos !== subpicture.lastIndexOf(properties['decimal-separator'])) {
+ error = 'D3081';
}
- }
- }, comp);
- });
- _context15.next = 11;
- break;
-
- case 10:
- // for internal usage of functionSort (i.e. order-by syntax)
- comp = comparator;
-
- case 11:
- merge =
- /*#__PURE__*/
- regeneratorRuntime.mark(function merge(l, r) {
- var merge_iter, merged;
- return regeneratorRuntime.wrap(function merge$(_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- merge_iter =
- /*#__PURE__*/
- regeneratorRuntime.mark(function merge_iter(result, left, right) {
- return regeneratorRuntime.wrap(function merge_iter$(_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- if (!(left.length === 0)) {
- _context12.next = 4;
- break;
- }
- Array.prototype.push.apply(result, right);
- _context12.next = 16;
- break;
+ if (subpicture.indexOf(properties.percent) !== subpicture.lastIndexOf(properties.percent)) {
+ error = 'D3082';
+ }
- case 4:
- if (!(right.length === 0)) {
- _context12.next = 8;
- break;
- }
+ if (subpicture.indexOf(properties['per-mille']) !== subpicture.lastIndexOf(properties['per-mille'])) {
+ error = 'D3083';
+ }
- Array.prototype.push.apply(result, left);
- _context12.next = 16;
- break;
+ if (
+ subpicture.indexOf(properties.percent) !== -1 &&
+ subpicture.indexOf(properties['per-mille']) !== -1
+ ) {
+ error = 'D3084';
+ }
- case 8:
- return _context12.delegateYield(comp(left[0], right[0]), "t0", 9);
+ var valid = false;
- case 9:
- if (!_context12.t0) {
- _context12.next = 14;
- break;
- }
+ for (ii = 0; ii < parts.mantissaPart.length; ii++) {
+ var ch = parts.mantissaPart.charAt(ii);
- // invoke the comparator function
- // if it returns true - swap left and right
- result.push(right[0]);
- return _context12.delegateYield(merge_iter(result, left, right.slice(1)), "t1", 12);
+ if (decimalDigitFamily.indexOf(ch) !== -1 || ch === properties.digit) {
+ valid = true;
+ break;
+ }
+ }
- case 12:
- _context12.next = 16;
- break;
+ if (!valid) {
+ error = 'D3085';
+ }
- case 14:
- // otherwise keep the same order
- result.push(left[0]);
- return _context12.delegateYield(merge_iter(result, left.slice(1), right), "t2", 16);
+ var charTypes = parts.activePart
+ .split('')
+ .map(function (_char2) {
+ return activeChars.indexOf(_char2) === -1 ? 'p' : 'a';
+ })
+ .join('');
- case 16:
- case "end":
- return _context12.stop();
- }
- }
- }, merge_iter);
- });
- merged = [];
- return _context13.delegateYield(merge_iter(merged, l, r), "t0", 3);
+ if (charTypes.indexOf('p') !== -1) {
+ error = 'D3086';
+ }
- case 3:
- return _context13.abrupt("return", merged);
+ if (decimalPos !== -1) {
+ if (
+ subpicture.charAt(decimalPos - 1) === properties['grouping-separator'] ||
+ subpicture.charAt(decimalPos + 1) === properties['grouping-separator']
+ ) {
+ error = 'D3087';
+ }
+ } else if (
+ parts.integerPart.charAt(parts.integerPart.length - 1) === properties['grouping-separator']
+ ) {
+ error = 'D3088';
+ }
- case 4:
- case "end":
- return _context13.stop();
+ if (subpicture.indexOf(properties['grouping-separator'] + properties['grouping-separator']) !== -1) {
+ error = 'D3089';
}
- }
- }, merge);
- });
- msort =
- /*#__PURE__*/
- regeneratorRuntime.mark(function msort(array) {
- var middle, left, right;
- return regeneratorRuntime.wrap(function msort$(_context14) {
- while (1) {
- switch (_context14.prev = _context14.next) {
- case 0:
- if (!(!Array.isArray(array) || array.length <= 1)) {
- _context14.next = 4;
- break;
- }
- return _context14.abrupt("return", array);
+ var optionalDigitPos = parts.integerPart.indexOf(properties.digit);
+
+ if (
+ optionalDigitPos !== -1 &&
+ parts.integerPart
+ .substring(0, optionalDigitPos)
+ .split('')
+ .filter(function (_char3) {
+ return decimalDigitFamily.indexOf(_char3) > -1;
+ }).length > 0
+ ) {
+ error = 'D3090';
+ }
- case 4:
- middle = Math.floor(array.length / 2);
- left = array.slice(0, middle);
- right = array.slice(middle);
- return _context14.delegateYield(msort(left), "t0", 8);
+ optionalDigitPos = parts.fractionalPart.lastIndexOf(properties.digit);
+
+ if (
+ optionalDigitPos !== -1 &&
+ parts.fractionalPart
+ .substring(optionalDigitPos)
+ .split('')
+ .filter(function (_char4) {
+ return decimalDigitFamily.indexOf(_char4) > -1;
+ }).length > 0
+ ) {
+ error = 'D3091';
+ }
- case 8:
- left = _context14.t0;
- return _context14.delegateYield(msort(right), "t1", 10);
+ var exponentExists = typeof parts.exponentPart === 'string';
- case 10:
- right = _context14.t1;
- return _context14.delegateYield(merge(left, right), "t2", 12);
+ if (
+ exponentExists &&
+ parts.exponentPart.length > 0 &&
+ (subpicture.indexOf(properties.percent) !== -1 ||
+ subpicture.indexOf(properties['per-mille']) !== -1)
+ ) {
+ error = 'D3092';
+ }
- case 12:
- return _context14.abrupt("return", _context14.t2);
+ if (
+ exponentExists &&
+ (parts.exponentPart.length === 0 ||
+ parts.exponentPart.split('').filter(function (_char5) {
+ return decimalDigitFamily.indexOf(_char5) === -1;
+ }).length > 0)
+ ) {
+ error = 'D3093';
+ }
- case 13:
- case "end":
- return _context14.stop();
+ if (error) {
+ throw {
+ code: error,
+ stack: new Error().stack,
+ };
}
- }
- }, msort);
- });
- return _context15.delegateYield(msort(arr), "t0", 14);
+ }; // analyse the picture string, F&O 4.7.4
+
+ var analyse = function analyse(parts) {
+ var getGroupingPositions = function getGroupingPositions(part, toLeft) {
+ var positions = [];
+ var groupingPosition = part.indexOf(properties['grouping-separator']);
+
+ while (groupingPosition !== -1) {
+ var charsToTheRight = (
+ toLeft ? part.substring(0, groupingPosition) : part.substring(groupingPosition)
+ )
+ .split('')
+ .filter(function (_char6) {
+ return decimalDigitFamily.indexOf(_char6) !== -1 || _char6 === properties.digit;
+ }).length;
+ positions.push(charsToTheRight);
+ groupingPosition = parts.integerPart.indexOf(
+ properties['grouping-separator'],
+ groupingPosition + 1
+ );
+ }
- case 14:
- result = _context15.t0;
- return _context15.abrupt("return", result);
+ return positions;
+ };
- case 16:
- case "end":
- return _context15.stop();
- }
- }
- }, _marked11);
- }
- /**
- * Randomly shuffles the contents of an array
- * @param {Array} arr - the input array
- * @returns {Array} the shuffled array
- */
+ var integerPartGroupingPositions = getGroupingPositions(parts.integerPart);
+ var regular = function regular(indexes) {
+ // are the grouping positions regular? i.e. same interval between each of them
+ if (indexes.length === 0) {
+ return 0;
+ }
- function shuffle(arr) {
- // undefined inputs always return undefined
- if (typeof arr === 'undefined') {
- return undefined;
- }
+ var gcd = function gcd(a, b) {
+ return b === 0 ? a : gcd(b, a % b);
+ }; // find the greatest common divisor of all the positions
- if (arr.length <= 1) {
- return arr;
- } // shuffle using the 'inside-out' variant of the Fisher-Yates algorithm
+ var factor = indexes.reduce(gcd); // is every position separated by this divisor? If so, it's regular
+ for (var index = 1; index <= indexes.length; index++) {
+ if (indexes.indexOf(index * factor) === -1) {
+ return 0;
+ }
+ }
- var result = new Array(arr.length);
+ return factor;
+ };
- for (var i = 0; i < arr.length; i++) {
- var j = Math.floor(Math.random() * (i + 1)); // random integer such that 0 ≤ j ≤ i
+ var regularGrouping = regular(integerPartGroupingPositions);
+ var fractionalPartGroupingPositions = getGroupingPositions(parts.fractionalPart, true);
+ var minimumIntegerPartSize = parts.integerPart.split('').filter(function (_char7) {
+ return decimalDigitFamily.indexOf(_char7) !== -1;
+ }).length;
+ var scalingFactor = minimumIntegerPartSize;
+ var fractionalPartArray = parts.fractionalPart.split('');
+ var minimumFactionalPartSize = fractionalPartArray.filter(function (_char8) {
+ return decimalDigitFamily.indexOf(_char8) !== -1;
+ }).length;
+ var maximumFactionalPartSize = fractionalPartArray.filter(function (_char9) {
+ return decimalDigitFamily.indexOf(_char9) !== -1 || _char9 === properties.digit;
+ }).length;
+ var exponentPresent = typeof parts.exponentPart === 'string';
+
+ if (minimumIntegerPartSize === 0 && maximumFactionalPartSize === 0) {
+ if (exponentPresent) {
+ minimumFactionalPartSize = 1;
+ maximumFactionalPartSize = 1;
+ } else {
+ minimumIntegerPartSize = 1;
+ }
+ }
- if (i !== j) {
- result[i] = result[j];
- }
+ if (
+ exponentPresent &&
+ minimumIntegerPartSize === 0 &&
+ parts.integerPart.indexOf(properties.digit) !== -1
+ ) {
+ minimumIntegerPartSize = 1;
+ }
- result[j] = arr[i];
- }
+ if (minimumIntegerPartSize === 0 && minimumFactionalPartSize === 0) {
+ minimumFactionalPartSize = 1;
+ }
- return result;
- }
- /**
- * Returns the values that appear in a sequence, with duplicates eliminated.
- * @param {Array} arr - An array or sequence of values
- * @returns {Array} - sequence of distinct values
- */
+ var minimumExponentSize = 0;
+ if (exponentPresent) {
+ minimumExponentSize = parts.exponentPart.split('').filter(function (_char10) {
+ return decimalDigitFamily.indexOf(_char10) !== -1;
+ }).length;
+ }
- function distinct(arr) {
- // undefined inputs always return undefined
- if (typeof arr === 'undefined') {
- return undefined;
- }
+ return {
+ integerPartGroupingPositions: integerPartGroupingPositions,
+ regularGrouping: regularGrouping,
+ minimumIntegerPartSize: minimumIntegerPartSize,
+ scalingFactor: scalingFactor,
+ prefix: parts.prefix,
+ fractionalPartGroupingPositions: fractionalPartGroupingPositions,
+ minimumFactionalPartSize: minimumFactionalPartSize,
+ maximumFactionalPartSize: maximumFactionalPartSize,
+ minimumExponentSize: minimumExponentSize,
+ suffix: parts.suffix,
+ picture: parts.subpicture,
+ };
+ };
- if (!Array.isArray(arr) || arr.length <= 1) {
- return arr;
- }
+ var parts = subPictures.map(splitParts);
+ parts.forEach(validate);
+ var variables = parts.map(analyse);
+ var minus_sign = properties['minus-sign'];
+ var zero_digit = properties['zero-digit'];
+ var decimal_separator = properties['decimal-separator'];
+ var grouping_separator = properties['grouping-separator'];
+
+ if (variables.length === 1) {
+ variables.push(JSON.parse(JSON.stringify(variables[0])));
+ variables[1].prefix = minus_sign + variables[1].prefix;
+ } // TODO cache the result of the analysis
+ // format the number
+ // bullet 1: TODO: NaN - not sure we'd ever get this in JSON
+
+ var pic; // bullet 2:
+
+ if (value >= 0) {
+ pic = variables[0];
+ } else {
+ pic = variables[1];
+ }
- var results = isSequence(arr) ? createSequence() : [];
+ var adjustedNumber; // bullet 3:
- for (var ii = 0; ii < arr.length; ii++) {
- var value = arr[ii]; // is this value already in the result sequence?
+ if (pic.picture.indexOf(properties.percent) !== -1) {
+ adjustedNumber = value * 100;
+ } else if (pic.picture.indexOf(properties['per-mille']) !== -1) {
+ adjustedNumber = value * 1000;
+ } else {
+ adjustedNumber = value;
+ } // bullet 4:
+ // TODO: infinity - not sure we'd ever get this in JSON
+ // bullet 5:
- var includes = false;
+ var mantissa, exponent;
- for (var jj = 0; jj < results.length; jj++) {
- if (deepEquals(value, results[jj])) {
- includes = true;
- break;
- }
- }
+ if (pic.minimumExponentSize === 0) {
+ mantissa = adjustedNumber;
+ } else {
+ // mantissa * 10^exponent = adjustedNumber
+ var maxMantissa = Math.pow(10, pic.scalingFactor);
+ var minMantissa = Math.pow(10, pic.scalingFactor - 1);
+ mantissa = adjustedNumber;
+ exponent = 0;
+
+ while (mantissa < minMantissa) {
+ mantissa *= 10;
+ exponent -= 1;
+ }
- if (!includes) {
- results.push(value);
- }
- }
+ while (mantissa > maxMantissa) {
+ mantissa /= 10;
+ exponent += 1;
+ }
+ } // bullet 6:
- return results;
- }
- /**
- * Applies a predicate function to each key/value pair in an object, and returns an object containing
- * only the key/value pairs that passed the predicate
- *
- * @param {object} arg - the object to be sifted
- * @param {object} func - the predicate function (lambda or native)
- * @returns {object} - sifted object
- */
-
-
- function sift(arg, func) {
- var result, item, entry, func_args, res;
- return regeneratorRuntime.wrap(function sift$(_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- result = {};
- _context16.t0 = regeneratorRuntime.keys(arg);
-
- case 2:
- if ((_context16.t1 = _context16.t0()).done) {
- _context16.next = 11;
- break;
- }
+ var roundedNumber = round(mantissa, pic.maximumFactionalPartSize); // bullet 7:
- item = _context16.t1.value;
- entry = arg[item];
- func_args = hofFuncArgs(func, entry, item, arg); // invoke func
+ var makeString = function makeString(value, dp) {
+ var str = Math.abs(value).toFixed(dp);
- return _context16.delegateYield(func.apply(this, func_args), "t2", 7);
+ if (zero_digit !== '0') {
+ str = str
+ .split('')
+ .map(function (digit) {
+ if (digit >= '0' && digit <= '9') {
+ return decimalDigitFamily[digit.charCodeAt(0) - 48];
+ } else {
+ return digit;
+ }
+ })
+ .join('');
+ }
- case 7:
- res = _context16.t2;
+ return str;
+ };
- if (_boolean(res)) {
- result[item] = entry;
- }
+ var stringValue = makeString(roundedNumber, pic.maximumFactionalPartSize);
+ var decimalPos = stringValue.indexOf('.');
- _context16.next = 2;
- break;
+ if (decimalPos === -1) {
+ stringValue = stringValue + decimal_separator;
+ } else {
+ stringValue = stringValue.replace('.', decimal_separator);
+ }
- case 11:
- // empty objects should be changed to undefined
- if (Object.keys(result).length === 0) {
- result = undefined;
- }
+ while (stringValue.charAt(0) === zero_digit) {
+ stringValue = stringValue.substring(1);
+ }
- return _context16.abrupt("return", result);
+ while (stringValue.charAt(stringValue.length - 1) === zero_digit) {
+ stringValue = stringValue.substring(0, stringValue.length - 1);
+ } // bullets 8 & 9:
+
+ decimalPos = stringValue.indexOf(decimal_separator);
+ var padLeft = pic.minimumIntegerPartSize - decimalPos;
+ var padRight = pic.minimumFactionalPartSize - (stringValue.length - decimalPos - 1);
+ stringValue = (padLeft > 0 ? new Array(padLeft + 1).join(zero_digit) : '') + stringValue;
+ stringValue = stringValue + (padRight > 0 ? new Array(padRight + 1).join(zero_digit) : '');
+ decimalPos = stringValue.indexOf(decimal_separator); // bullet 10:
+
+ if (pic.regularGrouping > 0) {
+ var groupCount = Math.floor((decimalPos - 1) / pic.regularGrouping);
+
+ for (var group = 1; group <= groupCount; group++) {
+ stringValue = [
+ stringValue.slice(0, decimalPos - group * pic.regularGrouping),
+ grouping_separator,
+ stringValue.slice(decimalPos - group * pic.regularGrouping),
+ ].join('');
+ }
+ } else {
+ pic.integerPartGroupingPositions.forEach(function (pos) {
+ stringValue = [
+ stringValue.slice(0, decimalPos - pos),
+ grouping_separator,
+ stringValue.slice(decimalPos - pos),
+ ].join('');
+ decimalPos++;
+ });
+ } // bullet 11:
+
+ decimalPos = stringValue.indexOf(decimal_separator);
+ pic.fractionalPartGroupingPositions.forEach(function (pos) {
+ stringValue = [
+ stringValue.slice(0, pos + decimalPos + 1),
+ grouping_separator,
+ stringValue.slice(pos + decimalPos + 1),
+ ].join('');
+ }); // bullet 12:
+
+ decimalPos = stringValue.indexOf(decimal_separator);
+
+ if (pic.picture.indexOf(decimal_separator) === -1 || decimalPos === stringValue.length - 1) {
+ stringValue = stringValue.substring(0, stringValue.length - 1);
+ } // bullet 13:
+
+ if (typeof exponent !== 'undefined') {
+ var stringExponent = makeString(exponent, 0);
+ padLeft = pic.minimumExponentSize - stringExponent.length;
+
+ if (padLeft > 0) {
+ stringExponent = new Array(padLeft + 1).join(zero_digit) + stringExponent;
+ }
- case 13:
- case "end":
- return _context16.stop();
- }
- }
- }, _marked12, this);
- }
+ stringValue =
+ stringValue + properties['exponent-separator'] + (exponent < 0 ? minus_sign : '') + stringExponent;
+ } // bullet 14:
- return {
- sum: sum,
- count: count,
- max: max,
- min: min,
- average: average,
- string: string,
- substring: substring,
- substringBefore: substringBefore,
- substringAfter: substringAfter,
- lowercase: lowercase,
- uppercase: uppercase,
- length: length,
- trim: trim,
- pad: pad,
- match: match,
- contains: contains,
- replace: replace,
- split: split,
- join: join,
- formatNumber: formatNumber,
- formatBase: formatBase,
- number: number,
- floor: floor,
- ceil: ceil,
- round: round,
- abs: abs,
- sqrt: sqrt,
- power: power,
- random: random,
- "boolean": _boolean,
- not: not,
- map: map,
- zip: zip,
- filter: filter,
- single: single,
- foldLeft: foldLeft,
- sift: sift,
- keys: keys,
- lookup: lookup,
- append: append,
- exists: exists,
- spread: spread,
- merge: merge,
- reverse: reverse,
- each: each,
- error: error,
- assert: assert,
- sort: sort,
- shuffle: shuffle,
- distinct: distinct,
- base64encode: base64encode,
- base64decode: base64decode,
- encodeUrlComponent: encodeUrlComponent,
- encodeUrl: encodeUrl,
- decodeUrlComponent: decodeUrlComponent,
- decodeUrl: decodeUrl
- };
-}();
+ stringValue = pic.prefix + stringValue + pic.suffix;
+ return stringValue;
+ }
+ /**
+ * Converts a number to a string using a specified number base
+ * @param {number} value - the number to convert
+ * @param {number} [radix] - the number base; must be between 2 and 36. Defaults to 10
+ * @returns {string} - the converted string
+ */
+
+ function formatBase(value, radix) {
+ // undefined inputs always return undefined
+ if (typeof value === 'undefined') {
+ return undefined;
+ }
-module.exports = functions;
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./utils":6}],3:[function(require,module,exports){
-"use strict";
+ value = round(value);
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+ if (typeof radix === 'undefined') {
+ radix = 10;
+ } else {
+ radix = round(radix);
+ }
-/**
- * © Copyright IBM Corp. 2016, 2017 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
+ if (radix < 2 || radix > 36) {
+ throw {
+ code: 'D3100',
+ stack: new Error().stack,
+ value: radix,
+ };
+ }
-/**
- * @module JSONata
- * @description JSON query and transformation language
- */
-var datetime = require('./datetime');
+ var result = value.toString(radix);
+ return result;
+ }
+ /**
+ * Cast argument to number
+ * @param {Object} arg - Argument
+ * @returns {Number} numeric value of argument
+ */
-var fn = require('./functions');
+ function number(arg) {
+ var result; // undefined inputs always return undefined
-var utils = require('./utils');
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
-var parser = require('./parser');
+ if (typeof arg === 'number') {
+ // already a number
+ result = arg;
+ } else if (
+ typeof arg === 'string' &&
+ /^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(arg) &&
+ !isNaN(parseFloat(arg)) &&
+ isFinite(arg)
+ ) {
+ result = parseFloat(arg);
+ } else if (arg === true) {
+ // boolean true casts to 1
+ result = 1;
+ } else if (arg === false) {
+ // boolean false casts to 0
+ result = 0;
+ } else {
+ throw {
+ code: 'D3030',
+ value: arg,
+ stack: new Error().stack,
+ index: 1,
+ };
+ }
-var parseSignature = require('./signature');
-/**
- * jsonata
- * @function
- * @param {Object} expr - JSONata expression
- * @returns {{evaluate: evaluate, assign: assign}} Evaluated expression
- */
+ return result;
+ }
+ /**
+ * Absolute value of a number
+ * @param {Number} arg - Argument
+ * @returns {Number} absolute value of argument
+ */
+ function abs(arg) {
+ var result; // undefined inputs always return undefined
-var jsonata = function () {
- 'use strict';
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- var _marked =
- /*#__PURE__*/
- regeneratorRuntime.mark(_evaluate),
- _marked2 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluatePath),
- _marked3 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateStep),
- _marked4 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateStages),
- _marked5 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateTupleStep),
- _marked6 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateFilter),
- _marked7 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateBinary),
- _marked8 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateUnary),
- _marked9 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateGroupExpression),
- _marked10 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateBindExpression),
- _marked11 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateCondition),
- _marked12 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateBlock),
- _marked13 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateSortExpression),
- _marked14 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateApplyExpression),
- _marked15 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluateFunction),
- _marked16 =
- /*#__PURE__*/
- regeneratorRuntime.mark(apply),
- _marked17 =
- /*#__PURE__*/
- regeneratorRuntime.mark(applyInner),
- _marked18 =
- /*#__PURE__*/
- regeneratorRuntime.mark(evaluatePartialApplication),
- _marked19 =
- /*#__PURE__*/
- regeneratorRuntime.mark(applyProcedure),
- _marked20 =
- /*#__PURE__*/
- regeneratorRuntime.mark(applyNativeFunction),
- _marked21 =
- /*#__PURE__*/
- regeneratorRuntime.mark(functionEval);
-
- var isNumeric = utils.isNumeric;
- var isArrayOfStrings = utils.isArrayOfStrings;
- var isArrayOfNumbers = utils.isArrayOfNumbers;
- var createSequence = utils.createSequence;
- var isSequence = utils.isSequence;
- var isFunction = utils.isFunction;
- var isLambda = utils.isLambda;
- var isIterable = utils.isIterable;
- var getFunctionArity = utils.getFunctionArity;
- var isDeepEqual = utils.isDeepEqual; // Start of Evaluator code
-
- var staticFrame = createFrame(null);
- /**
- * Evaluate expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
- function _evaluate(expr, input, environment) {
- var result, entryCallback, ii, exitCallback;
- return regeneratorRuntime.wrap(function evaluate$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- entryCallback = environment.lookup('__evaluate_entry');
-
- if (entryCallback) {
- entryCallback(expr, input, environment);
- }
+ result = Math.abs(arg);
+ return result;
+ }
+ /**
+ * Rounds a number down to integer
+ * @param {Number} arg - Argument
+ * @returns {Number} rounded integer
+ */
+
+ function floor(arg) {
+ var result; // undefined inputs always return undefined
- _context.t0 = expr.type;
- _context.next = _context.t0 === 'path' ? 5 : _context.t0 === 'binary' ? 8 : _context.t0 === 'unary' ? 11 : _context.t0 === 'name' ? 14 : _context.t0 === 'string' ? 16 : _context.t0 === 'number' ? 16 : _context.t0 === 'value' ? 16 : _context.t0 === 'wildcard' ? 18 : _context.t0 === 'descendant' ? 20 : _context.t0 === 'condition' ? 22 : _context.t0 === 'block' ? 25 : _context.t0 === 'bind' ? 28 : _context.t0 === 'regex' ? 31 : _context.t0 === 'function' ? 33 : _context.t0 === 'variable' ? 36 : _context.t0 === 'lambda' ? 38 : _context.t0 === 'partial' ? 40 : _context.t0 === 'apply' ? 43 : _context.t0 === 'transform' ? 46 : 48;
- break;
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 5:
- return _context.delegateYield(evaluatePath(expr, input, environment), "t1", 6);
+ result = Math.floor(arg);
+ return result;
+ }
+ /**
+ * Rounds a number up to integer
+ * @param {Number} arg - Argument
+ * @returns {Number} rounded integer
+ */
- case 6:
- result = _context.t1;
- return _context.abrupt("break", 48);
+ function ceil(arg) {
+ var result; // undefined inputs always return undefined
- case 8:
- return _context.delegateYield(evaluateBinary(expr, input, environment), "t2", 9);
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 9:
- result = _context.t2;
- return _context.abrupt("break", 48);
+ result = Math.ceil(arg);
+ return result;
+ }
+ /**
+ * Round to half even
+ * @param {Number} arg - Argument
+ * @param {Number} [precision] - number of decimal places
+ * @returns {Number} rounded integer
+ */
+
+ function round(arg, precision) {
+ var result; // undefined inputs always return undefined
+
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 11:
- return _context.delegateYield(evaluateUnary(expr, input, environment), "t3", 12);
+ if (precision) {
+ // shift the decimal place - this needs to be done in a string since multiplying
+ // by a power of ten can introduce floating point precision errors which mess up
+ // this rounding algorithm - See 'Decimal rounding' in
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
+ // Shift
+ var value = arg.toString().split('e');
+ arg = +(value[0] + 'e' + (value[1] ? +value[1] + precision : precision));
+ } // round up to nearest int
+
+ result = Math.round(arg);
+ var diff = result - arg;
+
+ if (Math.abs(diff) === 0.5 && Math.abs(result % 2) === 1) {
+ // rounded the wrong way - adjust to nearest even number
+ result = result - 1;
+ }
- case 12:
- result = _context.t3;
- return _context.abrupt("break", 48);
+ if (precision) {
+ // Shift back
+ value = result.toString().split('e');
+ /* istanbul ignore next */
- case 14:
- result = evaluateName(expr, input, environment);
- return _context.abrupt("break", 48);
+ result = +(value[0] + 'e' + (value[1] ? +value[1] - precision : -precision));
+ }
- case 16:
- result = evaluateLiteral(expr, input, environment);
- return _context.abrupt("break", 48);
+ if (Object.is(result, -0)) {
+ // ESLint rule 'no-compare-neg-zero' suggests this way
+ // JSON doesn't do -0
+ result = 0;
+ }
- case 18:
- result = evaluateWildcard(expr, input, environment);
- return _context.abrupt("break", 48);
+ return result;
+ }
+ /**
+ * Square root of number
+ * @param {Number} arg - Argument
+ * @returns {Number} square root
+ */
- case 20:
- result = evaluateDescendants(expr, input, environment);
- return _context.abrupt("break", 48);
+ function sqrt(arg) {
+ var result; // undefined inputs always return undefined
- case 22:
- return _context.delegateYield(evaluateCondition(expr, input, environment), "t4", 23);
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 23:
- result = _context.t4;
- return _context.abrupt("break", 48);
+ if (arg < 0) {
+ throw {
+ stack: new Error().stack,
+ code: 'D3060',
+ index: 1,
+ value: arg,
+ };
+ }
- case 25:
- return _context.delegateYield(evaluateBlock(expr, input, environment), "t5", 26);
+ result = Math.sqrt(arg);
+ return result;
+ }
+ /**
+ * Raises number to the power of the second number
+ * @param {Number} arg - the base
+ * @param {Number} exp - the exponent
+ * @returns {Number} rounded integer
+ */
+
+ function power(arg, exp) {
+ var result; // undefined inputs always return undefined
+
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 26:
- result = _context.t5;
- return _context.abrupt("break", 48);
+ result = Math.pow(arg, exp);
- case 28:
- return _context.delegateYield(evaluateBindExpression(expr, input, environment), "t6", 29);
+ if (!isFinite(result)) {
+ throw {
+ stack: new Error().stack,
+ code: 'D3061',
+ index: 1,
+ value: arg,
+ exp: exp,
+ };
+ }
- case 29:
- result = _context.t6;
- return _context.abrupt("break", 48);
+ return result;
+ }
+ /**
+ * Returns a random number 0 <= n < 1
+ * @returns {number} random number
+ */
- case 31:
- result = evaluateRegex(expr, input, environment);
- return _context.abrupt("break", 48);
+ function random() {
+ return Math.random();
+ }
+ /**
+ * Evaluate an input and return a boolean
+ * @param {*} arg - Arguments
+ * @returns {boolean} Boolean
+ */
+
+ function _boolean(arg) {
+ // cast arg to its effective boolean value
+ // boolean: unchanged
+ // string: zero-length -> false; otherwise -> true
+ // number: 0 -> false; otherwise -> true
+ // null -> false
+ // array: empty -> false; length > 1 -> true
+ // object: empty -> false; non-empty -> true
+ // function -> false
+ // undefined inputs always return undefined
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 33:
- return _context.delegateYield(evaluateFunction(expr, input, environment), "t7", 34);
+ var result = false;
- case 34:
- result = _context.t7;
- return _context.abrupt("break", 48);
+ if (Array.isArray(arg)) {
+ if (arg.length === 1) {
+ result = _boolean(arg[0]);
+ } else if (arg.length > 1) {
+ var trues = arg.filter(function (val) {
+ return _boolean(val);
+ });
+ result = trues.length > 0;
+ }
+ } else if (typeof arg === 'string') {
+ if (arg.length > 0) {
+ result = true;
+ }
+ } else if (isNumeric(arg)) {
+ if (arg !== 0) {
+ result = true;
+ }
+ } else if (arg !== null && _typeof(arg) === 'object') {
+ if (Object.keys(arg).length > 0) {
+ result = true;
+ }
+ } else if (typeof arg === 'boolean' && arg === true) {
+ result = true;
+ }
- case 36:
- result = evaluateVariable(expr, input, environment);
- return _context.abrupt("break", 48);
+ return result;
+ }
+ /**
+ * returns the Boolean NOT of the arg
+ * @param {*} arg - argument
+ * @returns {boolean} - NOT arg
+ */
+
+ function not(arg) {
+ return !_boolean(arg);
+ }
+ /**
+ * Helper function to build the arguments to be supplied to the function arg of the
+ * HOFs map, filter, each, sift and single
+ * @param {function} func - the function to be invoked
+ * @param {*} arg1 - the first (required) arg - the value
+ * @param {*} arg2 - the second (optional) arg - the position (index or key)
+ * @param {*} arg3 - the third (optional) arg - the whole structure (array or object)
+ * @returns {*[]} the argument list
+ */
+
+ function hofFuncArgs(func, arg1, arg2, arg3) {
+ var func_args = [arg1]; // the first arg (the value) is required
+ // the other two are optional - only supply it if the function can take it
+
+ var length = getFunctionArity(func);
+
+ if (length >= 2) {
+ func_args.push(arg2);
+ }
- case 38:
- result = evaluateLambda(expr, input, environment);
- return _context.abrupt("break", 48);
+ if (length >= 3) {
+ func_args.push(arg3);
+ }
- case 40:
- return _context.delegateYield(evaluatePartialApplication(expr, input, environment), "t8", 41);
+ return func_args;
+ }
+ /**
+ * Create a map from an array of arguments
+ * @param {Array} [arr] - array to map over
+ * @param {Function} func - function to apply
+ * @returns {Array} Map array
+ */
+
+ function map(arr, func) {
+ var result, i, func_args, res;
+ return regeneratorRuntime.wrap(
+ function map$(_context6) {
+ while (1) {
+ switch ((_context6.prev = _context6.next)) {
+ case 0:
+ if (!(typeof arr === 'undefined')) {
+ _context6.next = 2;
+ break;
+ }
- case 41:
- result = _context.t8;
- return _context.abrupt("break", 48);
+ return _context6.abrupt('return', undefined);
- case 43:
- return _context.delegateYield(evaluateApplyExpression(expr, input, environment), "t9", 44);
+ case 2:
+ result = createSequence(); // do the map - iterate over the arrays, and invoke func
- case 44:
- result = _context.t9;
- return _context.abrupt("break", 48);
+ i = 0;
- case 46:
- result = evaluateTransformExpression(expr, input, environment);
- return _context.abrupt("break", 48);
+ case 4:
+ if (!(i < arr.length)) {
+ _context6.next = 12;
+ break;
+ }
- case 48:
- if (environment.async && (typeof result === 'undefined' || result === null || typeof result.then !== 'function')) {
- result = Promise.resolve(result);
- }
+ func_args = hofFuncArgs(func, arr[i], i, arr); // invoke func
- if (!(environment.async && typeof result.then === 'function' && expr.nextFunction && typeof result[expr.nextFunction] === 'function')) {
- _context.next = 52;
- break;
- }
+ return _context6.delegateYield(func.apply(this, func_args), 't0', 7);
- _context.next = 55;
- break;
+ case 7:
+ res = _context6.t0;
- case 52:
- _context.next = 54;
- return result;
+ if (typeof res !== 'undefined') {
+ result.push(res);
+ }
- case 54:
- result = _context.sent;
+ case 9:
+ i++;
+ _context6.next = 4;
+ break;
- case 55:
- if (!expr.hasOwnProperty('predicate')) {
- _context.next = 63;
- break;
- }
+ case 12:
+ return _context6.abrupt('return', result);
- ii = 0;
+ case 13:
+ case 'end':
+ return _context6.stop();
+ }
+ }
+ },
+ _marked6,
+ this
+ );
+ }
+ /**
+ * Create a map from an array of arguments
+ * @param {Array} [arr] - array to filter
+ * @param {Function} func - predicate function
+ * @returns {Array} Map array
+ */
+
+ function filter(arr, func) {
+ var result, i, entry, func_args, res;
+ return regeneratorRuntime.wrap(
+ function filter$(_context7) {
+ while (1) {
+ switch ((_context7.prev = _context7.next)) {
+ case 0:
+ if (!(typeof arr === 'undefined')) {
+ _context7.next = 2;
+ break;
+ }
- case 57:
- if (!(ii < expr.predicate.length)) {
- _context.next = 63;
- break;
- }
+ return _context7.abrupt('return', undefined);
- return _context.delegateYield(evaluateFilter(expr.predicate[ii].expr, result, environment), "t10", 59);
+ case 2:
+ result = createSequence();
+ i = 0;
- case 59:
- result = _context.t10;
+ case 4:
+ if (!(i < arr.length)) {
+ _context7.next = 13;
+ break;
+ }
- case 60:
- ii++;
- _context.next = 57;
- break;
+ entry = arr[i];
+ func_args = hofFuncArgs(func, entry, i, arr); // invoke func
- case 63:
- if (!(expr.type !== 'path' && expr.hasOwnProperty('group'))) {
- _context.next = 66;
- break;
- }
+ return _context7.delegateYield(func.apply(this, func_args), 't0', 8);
- return _context.delegateYield(evaluateGroupExpression(expr.group, result, environment), "t11", 65);
+ case 8:
+ res = _context7.t0;
- case 65:
- result = _context.t11;
+ if (_boolean(res)) {
+ result.push(entry);
+ }
- case 66:
- exitCallback = environment.lookup('__evaluate_exit');
+ case 10:
+ i++;
+ _context7.next = 4;
+ break;
- if (exitCallback) {
- exitCallback(expr, input, environment, result);
- }
+ case 13:
+ return _context7.abrupt('return', result);
- if (result && isSequence(result)) {
- if (expr.keepArray) {
- result.keepSingleton = true;
+ case 14:
+ case 'end':
+ return _context7.stop();
+ }
+ }
+ },
+ _marked7,
+ this
+ );
}
+ /**
+ * Given an array, find the single element matching a specified condition
+ * Throws an exception if the number of matching elements is not exactly one
+ * @param {Array} [arr] - array to filter
+ * @param {Function} [func] - predicate function
+ * @returns {*} Matching element
+ */
+
+ function single(arr, func) {
+ var hasFoundMatch, result, i, entry, positiveResult, func_args, res;
+ return regeneratorRuntime.wrap(
+ function single$(_context8) {
+ while (1) {
+ switch ((_context8.prev = _context8.next)) {
+ case 0:
+ if (!(typeof arr === 'undefined')) {
+ _context8.next = 2;
+ break;
+ }
- if (result.length === 0) {
- result = undefined;
- } else if (result.length === 1) {
- result = result.keepSingleton ? result : result[0];
- }
- }
+ return _context8.abrupt('return', undefined);
- return _context.abrupt("return", result);
+ case 2:
+ hasFoundMatch = false;
+ i = 0;
- case 70:
- case "end":
- return _context.stop();
- }
- }
- }, _marked);
- }
- /**
- * Evaluate path expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluatePath(expr, input, environment) {
- var inputSequence, resultSequence, isTupleStream, tupleBindings, ii, step;
- return regeneratorRuntime.wrap(function evaluatePath$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- // expr is an array of steps
- // if the first step is a variable reference ($...), including root reference ($$),
- // then the path is absolute rather than relative
- if (expr.steps[0].type === 'variable') {
- inputSequence = createSequence(input); // dummy singleton sequence for first (absolute) step
- } else if (Array.isArray(input)) {
- inputSequence = input;
- } else {
- // if input is not an array, make it so
- inputSequence = createSequence(input);
- }
+ case 4:
+ if (!(i < arr.length)) {
+ _context8.next = 22;
+ break;
+ }
+
+ entry = arr[i];
+ positiveResult = true;
- isTupleStream = false;
- tupleBindings = undefined; // evaluate each step in turn
+ if (!(typeof func !== 'undefined')) {
+ _context8.next = 12;
+ break;
+ }
- ii = 0;
+ func_args = hofFuncArgs(func, entry, i, arr); // invoke func
- case 4:
- if (!(ii < expr.steps.length)) {
- _context2.next = 25;
- break;
- }
+ return _context8.delegateYield(func.apply(this, func_args), 't0', 10);
- step = expr.steps[ii];
+ case 10:
+ res = _context8.t0;
+ positiveResult = _boolean(res);
- if (step.tuple) {
- isTupleStream = true;
- } // if the first step is an explicit array constructor, then just evaluate that (i.e. don't iterate over a context array)
+ case 12:
+ if (!positiveResult) {
+ _context8.next = 19;
+ break;
+ }
+ if (hasFoundMatch) {
+ _context8.next = 18;
+ break;
+ }
- if (!(ii === 0 && step.consarray)) {
- _context2.next = 12;
- break;
- }
+ result = entry;
+ hasFoundMatch = true;
+ _context8.next = 19;
+ break;
+
+ case 18:
+ throw {
+ stack: new Error().stack,
+ code: 'D3138',
+ index: i,
+ };
+
+ case 19:
+ i++;
+ _context8.next = 4;
+ break;
+
+ case 22:
+ if (hasFoundMatch) {
+ _context8.next = 24;
+ break;
+ }
- return _context2.delegateYield(_evaluate(step, inputSequence, environment), "t0", 9);
+ throw {
+ stack: new Error().stack,
+ code: 'D3139',
+ };
- case 9:
- resultSequence = _context2.t0;
- _context2.next = 19;
- break;
+ case 24:
+ return _context8.abrupt('return', result);
- case 12:
- if (!isTupleStream) {
- _context2.next = 17;
- break;
- }
+ case 25:
+ case 'end':
+ return _context8.stop();
+ }
+ }
+ },
+ _marked8,
+ this
+ );
+ }
+ /**
+ * Convolves (zips) each value from a set of arrays
+ * @param {Array} [args] - arrays to zip
+ * @returns {Array} Zipped array
+ */
+
+ function zip() {
+ // this can take a variable number of arguments
+ var result = [];
+ var args = Array.prototype.slice.call(arguments); // length of the shortest array
+
+ var length = Math.min.apply(
+ Math,
+ args.map(function (arg) {
+ if (Array.isArray(arg)) {
+ return arg.length;
+ }
+
+ return 0;
+ })
+ );
- return _context2.delegateYield(evaluateTupleStep(step, inputSequence, tupleBindings, environment), "t1", 14);
+ for (var i = 0; i < length; i++) {
+ var tuple = args.map(function (arg) {
+ return arg[i];
+ });
+ result.push(tuple);
+ }
+
+ return result;
+ }
+ /**
+ * Fold left function
+ * @param {Array} sequence - Sequence
+ * @param {Function} func - Function
+ * @param {Object} init - Initial value
+ * @returns {*} Result
+ */
+
+ function foldLeft(sequence, func, init) {
+ var result, arity, index, args;
+ return regeneratorRuntime.wrap(
+ function foldLeft$(_context9) {
+ while (1) {
+ switch ((_context9.prev = _context9.next)) {
+ case 0:
+ if (!(typeof sequence === 'undefined')) {
+ _context9.next = 2;
+ break;
+ }
- case 14:
- tupleBindings = _context2.t1;
- _context2.next = 19;
- break;
+ return _context9.abrupt('return', undefined);
- case 17:
- return _context2.delegateYield(evaluateStep(step, inputSequence, environment, ii === expr.steps.length - 1), "t2", 18);
+ case 2:
+ arity = getFunctionArity(func);
- case 18:
- resultSequence = _context2.t2;
+ if (!(arity < 2)) {
+ _context9.next = 5;
+ break;
+ }
- case 19:
- if (!(!isTupleStream && (typeof resultSequence === 'undefined' || resultSequence.length === 0))) {
- _context2.next = 21;
- break;
- }
+ throw {
+ stack: new Error().stack,
+ code: 'D3050',
+ index: 1,
+ };
- return _context2.abrupt("break", 25);
+ case 5:
+ if (typeof init === 'undefined' && sequence.length > 0) {
+ result = sequence[0];
+ index = 1;
+ } else {
+ result = init;
+ index = 0;
+ }
- case 21:
- if (typeof step.focus === 'undefined') {
- inputSequence = resultSequence;
- }
+ case 6:
+ if (!(index < sequence.length)) {
+ _context9.next = 15;
+ break;
+ }
- case 22:
- ii++;
- _context2.next = 4;
- break;
+ args = [result, sequence[index]];
- case 25:
- if (isTupleStream) {
- resultSequence = createSequence();
+ if (arity >= 3) {
+ args.push(index);
+ }
- for (ii = 0; ii < tupleBindings.length; ii++) {
- resultSequence.push(tupleBindings[ii]['@']);
- }
- }
+ if (arity >= 4) {
+ args.push(sequence);
+ }
- if (expr.keepSingletonArray) {
- resultSequence.keepSingleton = true;
- }
+ return _context9.delegateYield(func.apply(this, args), 't0', 11);
- if (!expr.hasOwnProperty('group')) {
- _context2.next = 30;
- break;
- }
+ case 11:
+ result = _context9.t0;
+ index++;
+ _context9.next = 6;
+ break;
- return _context2.delegateYield(evaluateGroupExpression(expr.group, isTupleStream ? tupleBindings : resultSequence, environment), "t3", 29);
+ case 15:
+ return _context9.abrupt('return', result);
- case 29:
- resultSequence = _context2.t3;
+ case 16:
+ case 'end':
+ return _context9.stop();
+ }
+ }
+ },
+ _marked9,
+ this
+ );
+ }
+ /**
+ * Return keys for an object
+ * @param {Object} arg - Object
+ * @returns {Array} Array of keys
+ */
+
+ function keys(arg) {
+ var result = createSequence();
+
+ if (Array.isArray(arg)) {
+ // merge the keys of all of the items in the array
+ var merge = {};
+ arg.forEach(function (item) {
+ var allkeys = keys(item);
+ allkeys.forEach(function (key) {
+ merge[key] = true;
+ });
+ });
+ result = keys(merge);
+ } else if (arg !== null && _typeof(arg) === 'object' && !isLambda(arg)) {
+ Object.keys(arg).forEach(function (key) {
+ return result.push(key);
+ });
+ }
- case 30:
- return _context2.abrupt("return", resultSequence);
+ return result;
+ }
+ /**
+ * Return value from an object for a given key
+ * @param {Object} input - Object/Array
+ * @param {String} key - Key in object
+ * @returns {*} Value of key in object
+ */
- case 31:
- case "end":
- return _context2.stop();
- }
- }
- }, _marked2);
- }
+ function lookup(input, key) {
+ // lookup the 'name' item in the input
+ var result;
- function createFrameFromTuple(environment, tuple) {
- var frame = createFrame(environment);
+ if (Array.isArray(input)) {
+ result = createSequence();
- for (var prop in tuple) {
- frame.bind(prop, tuple[prop]);
- }
+ for (var ii = 0; ii < input.length; ii++) {
+ var res = lookup(input[ii], key);
- return frame;
- }
- /**
- * Evaluate a step within a path
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @param {boolean} lastStep - flag the last step in a path
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateStep(expr, input, environment, lastStep) {
- var result, ii, res, ss, resultSequence;
- return regeneratorRuntime.wrap(function evaluateStep$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (!(expr.type === 'sort')) {
- _context3.next = 7;
- break;
- }
+ if (typeof res !== 'undefined') {
+ if (Array.isArray(res)) {
+ var _result;
- return _context3.delegateYield(evaluateSortExpression(expr, input, environment), "t0", 2);
+ (_result = result).push.apply(_result, _toConsumableArray(res));
+ } else {
+ result.push(res);
+ }
+ }
+ }
+ } else if (input !== null && _typeof(input) === 'object') {
+ result = input[key];
+ }
- case 2:
- result = _context3.t0;
+ return result;
+ }
+ /**
+ * Append second argument to first
+ * @param {Array|Object} arg1 - First argument
+ * @param {Array|Object} arg2 - Second argument
+ * @returns {*} Appended arguments
+ */
+
+ function append(arg1, arg2) {
+ // disregard undefined args
+ if (typeof arg1 === 'undefined') {
+ return arg2;
+ }
- if (!expr.stages) {
- _context3.next = 6;
- break;
- }
+ if (typeof arg2 === 'undefined') {
+ return arg1;
+ } // if either argument is not an array, make it so
- return _context3.delegateYield(evaluateStages(expr.stages, result, environment), "t1", 5);
+ if (!Array.isArray(arg1)) {
+ arg1 = createSequence(arg1);
+ }
- case 5:
- result = _context3.t1;
+ if (!Array.isArray(arg2)) {
+ arg2 = [arg2];
+ }
- case 6:
- return _context3.abrupt("return", result);
+ return arg1.concat(arg2);
+ }
+ /**
+ * Determines if the argument is undefined
+ * @param {*} arg - argument
+ * @returns {boolean} False if argument undefined, otherwise true
+ */
+
+ function exists(arg) {
+ if (typeof arg === 'undefined') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ /**
+ * Splits an object into an array of object with one property each
+ * @param {*} arg - the object to split
+ * @returns {*} - the array
+ */
+
+ function spread(arg) {
+ var result = createSequence();
+
+ if (Array.isArray(arg)) {
+ // spread all of the items in the array
+ arg.forEach(function (item) {
+ result = append(result, spread(item));
+ });
+ } else if (arg !== null && _typeof(arg) === 'object' && !isLambda(arg)) {
+ for (var key in arg) {
+ var obj = {};
+ obj[key] = arg[key];
+ result.push(obj);
+ }
+ } else {
+ result = arg;
+ }
- case 7:
- result = createSequence();
- ii = 0;
+ return result;
+ }
+ /**
+ * Merges an array of objects into a single object. Duplicate properties are
+ * overridden by entries later in the array
+ * @param {*} arg - the objects to merge
+ * @returns {*} - the object
+ */
+
+ function merge(arg) {
+ // undefined inputs always return undefined
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- case 9:
- if (!(ii < input.length)) {
- _context3.next = 24;
- break;
- }
+ var result = {};
+ arg.forEach(function (obj) {
+ for (var prop in obj) {
+ result[prop] = obj[prop];
+ }
+ });
+ return result;
+ }
+ /**
+ * Reverses the order of items in an array
+ * @param {Array} arr - the array to reverse
+ * @returns {Array} - the reversed array
+ */
+
+ function reverse(arr) {
+ // undefined inputs always return undefined
+ if (typeof arr === 'undefined') {
+ return undefined;
+ }
- return _context3.delegateYield(_evaluate(expr, input[ii], environment), "t2", 11);
+ if (arr.length <= 1) {
+ return arr;
+ }
- case 11:
- res = _context3.t2;
+ var length = arr.length;
+ var result = new Array(length);
- if (!expr.stages) {
- _context3.next = 20;
- break;
- }
+ for (var i = 0; i < length; i++) {
+ result[length - i - 1] = arr[i];
+ }
- ss = 0;
+ return result;
+ }
+ /**
+ *
+ * @param {*} obj - the input object to iterate over
+ * @param {*} func - the function to apply to each key/value pair
+ * @returns {Array} - the resultant array
+ */
+
+ function each(obj, func) {
+ var result, key, func_args, val;
+ return regeneratorRuntime.wrap(
+ function each$(_context10) {
+ while (1) {
+ switch ((_context10.prev = _context10.next)) {
+ case 0:
+ result = createSequence();
+ _context10.t0 = regeneratorRuntime.keys(obj);
+
+ case 2:
+ if ((_context10.t1 = _context10.t0()).done) {
+ _context10.next = 10;
+ break;
+ }
- case 14:
- if (!(ss < expr.stages.length)) {
- _context3.next = 20;
- break;
- }
+ key = _context10.t1.value;
+ func_args = hofFuncArgs(func, obj[key], key, obj); // invoke func
- return _context3.delegateYield(evaluateFilter(expr.stages[ss].expr, res, environment), "t3", 16);
+ return _context10.delegateYield(func.apply(this, func_args), 't2', 6);
- case 16:
- res = _context3.t3;
+ case 6:
+ val = _context10.t2;
- case 17:
- ss++;
- _context3.next = 14;
- break;
+ if (typeof val !== 'undefined') {
+ result.push(val);
+ }
- case 20:
- if (typeof res !== 'undefined') {
- result.push(res);
- }
+ _context10.next = 2;
+ break;
- case 21:
- ii++;
- _context3.next = 9;
- break;
+ case 10:
+ return _context10.abrupt('return', result);
- case 24:
- resultSequence = createSequence();
+ case 11:
+ case 'end':
+ return _context10.stop();
+ }
+ }
+ },
+ _marked10,
+ this
+ );
+ }
+ /**
+ *
+ * @param {string} [message] - the message to attach to the error
+ * @throws custom error with code 'D3137'
+ */
- if (lastStep && result.length === 1 && Array.isArray(result[0]) && !isSequence(result[0])) {
- resultSequence = result[0];
- } else {
- // flatten the sequence
- result.forEach(function (res) {
- if (!Array.isArray(res) || res.cons) {
- // it's not an array - just push into the result sequence
- resultSequence.push(res);
- } else {
- // res is a sequence - flatten it into the parent sequence
- Array.prototype.push.apply(resultSequence, res);
+ function error(message) {
+ throw {
+ code: 'D3137',
+ stack: new Error().stack,
+ message: message || '$error() function evaluated',
+ };
+ }
+ /**
+ *
+ * @param {boolean} condition - the condition to evaluate
+ * @param {string} [message] - the message to attach to the error
+ * @throws custom error with code 'D3137'
+ * @returns {undefined}
+ */
+
+ function assert(condition, message) {
+ if (!condition) {
+ throw {
+ code: 'D3141',
+ stack: new Error().stack,
+ message: message || '$assert() statement failed',
+ };
}
- });
- }
-
- return _context3.abrupt("return", resultSequence);
- case 27:
- case "end":
- return _context3.stop();
- }
- }
- }, _marked3);
- }
+ return undefined;
+ }
+ /**
+ * Implements the merge sort (stable) with optional comparator function
+ *
+ * @param {Array} arr - the array to sort
+ * @param {*} comparator - comparator function
+ * @returns {Array} - sorted array
+ */
+
+ function sort(arr, comparator) {
+ var comp, merge, msort, result;
+ return regeneratorRuntime.wrap(function sort$(_context15) {
+ while (1) {
+ switch ((_context15.prev = _context15.next)) {
+ case 0:
+ if (!(typeof arr === 'undefined')) {
+ _context15.next = 2;
+ break;
+ }
- function evaluateStages(stages, input, environment) {
- var result, ss, stage, ee, tuple;
- return regeneratorRuntime.wrap(function evaluateStages$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- result = input;
- ss = 0;
-
- case 2:
- if (!(ss < stages.length)) {
- _context4.next = 15;
- break;
- }
+ return _context15.abrupt('return', undefined);
- stage = stages[ss];
- _context4.t0 = stage.type;
- _context4.next = _context4.t0 === 'filter' ? 7 : _context4.t0 === 'index' ? 10 : 12;
- break;
+ case 2:
+ if (!(arr.length <= 1)) {
+ _context15.next = 4;
+ break;
+ }
- case 7:
- return _context4.delegateYield(evaluateFilter(stage.expr, result, environment), "t1", 8);
+ return _context15.abrupt('return', arr);
- case 8:
- result = _context4.t1;
- return _context4.abrupt("break", 12);
+ case 4:
+ if (!(typeof comparator === 'undefined')) {
+ _context15.next = 10;
+ break;
+ }
- case 10:
- for (ee = 0; ee < result.length; ee++) {
- tuple = result[ee];
- tuple[stage.value] = ee;
- }
+ if (!(!isArrayOfNumbers(arr) && !isArrayOfStrings(arr))) {
+ _context15.next = 7;
+ break;
+ }
- return _context4.abrupt("break", 12);
+ throw {
+ stack: new Error().stack,
+ code: 'D3070',
+ index: 1,
+ };
+
+ case 7:
+ comp =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function comp(a, b) {
+ return regeneratorRuntime.wrap(function comp$(_context11) {
+ while (1) {
+ switch ((_context11.prev = _context11.next)) {
+ case 0:
+ return _context11.abrupt('return', a > b);
+
+ case 1:
+ case 'end':
+ return _context11.stop();
+ }
+ }
+ }, comp);
+ });
+ _context15.next = 11;
+ break;
- case 12:
- ss++;
- _context4.next = 2;
- break;
+ case 10:
+ // for internal usage of functionSort (i.e. order-by syntax)
+ comp = comparator;
+
+ case 11:
+ merge =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function merge(l, r) {
+ var merge_iter, merged;
+ return regeneratorRuntime.wrap(function merge$(_context13) {
+ while (1) {
+ switch ((_context13.prev = _context13.next)) {
+ case 0:
+ merge_iter =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function merge_iter(result, left, right) {
+ return regeneratorRuntime.wrap(function merge_iter$(_context12) {
+ while (1) {
+ switch ((_context12.prev = _context12.next)) {
+ case 0:
+ if (!(left.length === 0)) {
+ _context12.next = 4;
+ break;
+ }
+
+ Array.prototype.push.apply(result, right);
+ _context12.next = 16;
+ break;
+
+ case 4:
+ if (!(right.length === 0)) {
+ _context12.next = 8;
+ break;
+ }
+
+ Array.prototype.push.apply(result, left);
+ _context12.next = 16;
+ break;
+
+ case 8:
+ return _context12.delegateYield(comp(left[0], right[0]), 't0', 9);
+
+ case 9:
+ if (!_context12.t0) {
+ _context12.next = 14;
+ break;
+ }
+
+ // invoke the comparator function
+ // if it returns true - swap left and right
+ result.push(right[0]);
+ return _context12.delegateYield(
+ merge_iter(result, left, right.slice(1)),
+ 't1',
+ 12
+ );
+
+ case 12:
+ _context12.next = 16;
+ break;
+
+ case 14:
+ // otherwise keep the same order
+ result.push(left[0]);
+ return _context12.delegateYield(
+ merge_iter(result, left.slice(1), right),
+ 't2',
+ 16
+ );
+
+ case 16:
+ case 'end':
+ return _context12.stop();
+ }
+ }
+ }, merge_iter);
+ });
+ merged = [];
+ return _context13.delegateYield(merge_iter(merged, l, r), 't0', 3);
+
+ case 3:
+ return _context13.abrupt('return', merged);
+
+ case 4:
+ case 'end':
+ return _context13.stop();
+ }
+ }
+ }, merge);
+ });
+ msort =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function msort(array) {
+ var middle, left, right;
+ return regeneratorRuntime.wrap(function msort$(_context14) {
+ while (1) {
+ switch ((_context14.prev = _context14.next)) {
+ case 0:
+ if (!(!Array.isArray(array) || array.length <= 1)) {
+ _context14.next = 4;
+ break;
+ }
+
+ return _context14.abrupt('return', array);
+
+ case 4:
+ middle = Math.floor(array.length / 2);
+ left = array.slice(0, middle);
+ right = array.slice(middle);
+ return _context14.delegateYield(msort(left), 't0', 8);
+
+ case 8:
+ left = _context14.t0;
+ return _context14.delegateYield(msort(right), 't1', 10);
+
+ case 10:
+ right = _context14.t1;
+ return _context14.delegateYield(merge(left, right), 't2', 12);
+
+ case 12:
+ return _context14.abrupt('return', _context14.t2);
+
+ case 13:
+ case 'end':
+ return _context14.stop();
+ }
+ }
+ }, msort);
+ });
+ return _context15.delegateYield(msort(arr), 't0', 14);
- case 15:
- return _context4.abrupt("return", result);
+ case 14:
+ result = _context15.t0;
+ return _context15.abrupt('return', result);
- case 16:
- case "end":
- return _context4.stop();
- }
- }
- }, _marked4);
- }
- /**
- * Evaluate a step within a path
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} tupleBindings - The tuple stream
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateTupleStep(expr, input, tupleBindings, environment) {
- var result, sorted, ss, tuple, stepEnv, ee, res, bb;
- return regeneratorRuntime.wrap(function evaluateTupleStep$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (!(expr.type === 'sort')) {
- _context5.next = 15;
- break;
- }
+ case 16:
+ case 'end':
+ return _context15.stop();
+ }
+ }
+ }, _marked11);
+ }
+ /**
+ * Randomly shuffles the contents of an array
+ * @param {Array} arr - the input array
+ * @returns {Array} the shuffled array
+ */
+
+ function shuffle(arr) {
+ // undefined inputs always return undefined
+ if (typeof arr === 'undefined') {
+ return undefined;
+ }
- if (!tupleBindings) {
- _context5.next = 6;
- break;
- }
+ if (arr.length <= 1) {
+ return arr;
+ } // shuffle using the 'inside-out' variant of the Fisher-Yates algorithm
- return _context5.delegateYield(evaluateSortExpression(expr, tupleBindings, environment), "t0", 3);
+ var result = new Array(arr.length);
- case 3:
- result = _context5.t0;
- _context5.next = 11;
- break;
+ for (var i = 0; i < arr.length; i++) {
+ var j = Math.floor(Math.random() * (i + 1)); // random integer such that 0 ≤ j ≤ i
- case 6:
- return _context5.delegateYield(evaluateSortExpression(expr, input, environment), "t1", 7);
+ if (i !== j) {
+ result[i] = result[j];
+ }
- case 7:
- sorted = _context5.t1;
- result = createSequence();
- result.tupleStream = true;
+ result[j] = arr[i];
+ }
- for (ss = 0; ss < sorted.length; ss++) {
- tuple = {
- '@': sorted[ss]
- };
- tuple[expr.index] = ss;
- result.push(tuple);
- }
+ return result;
+ }
+ /**
+ * Returns the values that appear in a sequence, with duplicates eliminated.
+ * @param {Array} arr - An array or sequence of values
+ * @returns {Array} - sequence of distinct values
+ */
+
+ function distinct(arr) {
+ // undefined inputs always return undefined
+ if (typeof arr === 'undefined') {
+ return undefined;
+ }
- case 11:
- if (!expr.stages) {
- _context5.next = 14;
- break;
- }
+ if (!Array.isArray(arr) || arr.length <= 1) {
+ return arr;
+ }
- return _context5.delegateYield(evaluateStages(expr.stages, result, environment), "t2", 13);
+ var results = isSequence(arr) ? createSequence() : [];
- case 13:
- result = _context5.t2;
+ for (var ii = 0; ii < arr.length; ii++) {
+ var value = arr[ii]; // is this value already in the result sequence?
- case 14:
- return _context5.abrupt("return", result);
+ var includes = false;
- case 15:
- result = createSequence();
- result.tupleStream = true;
- stepEnv = environment;
+ for (var jj = 0; jj < results.length; jj++) {
+ if (deepEquals(value, results[jj])) {
+ includes = true;
+ break;
+ }
+ }
- if (tupleBindings === undefined) {
- tupleBindings = [{
- '@': input
- }];
- }
+ if (!includes) {
+ results.push(value);
+ }
+ }
- ee = 0;
+ return results;
+ }
+ /**
+ * Applies a predicate function to each key/value pair in an object, and returns an object containing
+ * only the key/value pairs that passed the predicate
+ *
+ * @param {object} arg - the object to be sifted
+ * @param {object} func - the predicate function (lambda or native)
+ * @returns {object} - sifted object
+ */
+
+ function sift(arg, func) {
+ var result, item, entry, func_args, res;
+ return regeneratorRuntime.wrap(
+ function sift$(_context16) {
+ while (1) {
+ switch ((_context16.prev = _context16.next)) {
+ case 0:
+ result = {};
+ _context16.t0 = regeneratorRuntime.keys(arg);
+
+ case 2:
+ if ((_context16.t1 = _context16.t0()).done) {
+ _context16.next = 11;
+ break;
+ }
- case 20:
- if (!(ee < tupleBindings.length)) {
- _context5.next = 28;
- break;
- }
+ item = _context16.t1.value;
+ entry = arg[item];
+ func_args = hofFuncArgs(func, entry, item, arg); // invoke func
- stepEnv = createFrameFromTuple(environment, tupleBindings[ee]);
- return _context5.delegateYield(_evaluate(expr, tupleBindings[ee]['@'], stepEnv), "t3", 23);
+ return _context16.delegateYield(func.apply(this, func_args), 't2', 7);
- case 23:
- res = _context5.t3;
+ case 7:
+ res = _context16.t2;
- // res is the binding sequence for the output tuple stream
- if (typeof res !== 'undefined') {
- if (!Array.isArray(res)) {
- res = [res];
- }
+ if (_boolean(res)) {
+ result[item] = entry;
+ }
- for (bb = 0; bb < res.length; bb++) {
- tuple = {};
- Object.assign(tuple, tupleBindings[ee]);
+ _context16.next = 2;
+ break;
- if (expr.focus) {
- tuple[expr.focus] = res[bb];
- tuple['@'] = input;
- } else {
- tuple['@'] = res[bb];
- }
+ case 11:
+ // empty objects should be changed to undefined
+ if (Object.keys(result).length === 0) {
+ result = undefined;
+ }
- if (expr.index) {
- tuple[expr.index] = bb;
- }
+ return _context16.abrupt('return', result);
- result.push(tuple);
+ case 13:
+ case 'end':
+ return _context16.stop();
+ }
+ }
+ },
+ _marked12,
+ this
+ );
}
+
+ return {
+ sum: sum,
+ count: count,
+ max: max,
+ min: min,
+ average: average,
+ string: string,
+ substring: substring,
+ substringBefore: substringBefore,
+ substringAfter: substringAfter,
+ lowercase: lowercase,
+ uppercase: uppercase,
+ length: length,
+ trim: trim,
+ pad: pad,
+ match: match,
+ contains: contains,
+ replace: replace,
+ split: split,
+ join: join,
+ formatNumber: formatNumber,
+ formatBase: formatBase,
+ number: number,
+ floor: floor,
+ ceil: ceil,
+ round: round,
+ abs: abs,
+ sqrt: sqrt,
+ power: power,
+ random: random,
+ boolean: _boolean,
+ not: not,
+ map: map,
+ zip: zip,
+ filter: filter,
+ single: single,
+ foldLeft: foldLeft,
+ sift: sift,
+ keys: keys,
+ lookup: lookup,
+ append: append,
+ exists: exists,
+ spread: spread,
+ merge: merge,
+ reverse: reverse,
+ each: each,
+ error: error,
+ assert: assert,
+ sort: sort,
+ shuffle: shuffle,
+ distinct: distinct,
+ base64encode: base64encode,
+ base64decode: base64decode,
+ encodeUrlComponent: encodeUrlComponent,
+ encodeUrl: encodeUrl,
+ decodeUrlComponent: decodeUrlComponent,
+ decodeUrl: decodeUrl,
+ };
+ })();
+
+ module.exports = functions;
+ }.call(
+ this,
+ typeof global !== 'undefined'
+ ? global
+ : typeof self !== 'undefined'
+ ? self
+ : typeof window !== 'undefined'
+ ? window
+ : {}
+ ));
+ },
+ { './utils': 6 },
+ ],
+ 3: [
+ function (require, module, exports) {
+ 'use strict';
+
+ function _typeof(obj) {
+ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
+ _typeof = function _typeof(obj) {
+ return typeof obj;
+ };
+ } else {
+ _typeof = function _typeof(obj) {
+ return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
+ ? 'symbol'
+ : typeof obj;
+ };
}
+ return _typeof(obj);
+ }
- case 25:
- ee++;
- _context5.next = 20;
- break;
+ /**
+ * © Copyright IBM Corp. 2016, 2017 All Rights Reserved
+ * Project name: JSONata
+ * This project is licensed under the MIT License, see LICENSE
+ */
+
+ /**
+ * @module JSONata
+ * @description JSON query and transformation language
+ */
+ var datetime = require('./datetime');
+
+ var fn = require('./functions');
+
+ var utils = require('./utils');
+
+ var parser = require('./parser');
+
+ var parseSignature = require('./signature');
+ /**
+ * jsonata
+ * @function
+ * @param {Object} expr - JSONata expression
+ * @returns {{evaluate: evaluate, assign: assign}} Evaluated expression
+ */
+
+ var jsonata = (function () {
+ 'use strict';
+
+ var _marked =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(_evaluate),
+ _marked2 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluatePath),
+ _marked3 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateStep),
+ _marked4 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateStages),
+ _marked5 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateTupleStep),
+ _marked6 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateFilter),
+ _marked7 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateBinary),
+ _marked8 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateUnary),
+ _marked9 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateGroupExpression),
+ _marked10 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateBindExpression),
+ _marked11 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateCondition),
+ _marked12 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateBlock),
+ _marked13 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateSortExpression),
+ _marked14 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateApplyExpression),
+ _marked15 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluateFunction),
+ _marked16 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(apply),
+ _marked17 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(applyInner),
+ _marked18 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(evaluatePartialApplication),
+ _marked19 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(applyProcedure),
+ _marked20 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(applyNativeFunction),
+ _marked21 =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(functionEval);
+
+ var isNumeric = utils.isNumeric;
+ var isArrayOfStrings = utils.isArrayOfStrings;
+ var isArrayOfNumbers = utils.isArrayOfNumbers;
+ var createSequence = utils.createSequence;
+ var isSequence = utils.isSequence;
+ var isFunction = utils.isFunction;
+ var isLambda = utils.isLambda;
+ var isIterable = utils.isIterable;
+ var getFunctionArity = utils.getFunctionArity;
+ var isDeepEqual = utils.isDeepEqual; // Start of Evaluator code
+
+ var staticFrame = createFrame(null);
+ /**
+ * Evaluate expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function _evaluate(expr, input, environment) {
+ var result, entryCallback, ii, exitCallback;
+ return regeneratorRuntime.wrap(function evaluate$(_context) {
+ while (1) {
+ switch ((_context.prev = _context.next)) {
+ case 0:
+ entryCallback = environment.lookup('__evaluate_entry');
- case 28:
- if (!expr.stages) {
- _context5.next = 31;
- break;
- }
+ if (entryCallback) {
+ entryCallback(expr, input, environment);
+ }
- return _context5.delegateYield(evaluateStages(expr.stages, result, environment), "t4", 30);
+ _context.t0 = expr.type;
+ _context.next =
+ _context.t0 === 'path'
+ ? 5
+ : _context.t0 === 'binary'
+ ? 8
+ : _context.t0 === 'unary'
+ ? 11
+ : _context.t0 === 'name'
+ ? 14
+ : _context.t0 === 'string'
+ ? 16
+ : _context.t0 === 'number'
+ ? 16
+ : _context.t0 === 'value'
+ ? 16
+ : _context.t0 === 'wildcard'
+ ? 18
+ : _context.t0 === 'descendant'
+ ? 20
+ : _context.t0 === 'condition'
+ ? 22
+ : _context.t0 === 'block'
+ ? 25
+ : _context.t0 === 'bind'
+ ? 28
+ : _context.t0 === 'regex'
+ ? 31
+ : _context.t0 === 'function'
+ ? 33
+ : _context.t0 === 'variable'
+ ? 36
+ : _context.t0 === 'lambda'
+ ? 38
+ : _context.t0 === 'partial'
+ ? 40
+ : _context.t0 === 'apply'
+ ? 43
+ : _context.t0 === 'transform'
+ ? 46
+ : 48;
+ break;
- case 30:
- result = _context5.t4;
+ case 5:
+ return _context.delegateYield(evaluatePath(expr, input, environment), 't1', 6);
- case 31:
- return _context5.abrupt("return", result);
+ case 6:
+ result = _context.t1;
+ return _context.abrupt('break', 48);
- case 32:
- case "end":
- return _context5.stop();
- }
- }
- }, _marked5);
- }
- /**
- * Apply filter predicate to input data
- * @param {Object} predicate - filter expression
- * @param {Object} input - Input data to apply predicates against
- * @param {Object} environment - Environment
- * @returns {*} Result after applying predicates
- */
-
-
- function evaluateFilter(predicate, input, environment) {
- var results, index, item, context, env, res;
- return regeneratorRuntime.wrap(function evaluateFilter$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- results = createSequence();
-
- if (input && input.tupleStream) {
- results.tupleStream = true;
- }
+ case 8:
+ return _context.delegateYield(evaluateBinary(expr, input, environment), 't2', 9);
- if (!Array.isArray(input)) {
- input = createSequence(input);
- }
+ case 9:
+ result = _context.t2;
+ return _context.abrupt('break', 48);
- if (!(predicate.type === 'number')) {
- _context6.next = 10;
- break;
- }
+ case 11:
+ return _context.delegateYield(evaluateUnary(expr, input, environment), 't3', 12);
- index = Math.floor(predicate.value); // round it down
+ case 12:
+ result = _context.t3;
+ return _context.abrupt('break', 48);
- if (index < 0) {
- // count in from end of array
- index = input.length + index;
- }
+ case 14:
+ result = evaluateName(expr, input, environment);
+ return _context.abrupt('break', 48);
- item = input[index];
+ case 16:
+ result = evaluateLiteral(expr, input, environment);
+ return _context.abrupt('break', 48);
- if (typeof item !== 'undefined') {
- if (Array.isArray(item)) {
- results = item;
- } else {
- results.push(item);
- }
- }
+ case 18:
+ result = evaluateWildcard(expr, input, environment);
+ return _context.abrupt('break', 48);
- _context6.next = 23;
- break;
+ case 20:
+ result = evaluateDescendants(expr, input, environment);
+ return _context.abrupt('break', 48);
- case 10:
- index = 0;
+ case 22:
+ return _context.delegateYield(evaluateCondition(expr, input, environment), 't4', 23);
- case 11:
- if (!(index < input.length)) {
- _context6.next = 23;
- break;
- }
+ case 23:
+ result = _context.t4;
+ return _context.abrupt('break', 48);
- item = input[index];
- context = item;
- env = environment;
+ case 25:
+ return _context.delegateYield(evaluateBlock(expr, input, environment), 't5', 26);
- if (input.tupleStream) {
- context = item['@'];
- env = createFrameFromTuple(environment, item);
- }
+ case 26:
+ result = _context.t5;
+ return _context.abrupt('break', 48);
- return _context6.delegateYield(_evaluate(predicate, context, env), "t0", 17);
+ case 28:
+ return _context.delegateYield(evaluateBindExpression(expr, input, environment), 't6', 29);
- case 17:
- res = _context6.t0;
+ case 29:
+ result = _context.t6;
+ return _context.abrupt('break', 48);
- if (isNumeric(res)) {
- res = [res];
- }
+ case 31:
+ result = evaluateRegex(expr, input, environment);
+ return _context.abrupt('break', 48);
- if (isArrayOfNumbers(res)) {
- res.forEach(function (ires) {
- // round it down
- var ii = Math.floor(ires);
+ case 33:
+ return _context.delegateYield(evaluateFunction(expr, input, environment), 't7', 34);
- if (ii < 0) {
- // count in from end of array
- ii = input.length + ii;
- }
+ case 34:
+ result = _context.t7;
+ return _context.abrupt('break', 48);
- if (ii === index) {
- results.push(item);
- }
- });
- } else if (fn["boolean"](res)) {
- // truthy
- results.push(item);
- }
+ case 36:
+ result = evaluateVariable(expr, input, environment);
+ return _context.abrupt('break', 48);
- case 20:
- index++;
- _context6.next = 11;
- break;
+ case 38:
+ result = evaluateLambda(expr, input, environment);
+ return _context.abrupt('break', 48);
- case 23:
- return _context6.abrupt("return", results);
+ case 40:
+ return _context.delegateYield(evaluatePartialApplication(expr, input, environment), 't8', 41);
- case 24:
- case "end":
- return _context6.stop();
- }
- }
- }, _marked6);
- }
- /**
- * Evaluate binary expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateBinary(expr, input, environment) {
- var result, lhs, rhs, op;
- return regeneratorRuntime.wrap(function evaluateBinary$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- return _context7.delegateYield(_evaluate(expr.lhs, input, environment), "t0", 1);
-
- case 1:
- lhs = _context7.t0;
- return _context7.delegateYield(_evaluate(expr.rhs, input, environment), "t1", 3);
-
- case 3:
- rhs = _context7.t1;
- op = expr.value;
- _context7.prev = 5;
- _context7.t2 = op;
- _context7.next = _context7.t2 === '+' ? 9 : _context7.t2 === '-' ? 9 : _context7.t2 === '*' ? 9 : _context7.t2 === '/' ? 9 : _context7.t2 === '%' ? 9 : _context7.t2 === '=' ? 11 : _context7.t2 === '!=' ? 11 : _context7.t2 === '<' ? 13 : _context7.t2 === '<=' ? 13 : _context7.t2 === '>' ? 13 : _context7.t2 === '>=' ? 13 : _context7.t2 === '&' ? 15 : _context7.t2 === 'and' ? 17 : _context7.t2 === 'or' ? 17 : _context7.t2 === '..' ? 19 : _context7.t2 === 'in' ? 21 : 23;
- break;
-
- case 9:
- result = evaluateNumericExpression(lhs, rhs, op);
- return _context7.abrupt("break", 23);
-
- case 11:
- result = evaluateEqualityExpression(lhs, rhs, op);
- return _context7.abrupt("break", 23);
-
- case 13:
- result = evaluateComparisonExpression(lhs, rhs, op);
- return _context7.abrupt("break", 23);
-
- case 15:
- result = evaluateStringConcat(lhs, rhs);
- return _context7.abrupt("break", 23);
-
- case 17:
- result = evaluateBooleanExpression(lhs, rhs, op);
- return _context7.abrupt("break", 23);
-
- case 19:
- result = evaluateRangeExpression(lhs, rhs);
- return _context7.abrupt("break", 23);
-
- case 21:
- result = evaluateIncludesExpression(lhs, rhs);
- return _context7.abrupt("break", 23);
-
- case 23:
- _context7.next = 30;
- break;
-
- case 25:
- _context7.prev = 25;
- _context7.t3 = _context7["catch"](5);
- _context7.t3.position = expr.position;
- _context7.t3.token = op;
- throw _context7.t3;
-
- case 30:
- return _context7.abrupt("return", result);
-
- case 31:
- case "end":
- return _context7.stop();
- }
- }
- }, _marked7, null, [[5, 25]]);
- }
- /**
- * Evaluate unary expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateUnary(expr, input, environment) {
- var result, ii, item, value;
- return regeneratorRuntime.wrap(function evaluateUnary$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- _context8.t0 = expr.value;
- _context8.next = _context8.t0 === '-' ? 3 : _context8.t0 === '[' ? 15 : _context8.t0 === '{' ? 27 : 30;
- break;
-
- case 3:
- return _context8.delegateYield(_evaluate(expr.expression, input, environment), "t1", 4);
-
- case 4:
- result = _context8.t1;
-
- if (!(typeof result === 'undefined')) {
- _context8.next = 9;
- break;
- }
+ case 41:
+ result = _context.t8;
+ return _context.abrupt('break', 48);
- result = undefined;
- _context8.next = 14;
- break;
+ case 43:
+ return _context.delegateYield(evaluateApplyExpression(expr, input, environment), 't9', 44);
- case 9:
- if (!isNumeric(result)) {
- _context8.next = 13;
- break;
- }
+ case 44:
+ result = _context.t9;
+ return _context.abrupt('break', 48);
- result = -result;
- _context8.next = 14;
- break;
-
- case 13:
- throw {
- code: "D1002",
- stack: new Error().stack,
- position: expr.position,
- token: expr.value,
- value: result
- };
+ case 46:
+ result = evaluateTransformExpression(expr, input, environment);
+ return _context.abrupt('break', 48);
- case 14:
- return _context8.abrupt("break", 30);
+ case 48:
+ if (
+ environment.async &&
+ (typeof result === 'undefined' || result === null || typeof result.then !== 'function')
+ ) {
+ result = Promise.resolve(result);
+ }
- case 15:
- // array constructor - evaluate each item
- result = [];
- ii = 0;
+ if (
+ !(
+ environment.async &&
+ typeof result.then === 'function' &&
+ expr.nextFunction &&
+ typeof result[expr.nextFunction] === 'function'
+ )
+ ) {
+ _context.next = 52;
+ break;
+ }
- case 17:
- if (!(ii < expr.expressions.length)) {
- _context8.next = 25;
- break;
- }
+ _context.next = 55;
+ break;
- item = expr.expressions[ii];
- return _context8.delegateYield(_evaluate(item, input, environment), "t2", 20);
+ case 52:
+ _context.next = 54;
+ return result;
- case 20:
- value = _context8.t2;
+ case 54:
+ result = _context.sent;
- if (typeof value !== 'undefined') {
- if (item.value === '[') {
- result.push(value);
- } else {
- result = fn.append(result, value);
- }
- }
+ case 55:
+ if (!expr.hasOwnProperty('predicate')) {
+ _context.next = 63;
+ break;
+ }
- case 22:
- ii++;
- _context8.next = 17;
- break;
-
- case 25:
- if (expr.consarray) {
- Object.defineProperty(result, 'cons', {
- enumerable: false,
- configurable: false,
- value: true
- });
- }
+ ii = 0;
- return _context8.abrupt("break", 30);
+ case 57:
+ if (!(ii < expr.predicate.length)) {
+ _context.next = 63;
+ break;
+ }
- case 27:
- return _context8.delegateYield(evaluateGroupExpression(expr, input, environment), "t3", 28);
+ return _context.delegateYield(
+ evaluateFilter(expr.predicate[ii].expr, result, environment),
+ 't10',
+ 59
+ );
- case 28:
- result = _context8.t3;
- return _context8.abrupt("break", 30);
+ case 59:
+ result = _context.t10;
- case 30:
- return _context8.abrupt("return", result);
+ case 60:
+ ii++;
+ _context.next = 57;
+ break;
- case 31:
- case "end":
- return _context8.stop();
- }
- }
- }, _marked8);
- }
- /**
- * Evaluate name object against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateName(expr, input, environment) {
- // lookup the 'name' item in the input
- return fn.lookup(input, expr.value);
- }
- /**
- * Evaluate literal against input data
- * @param {Object} expr - JSONata expression
- * @returns {*} Evaluated input data
- */
+ case 63:
+ if (!(expr.type !== 'path' && expr.hasOwnProperty('group'))) {
+ _context.next = 66;
+ break;
+ }
+ return _context.delegateYield(
+ evaluateGroupExpression(expr.group, result, environment),
+ 't11',
+ 65
+ );
- function evaluateLiteral(expr) {
- return expr.value;
- }
- /**
- * Evaluate wildcard against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @returns {*} Evaluated input data
- */
+ case 65:
+ result = _context.t11;
+ case 66:
+ exitCallback = environment.lookup('__evaluate_exit');
- function evaluateWildcard(expr, input) {
- var results = createSequence();
+ if (exitCallback) {
+ exitCallback(expr, input, environment, result);
+ }
- if (input !== null && _typeof(input) === 'object') {
- Object.keys(input).forEach(function (key) {
- var value = input[key];
+ if (result && isSequence(result)) {
+ if (expr.keepArray) {
+ result.keepSingleton = true;
+ }
- if (Array.isArray(value)) {
- value = flatten(value);
- results = fn.append(results, value);
- } else {
- results.push(value);
- }
- });
- } // result = normalizeSequence(results);
+ if (result.length === 0) {
+ result = undefined;
+ } else if (result.length === 1) {
+ result = result.keepSingleton ? result : result[0];
+ }
+ }
+ return _context.abrupt('return', result);
- return results;
- }
- /**
- * Returns a flattened array
- * @param {Array} arg - the array to be flatten
- * @param {Array} flattened - carries the flattened array - if not defined, will initialize to []
- * @returns {Array} - the flattened array
- */
+ case 70:
+ case 'end':
+ return _context.stop();
+ }
+ }
+ }, _marked);
+ }
+ /**
+ * Evaluate path expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluatePath(expr, input, environment) {
+ var inputSequence, resultSequence, isTupleStream, tupleBindings, ii, step;
+ return regeneratorRuntime.wrap(function evaluatePath$(_context2) {
+ while (1) {
+ switch ((_context2.prev = _context2.next)) {
+ case 0:
+ // expr is an array of steps
+ // if the first step is a variable reference ($...), including root reference ($$),
+ // then the path is absolute rather than relative
+ if (expr.steps[0].type === 'variable') {
+ inputSequence = createSequence(input); // dummy singleton sequence for first (absolute) step
+ } else if (Array.isArray(input)) {
+ inputSequence = input;
+ } else {
+ // if input is not an array, make it so
+ inputSequence = createSequence(input);
+ }
+ isTupleStream = false;
+ tupleBindings = undefined; // evaluate each step in turn
- function flatten(arg, flattened) {
- if (typeof flattened === 'undefined') {
- flattened = [];
- }
+ ii = 0;
- if (Array.isArray(arg)) {
- arg.forEach(function (item) {
- flatten(item, flattened);
- });
- } else {
- flattened.push(arg);
- }
+ case 4:
+ if (!(ii < expr.steps.length)) {
+ _context2.next = 25;
+ break;
+ }
- return flattened;
- }
- /**
- * Evaluate descendants against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @returns {*} Evaluated input data
- */
+ step = expr.steps[ii];
+ if (step.tuple) {
+ isTupleStream = true;
+ } // if the first step is an explicit array constructor, then just evaluate that (i.e. don't iterate over a context array)
- function evaluateDescendants(expr, input) {
- var result;
- var resultSequence = createSequence();
+ if (!(ii === 0 && step.consarray)) {
+ _context2.next = 12;
+ break;
+ }
- if (typeof input !== 'undefined') {
- // traverse all descendants of this object/array
- recurseDescendants(input, resultSequence);
+ return _context2.delegateYield(_evaluate(step, inputSequence, environment), 't0', 9);
- if (resultSequence.length === 1) {
- result = resultSequence[0];
- } else {
- result = resultSequence;
- }
- }
+ case 9:
+ resultSequence = _context2.t0;
+ _context2.next = 19;
+ break;
- return result;
- }
- /**
- * Recurse through descendants
- * @param {Object} input - Input data
- * @param {Object} results - Results
- */
+ case 12:
+ if (!isTupleStream) {
+ _context2.next = 17;
+ break;
+ }
+ return _context2.delegateYield(
+ evaluateTupleStep(step, inputSequence, tupleBindings, environment),
+ 't1',
+ 14
+ );
- function recurseDescendants(input, results) {
- // this is the equivalent of //* in XPath
- if (!Array.isArray(input)) {
- results.push(input);
- }
+ case 14:
+ tupleBindings = _context2.t1;
+ _context2.next = 19;
+ break;
- if (Array.isArray(input)) {
- input.forEach(function (member) {
- recurseDescendants(member, results);
- });
- } else if (input !== null && _typeof(input) === 'object') {
- Object.keys(input).forEach(function (key) {
- recurseDescendants(input[key], results);
- });
- }
- }
- /**
- * Evaluate numeric expression against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @param {Object} op - opcode
- * @returns {*} Result
- */
-
-
- function evaluateNumericExpression(lhs, rhs, op) {
- var result;
-
- if (typeof lhs !== 'undefined' && !isNumeric(lhs)) {
- throw {
- code: "T2001",
- stack: new Error().stack,
- value: lhs
- };
- }
+ case 17:
+ return _context2.delegateYield(
+ evaluateStep(step, inputSequence, environment, ii === expr.steps.length - 1),
+ 't2',
+ 18
+ );
- if (typeof rhs !== 'undefined' && !isNumeric(rhs)) {
- throw {
- code: "T2002",
- stack: new Error().stack,
- value: rhs
- };
- }
+ case 18:
+ resultSequence = _context2.t2;
- if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
- // if either side is undefined, the result is undefined
- return result;
- }
+ case 19:
+ if (!(!isTupleStream && (typeof resultSequence === 'undefined' || resultSequence.length === 0))) {
+ _context2.next = 21;
+ break;
+ }
- switch (op) {
- case '+':
- result = lhs + rhs;
- break;
+ return _context2.abrupt('break', 25);
- case '-':
- result = lhs - rhs;
- break;
+ case 21:
+ if (typeof step.focus === 'undefined') {
+ inputSequence = resultSequence;
+ }
- case '*':
- result = lhs * rhs;
- break;
+ case 22:
+ ii++;
+ _context2.next = 4;
+ break;
- case '/':
- result = lhs / rhs;
- break;
+ case 25:
+ if (isTupleStream) {
+ resultSequence = createSequence();
- case '%':
- result = lhs % rhs;
- break;
- }
+ for (ii = 0; ii < tupleBindings.length; ii++) {
+ resultSequence.push(tupleBindings[ii]['@']);
+ }
+ }
- return result;
- }
- /**
- * Evaluate equality expression against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @param {Object} op - opcode
- * @returns {*} Result
- */
+ if (expr.keepSingletonArray) {
+ resultSequence.keepSingleton = true;
+ }
+ if (!expr.hasOwnProperty('group')) {
+ _context2.next = 30;
+ break;
+ }
- function evaluateEqualityExpression(lhs, rhs, op) {
- var result; // type checks
+ return _context2.delegateYield(
+ evaluateGroupExpression(
+ expr.group,
+ isTupleStream ? tupleBindings : resultSequence,
+ environment
+ ),
+ 't3',
+ 29
+ );
- var ltype = _typeof(lhs);
+ case 29:
+ resultSequence = _context2.t3;
- var rtype = _typeof(rhs);
+ case 30:
+ return _context2.abrupt('return', resultSequence);
- if (ltype === 'undefined' || rtype === 'undefined') {
- // if either side is undefined, the result is false
- return false;
- }
+ case 31:
+ case 'end':
+ return _context2.stop();
+ }
+ }
+ }, _marked2);
+ }
- switch (op) {
- case '=':
- result = isDeepEqual(lhs, rhs);
- break;
+ function createFrameFromTuple(environment, tuple) {
+ var frame = createFrame(environment);
- case '!=':
- result = !isDeepEqual(lhs, rhs);
- break;
- }
+ for (var prop in tuple) {
+ frame.bind(prop, tuple[prop]);
+ }
- return result;
- }
- /**
- * Evaluate comparison expression against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @param {Object} op - opcode
- * @returns {*} Result
- */
+ return frame;
+ }
+ /**
+ * Evaluate a step within a path
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @param {boolean} lastStep - flag the last step in a path
+ * @returns {*} Evaluated input data
+ */
+ function evaluateStep(expr, input, environment, lastStep) {
+ var result, ii, res, ss, resultSequence;
+ return regeneratorRuntime.wrap(function evaluateStep$(_context3) {
+ while (1) {
+ switch ((_context3.prev = _context3.next)) {
+ case 0:
+ if (!(expr.type === 'sort')) {
+ _context3.next = 7;
+ break;
+ }
- function evaluateComparisonExpression(lhs, rhs, op) {
- var result; // type checks
+ return _context3.delegateYield(evaluateSortExpression(expr, input, environment), 't0', 2);
- var ltype = _typeof(lhs);
+ case 2:
+ result = _context3.t0;
- var rtype = _typeof(rhs);
+ if (!expr.stages) {
+ _context3.next = 6;
+ break;
+ }
- var lcomparable = ltype === 'undefined' || ltype === 'string' || ltype === 'number';
- var rcomparable = rtype === 'undefined' || rtype === 'string' || rtype === 'number'; // if either aa or bb are not comparable (string or numeric) values, then throw an error
+ return _context3.delegateYield(evaluateStages(expr.stages, result, environment), 't1', 5);
- if (!lcomparable || !rcomparable) {
- throw {
- code: "T2010",
- stack: new Error().stack,
- value: !(ltype === 'string' || ltype === 'number') ? lhs : rhs
- };
- } // if either side is undefined, the result is undefined
+ case 5:
+ result = _context3.t1;
+ case 6:
+ return _context3.abrupt('return', result);
- if (ltype === 'undefined' || rtype === 'undefined') {
- return undefined;
- } //if aa and bb are not of the same type
+ case 7:
+ result = createSequence();
+ ii = 0;
+ case 9:
+ if (!(ii < input.length)) {
+ _context3.next = 24;
+ break;
+ }
- if (ltype !== rtype) {
- throw {
- code: "T2009",
- stack: new Error().stack,
- value: lhs,
- value2: rhs
- };
- }
+ return _context3.delegateYield(_evaluate(expr, input[ii], environment), 't2', 11);
- switch (op) {
- case '<':
- result = lhs < rhs;
- break;
+ case 11:
+ res = _context3.t2;
- case '<=':
- result = lhs <= rhs;
- break;
+ if (!expr.stages) {
+ _context3.next = 20;
+ break;
+ }
- case '>':
- result = lhs > rhs;
- break;
+ ss = 0;
- case '>=':
- result = lhs >= rhs;
- break;
- }
+ case 14:
+ if (!(ss < expr.stages.length)) {
+ _context3.next = 20;
+ break;
+ }
- return result;
- }
- /**
- * Inclusion operator - in
- *
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @returns {boolean} - true if lhs is a member of rhs
- */
+ return _context3.delegateYield(evaluateFilter(expr.stages[ss].expr, res, environment), 't3', 16);
+ case 16:
+ res = _context3.t3;
- function evaluateIncludesExpression(lhs, rhs) {
- var result = false;
+ case 17:
+ ss++;
+ _context3.next = 14;
+ break;
- if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
- // if either side is undefined, the result is false
- return false;
- }
+ case 20:
+ if (typeof res !== 'undefined') {
+ result.push(res);
+ }
- if (!Array.isArray(rhs)) {
- rhs = [rhs];
- }
+ case 21:
+ ii++;
+ _context3.next = 9;
+ break;
- for (var i = 0; i < rhs.length; i++) {
- if (rhs[i] === lhs) {
- result = true;
- break;
- }
- }
+ case 24:
+ resultSequence = createSequence();
- return result;
- }
- /**
- * Evaluate boolean expression against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @param {Object} op - opcode
- * @returns {*} Result
- */
-
-
- function evaluateBooleanExpression(lhs, rhs, op) {
- var result;
- var lBool = fn["boolean"](lhs);
- var rBool = fn["boolean"](rhs);
-
- if (typeof lBool === 'undefined') {
- lBool = false;
- }
+ if (lastStep && result.length === 1 && Array.isArray(result[0]) && !isSequence(result[0])) {
+ resultSequence = result[0];
+ } else {
+ // flatten the sequence
+ result.forEach(function (res) {
+ if (!Array.isArray(res) || res.cons) {
+ // it's not an array - just push into the result sequence
+ resultSequence.push(res);
+ } else {
+ // res is a sequence - flatten it into the parent sequence
+ Array.prototype.push.apply(resultSequence, res);
+ }
+ });
+ }
- if (typeof rBool === 'undefined') {
- rBool = false;
- }
+ return _context3.abrupt('return', resultSequence);
- switch (op) {
- case 'and':
- result = lBool && rBool;
- break;
+ case 27:
+ case 'end':
+ return _context3.stop();
+ }
+ }
+ }, _marked3);
+ }
- case 'or':
- result = lBool || rBool;
- break;
- }
+ function evaluateStages(stages, input, environment) {
+ var result, ss, stage, ee, tuple;
+ return regeneratorRuntime.wrap(function evaluateStages$(_context4) {
+ while (1) {
+ switch ((_context4.prev = _context4.next)) {
+ case 0:
+ result = input;
+ ss = 0;
- return result;
- }
- /**
- * Evaluate string concatenation against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @returns {string|*} Concatenated string
- */
+ case 2:
+ if (!(ss < stages.length)) {
+ _context4.next = 15;
+ break;
+ }
+ stage = stages[ss];
+ _context4.t0 = stage.type;
+ _context4.next = _context4.t0 === 'filter' ? 7 : _context4.t0 === 'index' ? 10 : 12;
+ break;
- function evaluateStringConcat(lhs, rhs) {
- var result;
- var lstr = '';
- var rstr = '';
+ case 7:
+ return _context4.delegateYield(evaluateFilter(stage.expr, result, environment), 't1', 8);
- if (typeof lhs !== 'undefined') {
- lstr = fn.string(lhs);
- }
+ case 8:
+ result = _context4.t1;
+ return _context4.abrupt('break', 12);
- if (typeof rhs !== 'undefined') {
- rstr = fn.string(rhs);
- }
+ case 10:
+ for (ee = 0; ee < result.length; ee++) {
+ tuple = result[ee];
+ tuple[stage.value] = ee;
+ }
- result = lstr.concat(rstr);
- return result;
- }
- /**
- * Evaluate group expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {{}} Evaluated input data
- */
-
-
- function evaluateGroupExpression(expr, input, environment) {
- var result, groups, reduce, itemIndex, item, env, pairIndex, pair, key, entry, context, tuple, value;
- return regeneratorRuntime.wrap(function evaluateGroupExpression$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- result = {};
- groups = {};
- reduce = input && input.tupleStream ? true : false; // group the input sequence by 'key' expression
-
- if (!Array.isArray(input)) {
- input = createSequence(input);
- }
+ return _context4.abrupt('break', 12);
- itemIndex = 0;
+ case 12:
+ ss++;
+ _context4.next = 2;
+ break;
- case 5:
- if (!(itemIndex < input.length)) {
- _context9.next = 29;
- break;
- }
+ case 15:
+ return _context4.abrupt('return', result);
- item = input[itemIndex];
- env = reduce ? createFrameFromTuple(environment, item) : environment;
- pairIndex = 0;
+ case 16:
+ case 'end':
+ return _context4.stop();
+ }
+ }
+ }, _marked4);
+ }
+ /**
+ * Evaluate a step within a path
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} tupleBindings - The tuple stream
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateTupleStep(expr, input, tupleBindings, environment) {
+ var result, sorted, ss, tuple, stepEnv, ee, res, bb;
+ return regeneratorRuntime.wrap(function evaluateTupleStep$(_context5) {
+ while (1) {
+ switch ((_context5.prev = _context5.next)) {
+ case 0:
+ if (!(expr.type === 'sort')) {
+ _context5.next = 15;
+ break;
+ }
- case 9:
- if (!(pairIndex < expr.lhs.length)) {
- _context9.next = 26;
- break;
- }
+ if (!tupleBindings) {
+ _context5.next = 6;
+ break;
+ }
- pair = expr.lhs[pairIndex];
- return _context9.delegateYield(_evaluate(pair[0], reduce ? item['@'] : item, env), "t0", 12);
+ return _context5.delegateYield(evaluateSortExpression(expr, tupleBindings, environment), 't0', 3);
- case 12:
- key = _context9.t0;
+ case 3:
+ result = _context5.t0;
+ _context5.next = 11;
+ break;
- if (!(typeof key !== 'string')) {
- _context9.next = 15;
- break;
- }
+ case 6:
+ return _context5.delegateYield(evaluateSortExpression(expr, input, environment), 't1', 7);
- throw {
- code: "T1003",
- stack: new Error().stack,
- position: expr.position,
- value: key
- };
+ case 7:
+ sorted = _context5.t1;
+ result = createSequence();
+ result.tupleStream = true;
- case 15:
- entry = {
- data: item,
- exprIndex: pairIndex
- };
+ for (ss = 0; ss < sorted.length; ss++) {
+ tuple = {
+ '@': sorted[ss],
+ };
+ tuple[expr.index] = ss;
+ result.push(tuple);
+ }
- if (!groups.hasOwnProperty(key)) {
- _context9.next = 22;
- break;
- }
+ case 11:
+ if (!expr.stages) {
+ _context5.next = 14;
+ break;
+ }
- if (!(groups[key].exprIndex !== pairIndex)) {
- _context9.next = 19;
- break;
- }
+ return _context5.delegateYield(evaluateStages(expr.stages, result, environment), 't2', 13);
- throw {
- code: "D1009",
- stack: new Error().stack,
- position: expr.position,
- value: key
- };
+ case 13:
+ result = _context5.t2;
+
+ case 14:
+ return _context5.abrupt('return', result);
+
+ case 15:
+ result = createSequence();
+ result.tupleStream = true;
+ stepEnv = environment;
+
+ if (tupleBindings === undefined) {
+ tupleBindings = [
+ {
+ '@': input,
+ },
+ ];
+ }
- case 19:
- // append it as an array
- groups[key].data = fn.append(groups[key].data, item);
- _context9.next = 23;
- break;
+ ee = 0;
- case 22:
- groups[key] = entry;
+ case 20:
+ if (!(ee < tupleBindings.length)) {
+ _context5.next = 28;
+ break;
+ }
- case 23:
- pairIndex++;
- _context9.next = 9;
- break;
+ stepEnv = createFrameFromTuple(environment, tupleBindings[ee]);
+ return _context5.delegateYield(_evaluate(expr, tupleBindings[ee]['@'], stepEnv), 't3', 23);
- case 26:
- itemIndex++;
- _context9.next = 5;
- break;
+ case 23:
+ res = _context5.t3;
- case 29:
- _context9.t1 = regeneratorRuntime.keys(groups);
+ // res is the binding sequence for the output tuple stream
+ if (typeof res !== 'undefined') {
+ if (!Array.isArray(res)) {
+ res = [res];
+ }
- case 30:
- if ((_context9.t2 = _context9.t1()).done) {
- _context9.next = 41;
- break;
- }
+ for (bb = 0; bb < res.length; bb++) {
+ tuple = {};
+ Object.assign(tuple, tupleBindings[ee]);
- key = _context9.t2.value;
- entry = groups[key];
- context = entry.data;
- env = environment;
+ if (expr.focus) {
+ tuple[expr.focus] = res[bb];
+ tuple['@'] = input;
+ } else {
+ tuple['@'] = res[bb];
+ }
- if (reduce) {
- tuple = reduceTupleStream(entry.data);
- context = tuple['@'];
- delete tuple['@'];
- env = createFrameFromTuple(environment, tuple);
- }
+ if (expr.index) {
+ tuple[expr.index] = bb;
+ }
- return _context9.delegateYield(_evaluate(expr.lhs[entry.exprIndex][1], context, env), "t3", 37);
+ result.push(tuple);
+ }
+ }
- case 37:
- value = _context9.t3;
+ case 25:
+ ee++;
+ _context5.next = 20;
+ break;
- if (typeof value !== 'undefined') {
- result[key] = value;
- }
+ case 28:
+ if (!expr.stages) {
+ _context5.next = 31;
+ break;
+ }
- _context9.next = 30;
- break;
+ return _context5.delegateYield(evaluateStages(expr.stages, result, environment), 't4', 30);
- case 41:
- return _context9.abrupt("return", result);
+ case 30:
+ result = _context5.t4;
- case 42:
- case "end":
- return _context9.stop();
- }
- }
- }, _marked9);
- }
+ case 31:
+ return _context5.abrupt('return', result);
- function reduceTupleStream(tupleStream) {
- if (!Array.isArray(tupleStream)) {
- return tupleStream;
- }
+ case 32:
+ case 'end':
+ return _context5.stop();
+ }
+ }
+ }, _marked5);
+ }
+ /**
+ * Apply filter predicate to input data
+ * @param {Object} predicate - filter expression
+ * @param {Object} input - Input data to apply predicates against
+ * @param {Object} environment - Environment
+ * @returns {*} Result after applying predicates
+ */
+
+ function evaluateFilter(predicate, input, environment) {
+ var results, index, item, context, env, res;
+ return regeneratorRuntime.wrap(function evaluateFilter$(_context6) {
+ while (1) {
+ switch ((_context6.prev = _context6.next)) {
+ case 0:
+ results = createSequence();
- var result = {};
- Object.assign(result, tupleStream[0]);
+ if (input && input.tupleStream) {
+ results.tupleStream = true;
+ }
- for (var ii = 1; ii < tupleStream.length; ii++) {
- for (var prop in tupleStream[ii]) {
- result[prop] = fn.append(result[prop], tupleStream[ii][prop]);
- }
- }
+ if (!Array.isArray(input)) {
+ input = createSequence(input);
+ }
- return result;
- }
- /**
- * Evaluate range expression against input data
- * @param {Object} lhs - LHS value
- * @param {Object} rhs - RHS value
- * @returns {Array} Resultant array
- */
-
-
- function evaluateRangeExpression(lhs, rhs) {
- var result;
-
- if (typeof lhs !== 'undefined' && !Number.isInteger(lhs)) {
- throw {
- code: "T2003",
- stack: new Error().stack,
- value: lhs
- };
- }
+ if (!(predicate.type === 'number')) {
+ _context6.next = 10;
+ break;
+ }
- if (typeof rhs !== 'undefined' && !Number.isInteger(rhs)) {
- throw {
- code: "T2004",
- stack: new Error().stack,
- value: rhs
- };
- }
+ index = Math.floor(predicate.value); // round it down
- if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
- // if either side is undefined, the result is undefined
- return result;
- }
+ if (index < 0) {
+ // count in from end of array
+ index = input.length + index;
+ }
- if (lhs > rhs) {
- // if the lhs is greater than the rhs, return undefined
- return result;
- } // limit the size of the array to ten million entries (1e7)
- // this is an implementation defined limit to protect against
- // memory and performance issues. This value may increase in the future.
+ item = input[index];
+ if (typeof item !== 'undefined') {
+ if (Array.isArray(item)) {
+ results = item;
+ } else {
+ results.push(item);
+ }
+ }
- var size = rhs - lhs + 1;
+ _context6.next = 23;
+ break;
- if (size > 1e7) {
- throw {
- code: "D2014",
- stack: new Error().stack,
- value: size
- };
- }
+ case 10:
+ index = 0;
- result = new Array(size);
+ case 11:
+ if (!(index < input.length)) {
+ _context6.next = 23;
+ break;
+ }
- for (var item = lhs, index = 0; item <= rhs; item++, index++) {
- result[index] = item;
- }
+ item = input[index];
+ context = item;
+ env = environment;
- result.sequence = true;
- return result;
- }
- /**
- * Evaluate bind expression against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateBindExpression(expr, input, environment) {
- var value;
- return regeneratorRuntime.wrap(function evaluateBindExpression$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- return _context10.delegateYield(_evaluate(expr.rhs, input, environment), "t0", 1);
-
- case 1:
- value = _context10.t0;
- environment.bind(expr.lhs.value, value);
- return _context10.abrupt("return", value);
-
- case 4:
- case "end":
- return _context10.stop();
- }
- }
- }, _marked10);
- }
- /**
- * Evaluate condition against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateCondition(expr, input, environment) {
- var result, condition;
- return regeneratorRuntime.wrap(function evaluateCondition$(_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- return _context11.delegateYield(_evaluate(expr.condition, input, environment), "t0", 1);
-
- case 1:
- condition = _context11.t0;
-
- if (!fn["boolean"](condition)) {
- _context11.next = 7;
- break;
- }
+ if (input.tupleStream) {
+ context = item['@'];
+ env = createFrameFromTuple(environment, item);
+ }
- return _context11.delegateYield(_evaluate(expr.then, input, environment), "t1", 4);
+ return _context6.delegateYield(_evaluate(predicate, context, env), 't0', 17);
- case 4:
- result = _context11.t1;
- _context11.next = 10;
- break;
+ case 17:
+ res = _context6.t0;
- case 7:
- if (!(typeof expr["else"] !== 'undefined')) {
- _context11.next = 10;
- break;
- }
+ if (isNumeric(res)) {
+ res = [res];
+ }
- return _context11.delegateYield(_evaluate(expr["else"], input, environment), "t2", 9);
+ if (isArrayOfNumbers(res)) {
+ res.forEach(function (ires) {
+ // round it down
+ var ii = Math.floor(ires);
- case 9:
- result = _context11.t2;
+ if (ii < 0) {
+ // count in from end of array
+ ii = input.length + ii;
+ }
- case 10:
- return _context11.abrupt("return", result);
+ if (ii === index) {
+ results.push(item);
+ }
+ });
+ } else if (fn['boolean'](res)) {
+ // truthy
+ results.push(item);
+ }
- case 11:
- case "end":
- return _context11.stop();
- }
- }
- }, _marked11);
- }
- /**
- * Evaluate block against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateBlock(expr, input, environment) {
- var result, frame, ii;
- return regeneratorRuntime.wrap(function evaluateBlock$(_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- // create a new frame to limit the scope of variable assignments
- // TODO, only do this if the post-parse stage has flagged this as required
- frame = createFrame(environment); // invoke each expression in turn
- // only return the result of the last one
-
- ii = 0;
-
- case 2:
- if (!(ii < expr.expressions.length)) {
- _context12.next = 8;
- break;
- }
+ case 20:
+ index++;
+ _context6.next = 11;
+ break;
- return _context12.delegateYield(_evaluate(expr.expressions[ii], input, frame), "t0", 4);
+ case 23:
+ return _context6.abrupt('return', results);
- case 4:
- result = _context12.t0;
+ case 24:
+ case 'end':
+ return _context6.stop();
+ }
+ }
+ }, _marked6);
+ }
+ /**
+ * Evaluate binary expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateBinary(expr, input, environment) {
+ var result, lhs, rhs, op;
+ return regeneratorRuntime.wrap(
+ function evaluateBinary$(_context7) {
+ while (1) {
+ switch ((_context7.prev = _context7.next)) {
+ case 0:
+ return _context7.delegateYield(_evaluate(expr.lhs, input, environment), 't0', 1);
+
+ case 1:
+ lhs = _context7.t0;
+ return _context7.delegateYield(_evaluate(expr.rhs, input, environment), 't1', 3);
+
+ case 3:
+ rhs = _context7.t1;
+ op = expr.value;
+ _context7.prev = 5;
+ _context7.t2 = op;
+ _context7.next =
+ _context7.t2 === '+'
+ ? 9
+ : _context7.t2 === '-'
+ ? 9
+ : _context7.t2 === '*'
+ ? 9
+ : _context7.t2 === '/'
+ ? 9
+ : _context7.t2 === '%'
+ ? 9
+ : _context7.t2 === '='
+ ? 11
+ : _context7.t2 === '!='
+ ? 11
+ : _context7.t2 === '<'
+ ? 13
+ : _context7.t2 === '<='
+ ? 13
+ : _context7.t2 === '>'
+ ? 13
+ : _context7.t2 === '>='
+ ? 13
+ : _context7.t2 === '&'
+ ? 15
+ : _context7.t2 === 'and'
+ ? 17
+ : _context7.t2 === 'or'
+ ? 17
+ : _context7.t2 === '..'
+ ? 19
+ : _context7.t2 === 'in'
+ ? 21
+ : 23;
+ break;
- case 5:
- ii++;
- _context12.next = 2;
- break;
+ case 9:
+ result = evaluateNumericExpression(lhs, rhs, op);
+ return _context7.abrupt('break', 23);
- case 8:
- return _context12.abrupt("return", result);
+ case 11:
+ result = evaluateEqualityExpression(lhs, rhs, op);
+ return _context7.abrupt('break', 23);
- case 9:
- case "end":
- return _context12.stop();
- }
- }
- }, _marked12);
- }
- /**
- * Prepare a regex
- * @param {Object} expr - expression containing regex
- * @returns {Function} Higher order function representing prepared regex
- */
-
-
- function evaluateRegex(expr) {
- var re = new RegExp(expr.value);
-
- var closure = function closure(str) {
- var result;
- var match = re.exec(str);
-
- if (match !== null) {
- result = {
- match: match[0],
- start: match.index,
- end: match.index + match[0].length,
- groups: []
- };
-
- if (match.length > 1) {
- for (var i = 1; i < match.length; i++) {
- result.groups.push(match[i]);
- }
- }
+ case 13:
+ result = evaluateComparisonExpression(lhs, rhs, op);
+ return _context7.abrupt('break', 23);
- result.next = function () {
- if (re.lastIndex >= str.length) {
- return undefined;
- } else {
- var next = closure(str);
-
- if (next && next.match === '') {
- // matches zero length string; this will never progress
- throw {
- code: "D1004",
- stack: new Error().stack,
- position: expr.position,
- value: expr.value.source
- };
- }
+ case 15:
+ result = evaluateStringConcat(lhs, rhs);
+ return _context7.abrupt('break', 23);
- return next;
- }
- };
- }
+ case 17:
+ result = evaluateBooleanExpression(lhs, rhs, op);
+ return _context7.abrupt('break', 23);
- return result;
- };
+ case 19:
+ result = evaluateRangeExpression(lhs, rhs);
+ return _context7.abrupt('break', 23);
- return closure;
- }
- /**
- * Evaluate variable against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
+ case 21:
+ result = evaluateIncludesExpression(lhs, rhs);
+ return _context7.abrupt('break', 23);
+ case 23:
+ _context7.next = 30;
+ break;
- function evaluateVariable(expr, input, environment) {
- // lookup the variable value in the environment
- var result; // if the variable name is empty string, then it refers to context value
+ case 25:
+ _context7.prev = 25;
+ _context7.t3 = _context7['catch'](5);
+ _context7.t3.position = expr.position;
+ _context7.t3.token = op;
+ throw _context7.t3;
- if (expr.value === '') {
- result = input && input.outerWrapper ? input[0] : input;
- } else {
- result = environment.lookup(expr.value);
- }
+ case 30:
+ return _context7.abrupt('return', result);
- return result;
- }
- /**
- * sort / order-by operator
- * @param {Object} expr - AST for operator
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Ordered sequence
- */
-
-
- function evaluateSortExpression(expr, input, environment) {
- var result, lhs, isTupleSort, comparator, focus;
- return regeneratorRuntime.wrap(function evaluateSortExpression$(_context14) {
- while (1) {
- switch (_context14.prev = _context14.next) {
- case 0:
- // evaluate the lhs, then sort the results in order according to rhs expression
- //var lhs = yield * evaluate(expr.lhs, input, environment);
- lhs = input;
- isTupleSort = input.tupleStream ? true : false; // sort the lhs array
- // use comparator function
-
- comparator =
- /*#__PURE__*/
- regeneratorRuntime.mark(function comparator(a, b) {
- var comp, index, term, context, env, aa, bb, atype, btype;
- return regeneratorRuntime.wrap(function comparator$(_context13) {
+ case 31:
+ case 'end':
+ return _context7.stop();
+ }
+ }
+ },
+ _marked7,
+ null,
+ [[5, 25]]
+ );
+ }
+ /**
+ * Evaluate unary expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateUnary(expr, input, environment) {
+ var result, ii, item, value;
+ return regeneratorRuntime.wrap(function evaluateUnary$(_context8) {
while (1) {
- switch (_context13.prev = _context13.next) {
+ switch ((_context8.prev = _context8.next)) {
case 0:
- // eslint-disable-line require-yield
- // expr.terms is an array of order-by in priority order
- comp = 0;
- index = 0;
-
- case 2:
- if (!(comp === 0 && index < expr.terms.length)) {
- _context13.next = 35;
- break;
- }
+ _context8.t0 = expr.value;
+ _context8.next =
+ _context8.t0 === '-' ? 3 : _context8.t0 === '[' ? 15 : _context8.t0 === '{' ? 27 : 30;
+ break;
- term = expr.terms[index]; //evaluate the sort term in the context of a
+ case 3:
+ return _context8.delegateYield(_evaluate(expr.expression, input, environment), 't1', 4);
- context = a;
- env = environment;
+ case 4:
+ result = _context8.t1;
- if (isTupleSort) {
- context = a['@'];
- env = createFrameFromTuple(environment, a);
+ if (!(typeof result === 'undefined')) {
+ _context8.next = 9;
+ break;
}
- return _context13.delegateYield(_evaluate(term.expression, context, env), "t0", 8);
-
- case 8:
- aa = _context13.t0;
- //evaluate the sort term in the context of b
- context = b;
- env = environment;
+ result = undefined;
+ _context8.next = 14;
+ break;
- if (isTupleSort) {
- context = b['@'];
- env = createFrameFromTuple(environment, b);
+ case 9:
+ if (!isNumeric(result)) {
+ _context8.next = 13;
+ break;
}
- return _context13.delegateYield(_evaluate(term.expression, context, env), "t1", 13);
+ result = -result;
+ _context8.next = 14;
+ break;
case 13:
- bb = _context13.t1;
- // type checks
- atype = _typeof(aa);
- btype = _typeof(bb); // undefined should be last in sort order
+ throw {
+ code: 'D1002',
+ stack: new Error().stack,
+ position: expr.position,
+ token: expr.value,
+ value: result,
+ };
- if (!(atype === 'undefined')) {
- _context13.next = 19;
- break;
- }
+ case 14:
+ return _context8.abrupt('break', 30);
- // swap them, unless btype is also undefined
- comp = btype === 'undefined' ? 0 : 1;
- return _context13.abrupt("continue", 32);
+ case 15:
+ // array constructor - evaluate each item
+ result = [];
+ ii = 0;
- case 19:
- if (!(btype === 'undefined')) {
- _context13.next = 22;
+ case 17:
+ if (!(ii < expr.expressions.length)) {
+ _context8.next = 25;
break;
}
- comp = -1;
- return _context13.abrupt("continue", 32);
+ item = expr.expressions[ii];
+ return _context8.delegateYield(_evaluate(item, input, environment), 't2', 20);
- case 22:
- if (!(!(atype === 'string' || atype === 'number') || !(btype === 'string' || btype === 'number'))) {
- _context13.next = 24;
- break;
+ case 20:
+ value = _context8.t2;
+
+ if (typeof value !== 'undefined') {
+ if (item.value === '[') {
+ result.push(value);
+ } else {
+ result = fn.append(result, value);
+ }
}
- throw {
- code: "T2008",
- stack: new Error().stack,
- position: expr.position,
- value: !(atype === 'string' || atype === 'number') ? aa : bb
- };
+ case 22:
+ ii++;
+ _context8.next = 17;
+ break;
- case 24:
- if (!(atype !== btype)) {
- _context13.next = 26;
- break;
+ case 25:
+ if (expr.consarray) {
+ Object.defineProperty(result, 'cons', {
+ enumerable: false,
+ configurable: false,
+ value: true,
+ });
}
- throw {
- code: "T2007",
- stack: new Error().stack,
- position: expr.position,
- value: aa,
- value2: bb
- };
+ return _context8.abrupt('break', 30);
- case 26:
- if (!(aa === bb)) {
- _context13.next = 30;
- break;
- }
+ case 27:
+ return _context8.delegateYield(evaluateGroupExpression(expr, input, environment), 't3', 28);
- return _context13.abrupt("continue", 32);
+ case 28:
+ result = _context8.t3;
+ return _context8.abrupt('break', 30);
case 30:
- if (aa < bb) {
- comp = -1;
- } else {
- comp = 1;
- }
+ return _context8.abrupt('return', result);
case 31:
- if (term.descending === true) {
- comp = -comp;
- }
+ case 'end':
+ return _context8.stop();
+ }
+ }
+ }, _marked8);
+ }
+ /**
+ * Evaluate name object against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateName(expr, input, environment) {
+ // lookup the 'name' item in the input
+ return fn.lookup(input, expr.value);
+ }
+ /**
+ * Evaluate literal against input data
+ * @param {Object} expr - JSONata expression
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateLiteral(expr) {
+ return expr.value;
+ }
+ /**
+ * Evaluate wildcard against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateWildcard(expr, input) {
+ var results = createSequence();
+
+ if (input !== null && _typeof(input) === 'object') {
+ Object.keys(input).forEach(function (key) {
+ var value = input[key];
+
+ if (Array.isArray(value)) {
+ value = flatten(value);
+ results = fn.append(results, value);
+ } else {
+ results.push(value);
+ }
+ });
+ } // result = normalizeSequence(results);
- case 32:
- index++;
- _context13.next = 2;
- break;
+ return results;
+ }
+ /**
+ * Returns a flattened array
+ * @param {Array} arg - the array to be flatten
+ * @param {Array} flattened - carries the flattened array - if not defined, will initialize to []
+ * @returns {Array} - the flattened array
+ */
- case 35:
- return _context13.abrupt("return", comp === 1);
+ function flatten(arg, flattened) {
+ if (typeof flattened === 'undefined') {
+ flattened = [];
+ }
- case 36:
- case "end":
- return _context13.stop();
- }
+ if (Array.isArray(arg)) {
+ arg.forEach(function (item) {
+ flatten(item, flattened);
+ });
+ } else {
+ flattened.push(arg);
+ }
+
+ return flattened;
+ }
+ /**
+ * Evaluate descendants against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateDescendants(expr, input) {
+ var result;
+ var resultSequence = createSequence();
+
+ if (typeof input !== 'undefined') {
+ // traverse all descendants of this object/array
+ recurseDescendants(input, resultSequence);
+
+ if (resultSequence.length === 1) {
+ result = resultSequence[0];
+ } else {
+ result = resultSequence;
}
- }, comparator);
- });
- focus = {
- environment: environment,
- input: input
- }; // the `focus` is passed in as the `this` for the invoked function
+ }
+
+ return result;
+ }
+ /**
+ * Recurse through descendants
+ * @param {Object} input - Input data
+ * @param {Object} results - Results
+ */
+
+ function recurseDescendants(input, results) {
+ // this is the equivalent of //* in XPath
+ if (!Array.isArray(input)) {
+ results.push(input);
+ }
+
+ if (Array.isArray(input)) {
+ input.forEach(function (member) {
+ recurseDescendants(member, results);
+ });
+ } else if (input !== null && _typeof(input) === 'object') {
+ Object.keys(input).forEach(function (key) {
+ recurseDescendants(input[key], results);
+ });
+ }
+ }
+ /**
+ * Evaluate numeric expression against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @param {Object} op - opcode
+ * @returns {*} Result
+ */
+
+ function evaluateNumericExpression(lhs, rhs, op) {
+ var result;
+
+ if (typeof lhs !== 'undefined' && !isNumeric(lhs)) {
+ throw {
+ code: 'T2001',
+ stack: new Error().stack,
+ value: lhs,
+ };
+ }
+
+ if (typeof rhs !== 'undefined' && !isNumeric(rhs)) {
+ throw {
+ code: 'T2002',
+ stack: new Error().stack,
+ value: rhs,
+ };
+ }
- return _context14.delegateYield(fn.sort.apply(focus, [lhs, comparator]), "t0", 5);
+ if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
+ // if either side is undefined, the result is undefined
+ return result;
+ }
- case 5:
- result = _context14.t0;
- return _context14.abrupt("return", result);
+ switch (op) {
+ case '+':
+ result = lhs + rhs;
+ break;
- case 7:
- case "end":
- return _context14.stop();
- }
- }
- }, _marked13);
- }
- /**
- * create a transformer function
- * @param {Object} expr - AST for operator
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} tranformer function
- */
-
-
- function evaluateTransformExpression(expr, input, environment) {
- // create a function to implement the transform definition
- var transformer =
- /*#__PURE__*/
- regeneratorRuntime.mark(function transformer(obj) {
- var cloneFunction, result, matches, ii, match, update, updateType, prop, deletions, val, jj;
- return regeneratorRuntime.wrap(function transformer$(_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- if (!(typeof obj === 'undefined')) {
- _context15.next = 2;
- break;
- }
+ case '-':
+ result = lhs - rhs;
+ break;
- return _context15.abrupt("return", undefined);
+ case '*':
+ result = lhs * rhs;
+ break;
- case 2:
- // this function returns a copy of obj with changes specified by the pattern/operation
- cloneFunction = environment.lookup('clone');
+ case '/':
+ result = lhs / rhs;
+ break;
- if (isFunction(cloneFunction)) {
- _context15.next = 5;
- break;
+ case '%':
+ result = lhs % rhs;
+ break;
}
- throw {
- code: "T2013",
- stack: new Error().stack,
- position: expr.position
- };
+ return result;
+ }
+ /**
+ * Evaluate equality expression against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @param {Object} op - opcode
+ * @returns {*} Result
+ */
- case 5:
- return _context15.delegateYield(apply(cloneFunction, [obj], null, environment), "t0", 6);
+ function evaluateEqualityExpression(lhs, rhs, op) {
+ var result; // type checks
- case 6:
- result = _context15.t0;
- return _context15.delegateYield(_evaluate(expr.pattern, result, environment), "t1", 8);
+ var ltype = _typeof(lhs);
- case 8:
- matches = _context15.t1;
+ var rtype = _typeof(rhs);
- if (!(typeof matches !== 'undefined')) {
- _context15.next = 33;
- break;
+ if (ltype === 'undefined' || rtype === 'undefined') {
+ // if either side is undefined, the result is false
+ return false;
}
- if (!Array.isArray(matches)) {
- matches = [matches];
+ switch (op) {
+ case '=':
+ result = isDeepEqual(lhs, rhs);
+ break;
+
+ case '!=':
+ result = !isDeepEqual(lhs, rhs);
+ break;
}
- ii = 0;
+ return result;
+ }
+ /**
+ * Evaluate comparison expression against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @param {Object} op - opcode
+ * @returns {*} Result
+ */
- case 12:
- if (!(ii < matches.length)) {
- _context15.next = 33;
- break;
- }
+ function evaluateComparisonExpression(lhs, rhs, op) {
+ var result; // type checks
- match = matches[ii]; // evaluate the update value for each match
+ var ltype = _typeof(lhs);
- return _context15.delegateYield(_evaluate(expr.update, match, environment), "t2", 15);
+ var rtype = _typeof(rhs);
- case 15:
- update = _context15.t2;
- // update must be an object
- updateType = _typeof(update);
+ var lcomparable = ltype === 'undefined' || ltype === 'string' || ltype === 'number';
+ var rcomparable = rtype === 'undefined' || rtype === 'string' || rtype === 'number'; // if either aa or bb are not comparable (string or numeric) values, then throw an error
- if (!(updateType !== 'undefined')) {
- _context15.next = 21;
- break;
- }
+ if (!lcomparable || !rcomparable) {
+ throw {
+ code: 'T2010',
+ stack: new Error().stack,
+ value: !(ltype === 'string' || ltype === 'number') ? lhs : rhs,
+ };
+ } // if either side is undefined, the result is undefined
- if (!(updateType !== 'object' || update === null || Array.isArray(update))) {
- _context15.next = 20;
- break;
+ if (ltype === 'undefined' || rtype === 'undefined') {
+ return undefined;
+ } //if aa and bb are not of the same type
+
+ if (ltype !== rtype) {
+ throw {
+ code: 'T2009',
+ stack: new Error().stack,
+ value: lhs,
+ value2: rhs,
+ };
}
- throw {
- code: "T2011",
- stack: new Error().stack,
- position: expr.update.position,
- value: update
- };
+ switch (op) {
+ case '<':
+ result = lhs < rhs;
+ break;
- case 20:
- // merge the update
- for (prop in update) {
- match[prop] = update[prop];
- }
+ case '<=':
+ result = lhs <= rhs;
+ break;
- case 21:
- if (!(typeof expr["delete"] !== 'undefined')) {
- _context15.next = 30;
- break;
+ case '>':
+ result = lhs > rhs;
+ break;
+
+ case '>=':
+ result = lhs >= rhs;
+ break;
}
- return _context15.delegateYield(_evaluate(expr["delete"], match, environment), "t3", 23);
+ return result;
+ }
+ /**
+ * Inclusion operator - in
+ *
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @returns {boolean} - true if lhs is a member of rhs
+ */
+
+ function evaluateIncludesExpression(lhs, rhs) {
+ var result = false;
+
+ if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
+ // if either side is undefined, the result is false
+ return false;
+ }
- case 23:
- deletions = _context15.t3;
+ if (!Array.isArray(rhs)) {
+ rhs = [rhs];
+ }
- if (!(typeof deletions !== 'undefined')) {
- _context15.next = 30;
- break;
+ for (var i = 0; i < rhs.length; i++) {
+ if (rhs[i] === lhs) {
+ result = true;
+ break;
+ }
}
- val = deletions;
+ return result;
+ }
+ /**
+ * Evaluate boolean expression against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @param {Object} op - opcode
+ * @returns {*} Result
+ */
+
+ function evaluateBooleanExpression(lhs, rhs, op) {
+ var result;
+ var lBool = fn['boolean'](lhs);
+ var rBool = fn['boolean'](rhs);
- if (!Array.isArray(deletions)) {
- deletions = [deletions];
+ if (typeof lBool === 'undefined') {
+ lBool = false;
}
- if (isArrayOfStrings(deletions)) {
- _context15.next = 29;
- break;
+ if (typeof rBool === 'undefined') {
+ rBool = false;
}
- throw {
- code: "T2012",
- stack: new Error().stack,
- position: expr["delete"].position,
- value: val
- };
+ switch (op) {
+ case 'and':
+ result = lBool && rBool;
+ break;
- case 29:
- for (jj = 0; jj < deletions.length; jj++) {
- delete match[deletions[jj]];
+ case 'or':
+ result = lBool || rBool;
+ break;
}
- case 30:
- ii++;
- _context15.next = 12;
- break;
+ return result;
+ }
+ /**
+ * Evaluate string concatenation against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @returns {string|*} Concatenated string
+ */
- case 33:
- return _context15.abrupt("return", result);
+ function evaluateStringConcat(lhs, rhs) {
+ var result;
+ var lstr = '';
+ var rstr = '';
- case 34:
- case "end":
- return _context15.stop();
- }
- }
- }, transformer);
- });
- return defineFunction(transformer, '<(oa):o>');
- }
+ if (typeof lhs !== 'undefined') {
+ lstr = fn.string(lhs);
+ }
- var chainAST = parser('function($f, $g) { function($x){ $g($f($x)) } }');
- /**
- * Apply the function on the RHS using the sequence on the LHS as the first argument
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
- function evaluateApplyExpression(expr, input, environment) {
- var result, lhs, func, chain;
- return regeneratorRuntime.wrap(function evaluateApplyExpression$(_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- return _context16.delegateYield(_evaluate(expr.lhs, input, environment), "t0", 1);
-
- case 1:
- lhs = _context16.t0;
-
- if (!(expr.rhs.type === 'function')) {
- _context16.next = 7;
- break;
+ if (typeof rhs !== 'undefined') {
+ rstr = fn.string(rhs);
+ }
+
+ result = lstr.concat(rstr);
+ return result;
}
+ /**
+ * Evaluate group expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {{}} Evaluated input data
+ */
- return _context16.delegateYield(evaluateFunction(expr.rhs, input, environment, {
- context: lhs
- }), "t1", 4);
+ function evaluateGroupExpression(expr, input, environment) {
+ var result, groups, reduce, itemIndex, item, env, pairIndex, pair, key, entry, context, tuple, value;
+ return regeneratorRuntime.wrap(function evaluateGroupExpression$(_context9) {
+ while (1) {
+ switch ((_context9.prev = _context9.next)) {
+ case 0:
+ result = {};
+ groups = {};
+ reduce = input && input.tupleStream ? true : false; // group the input sequence by 'key' expression
- case 4:
- result = _context16.t1;
- _context16.next = 20;
- break;
+ if (!Array.isArray(input)) {
+ input = createSequence(input);
+ }
- case 7:
- return _context16.delegateYield(_evaluate(expr.rhs, input, environment), "t2", 8);
+ itemIndex = 0;
- case 8:
- func = _context16.t2;
+ case 5:
+ if (!(itemIndex < input.length)) {
+ _context9.next = 29;
+ break;
+ }
- if (isFunction(func)) {
- _context16.next = 11;
- break;
- }
+ item = input[itemIndex];
+ env = reduce ? createFrameFromTuple(environment, item) : environment;
+ pairIndex = 0;
- throw {
- code: "T2006",
- stack: new Error().stack,
- position: expr.position,
- value: func
- };
+ case 9:
+ if (!(pairIndex < expr.lhs.length)) {
+ _context9.next = 26;
+ break;
+ }
- case 11:
- if (!isFunction(lhs)) {
- _context16.next = 18;
- break;
- }
+ pair = expr.lhs[pairIndex];
+ return _context9.delegateYield(_evaluate(pair[0], reduce ? item['@'] : item, env), 't0', 12);
- return _context16.delegateYield(_evaluate(chainAST, null, environment), "t3", 13);
+ case 12:
+ key = _context9.t0;
- case 13:
- chain = _context16.t3;
- return _context16.delegateYield(apply(chain, [lhs, func], null, environment), "t4", 15);
+ if (!(typeof key !== 'string')) {
+ _context9.next = 15;
+ break;
+ }
- case 15:
- result = _context16.t4;
- _context16.next = 20;
- break;
+ throw {
+ code: 'T1003',
+ stack: new Error().stack,
+ position: expr.position,
+ value: key,
+ };
- case 18:
- return _context16.delegateYield(apply(func, [lhs], null, environment), "t5", 19);
+ case 15:
+ entry = {
+ data: item,
+ exprIndex: pairIndex,
+ };
- case 19:
- result = _context16.t5;
+ if (!groups.hasOwnProperty(key)) {
+ _context9.next = 22;
+ break;
+ }
- case 20:
- return _context16.abrupt("return", result);
+ if (!(groups[key].exprIndex !== pairIndex)) {
+ _context9.next = 19;
+ break;
+ }
- case 21:
- case "end":
- return _context16.stop();
- }
- }
- }, _marked14);
- }
- /**
- * Evaluate function against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluateFunction(expr, input, environment, applyto) {
- var result, proc, evaluatedArgs, _loop, jj, procName;
-
- return regeneratorRuntime.wrap(function evaluateFunction$(_context19) {
- while (1) {
- switch (_context19.prev = _context19.next) {
- case 0:
- return _context19.delegateYield(_evaluate(expr.procedure, input, environment), "t0", 1);
-
- case 1:
- proc = _context19.t0;
-
- if (!(typeof proc === 'undefined' && expr.procedure.type === 'path' && environment.lookup(expr.procedure.steps[0].value))) {
- _context19.next = 4;
- break;
- }
+ throw {
+ code: 'D1009',
+ stack: new Error().stack,
+ position: expr.position,
+ value: key,
+ };
- throw {
- code: "T1005",
- stack: new Error().stack,
- position: expr.position,
- token: expr.procedure.steps[0].value
- };
+ case 19:
+ // append it as an array
+ groups[key].data = fn.append(groups[key].data, item);
+ _context9.next = 23;
+ break;
- case 4:
- evaluatedArgs = [];
+ case 22:
+ groups[key] = entry;
- if (typeof applyto !== 'undefined') {
- evaluatedArgs.push(applyto.context);
- } // eager evaluation - evaluate the arguments
+ case 23:
+ pairIndex++;
+ _context9.next = 9;
+ break;
+ case 26:
+ itemIndex++;
+ _context9.next = 5;
+ break;
- _loop =
- /*#__PURE__*/
- regeneratorRuntime.mark(function _loop() {
- var arg, closure;
- return regeneratorRuntime.wrap(function _loop$(_context18) {
- while (1) {
- switch (_context18.prev = _context18.next) {
- case 0:
- return _context18.delegateYield(_evaluate(expr.arguments[jj], input, environment), "t0", 1);
+ case 29:
+ _context9.t1 = regeneratorRuntime.keys(groups);
- case 1:
- arg = _context18.t0;
+ case 30:
+ if ((_context9.t2 = _context9.t1()).done) {
+ _context9.next = 41;
+ break;
+ }
- if (isFunction(arg)) {
- // wrap this in a closure
- closure =
- /*#__PURE__*/
- regeneratorRuntime.mark(function closure() {
- var _len,
- params,
- _key,
- _args17 = arguments;
+ key = _context9.t2.value;
+ entry = groups[key];
+ context = entry.data;
+ env = environment;
- return regeneratorRuntime.wrap(function closure$(_context17) {
- while (1) {
- switch (_context17.prev = _context17.next) {
- case 0:
- for (_len = _args17.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
- params[_key] = _args17[_key];
- }
+ if (reduce) {
+ tuple = reduceTupleStream(entry.data);
+ context = tuple['@'];
+ delete tuple['@'];
+ env = createFrameFromTuple(environment, tuple);
+ }
- return _context17.delegateYield(apply(arg, params, null, environment), "t0", 2);
+ return _context9.delegateYield(_evaluate(expr.lhs[entry.exprIndex][1], context, env), 't3', 37);
- case 2:
- return _context17.abrupt("return", _context17.t0);
+ case 37:
+ value = _context9.t3;
- case 3:
- case "end":
- return _context17.stop();
- }
- }
- }, closure);
- });
- closure.arity = getFunctionArity(arg);
- evaluatedArgs.push(closure);
- } else {
- evaluatedArgs.push(arg);
+ if (typeof value !== 'undefined') {
+ result[key] = value;
}
- case 3:
- case "end":
- return _context18.stop();
+ _context9.next = 30;
+ break;
+
+ case 41:
+ return _context9.abrupt('return', result);
+
+ case 42:
+ case 'end':
+ return _context9.stop();
}
}
- }, _loop);
- });
- jj = 0;
-
- case 8:
- if (!(jj < expr.arguments.length)) {
- _context19.next = 13;
- break;
+ }, _marked9);
}
- return _context19.delegateYield(_loop(), "t1", 10);
+ function reduceTupleStream(tupleStream) {
+ if (!Array.isArray(tupleStream)) {
+ return tupleStream;
+ }
- case 10:
- jj++;
- _context19.next = 8;
- break;
+ var result = {};
+ Object.assign(result, tupleStream[0]);
- case 13:
- // apply the procedure
- procName = expr.procedure.type === 'path' ? expr.procedure.steps[0].value : expr.procedure.value;
- _context19.prev = 14;
+ for (var ii = 1; ii < tupleStream.length; ii++) {
+ for (var prop in tupleStream[ii]) {
+ result[prop] = fn.append(result[prop], tupleStream[ii][prop]);
+ }
+ }
- if (_typeof(proc) === 'object') {
- proc.token = procName;
- proc.position = expr.position;
+ return result;
}
+ /**
+ * Evaluate range expression against input data
+ * @param {Object} lhs - LHS value
+ * @param {Object} rhs - RHS value
+ * @returns {Array} Resultant array
+ */
- return _context19.delegateYield(apply(proc, evaluatedArgs, input, environment), "t2", 17);
+ function evaluateRangeExpression(lhs, rhs) {
+ var result;
- case 17:
- result = _context19.t2;
- _context19.next = 25;
- break;
+ if (typeof lhs !== 'undefined' && !Number.isInteger(lhs)) {
+ throw {
+ code: 'T2003',
+ stack: new Error().stack,
+ value: lhs,
+ };
+ }
- case 20:
- _context19.prev = 20;
- _context19.t3 = _context19["catch"](14);
+ if (typeof rhs !== 'undefined' && !Number.isInteger(rhs)) {
+ throw {
+ code: 'T2004',
+ stack: new Error().stack,
+ value: rhs,
+ };
+ }
- if (!_context19.t3.position) {
- // add the position field to the error
- _context19.t3.position = expr.position;
- }
+ if (typeof lhs === 'undefined' || typeof rhs === 'undefined') {
+ // if either side is undefined, the result is undefined
+ return result;
+ }
- if (!_context19.t3.token) {
- // and the function identifier
- _context19.t3.token = procName;
- }
+ if (lhs > rhs) {
+ // if the lhs is greater than the rhs, return undefined
+ return result;
+ } // limit the size of the array to ten million entries (1e7)
+ // this is an implementation defined limit to protect against
+ // memory and performance issues. This value may increase in the future.
- throw _context19.t3;
+ var size = rhs - lhs + 1;
- case 25:
- return _context19.abrupt("return", result);
+ if (size > 1e7) {
+ throw {
+ code: 'D2014',
+ stack: new Error().stack,
+ value: size,
+ };
+ }
- case 26:
- case "end":
- return _context19.stop();
- }
- }
- }, _marked15, null, [[14, 20]]);
- }
- /**
- * Apply procedure or function
- * @param {Object} proc - Procedure
- * @param {Array} args - Arguments
- * @param {Object} input - input
- * @param {Object} environment - environment
- * @returns {*} Result of procedure
- */
-
-
- function apply(proc, args, input, environment) {
- var result, next, evaluatedArgs, ii;
- return regeneratorRuntime.wrap(function apply$(_context20) {
- while (1) {
- switch (_context20.prev = _context20.next) {
- case 0:
- return _context20.delegateYield(applyInner(proc, args, input, environment), "t0", 1);
-
- case 1:
- result = _context20.t0;
-
- case 2:
- if (!(isLambda(result) && result.thunk === true)) {
- _context20.next = 21;
- break;
+ result = new Array(size);
+
+ for (var item = lhs, index = 0; item <= rhs; item++, index++) {
+ result[index] = item;
+ }
+
+ result.sequence = true;
+ return result;
}
+ /**
+ * Evaluate bind expression against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
- return _context20.delegateYield(_evaluate(result.body.procedure, result.input, result.environment), "t1", 4);
+ function evaluateBindExpression(expr, input, environment) {
+ var value;
+ return regeneratorRuntime.wrap(function evaluateBindExpression$(_context10) {
+ while (1) {
+ switch ((_context10.prev = _context10.next)) {
+ case 0:
+ return _context10.delegateYield(_evaluate(expr.rhs, input, environment), 't0', 1);
- case 4:
- next = _context20.t1;
+ case 1:
+ value = _context10.t0;
+ environment.bind(expr.lhs.value, value);
+ return _context10.abrupt('return', value);
- if (result.body.procedure.type === 'variable') {
- next.token = result.body.procedure.value;
- }
+ case 4:
+ case 'end':
+ return _context10.stop();
+ }
+ }
+ }, _marked10);
+ }
+ /**
+ * Evaluate condition against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateCondition(expr, input, environment) {
+ var result, condition;
+ return regeneratorRuntime.wrap(function evaluateCondition$(_context11) {
+ while (1) {
+ switch ((_context11.prev = _context11.next)) {
+ case 0:
+ return _context11.delegateYield(_evaluate(expr.condition, input, environment), 't0', 1);
- next.position = result.body.procedure.position;
- evaluatedArgs = [];
- ii = 0;
+ case 1:
+ condition = _context11.t0;
- case 9:
- if (!(ii < result.body.arguments.length)) {
- _context20.next = 17;
- break;
- }
+ if (!fn['boolean'](condition)) {
+ _context11.next = 7;
+ break;
+ }
- _context20.t2 = evaluatedArgs;
- return _context20.delegateYield(_evaluate(result.body.arguments[ii], result.input, result.environment), "t3", 12);
+ return _context11.delegateYield(_evaluate(expr.then, input, environment), 't1', 4);
- case 12:
- _context20.t4 = _context20.t3;
+ case 4:
+ result = _context11.t1;
+ _context11.next = 10;
+ break;
- _context20.t2.push.call(_context20.t2, _context20.t4);
+ case 7:
+ if (!(typeof expr['else'] !== 'undefined')) {
+ _context11.next = 10;
+ break;
+ }
- case 14:
- ii++;
- _context20.next = 9;
- break;
+ return _context11.delegateYield(_evaluate(expr['else'], input, environment), 't2', 9);
- case 17:
- return _context20.delegateYield(applyInner(next, evaluatedArgs, input, environment), "t5", 18);
+ case 9:
+ result = _context11.t2;
- case 18:
- result = _context20.t5;
- _context20.next = 2;
- break;
+ case 10:
+ return _context11.abrupt('return', result);
- case 21:
- return _context20.abrupt("return", result);
+ case 11:
+ case 'end':
+ return _context11.stop();
+ }
+ }
+ }, _marked11);
+ }
+ /**
+ * Evaluate block against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateBlock(expr, input, environment) {
+ var result, frame, ii;
+ return regeneratorRuntime.wrap(function evaluateBlock$(_context12) {
+ while (1) {
+ switch ((_context12.prev = _context12.next)) {
+ case 0:
+ // create a new frame to limit the scope of variable assignments
+ // TODO, only do this if the post-parse stage has flagged this as required
+ frame = createFrame(environment); // invoke each expression in turn
+ // only return the result of the last one
- case 22:
- case "end":
- return _context20.stop();
- }
- }
- }, _marked16);
- }
- /**
- * Apply procedure or function
- * @param {Object} proc - Procedure
- * @param {Array} args - Arguments
- * @param {Object} input - input
- * @param {Object} environment - environment
- * @returns {*} Result of procedure
- */
-
-
- function applyInner(proc, args, input, environment) {
- var result, validatedArgs, focus;
- return regeneratorRuntime.wrap(function applyInner$(_context21) {
- while (1) {
- switch (_context21.prev = _context21.next) {
- case 0:
- _context21.prev = 0;
- validatedArgs = args;
-
- if (proc) {
- validatedArgs = validateArguments(proc.signature, args, input);
- }
+ ii = 0;
- if (!isLambda(proc)) {
- _context21.next = 8;
- break;
- }
+ case 2:
+ if (!(ii < expr.expressions.length)) {
+ _context12.next = 8;
+ break;
+ }
- return _context21.delegateYield(applyProcedure(proc, validatedArgs), "t0", 5);
+ return _context12.delegateYield(_evaluate(expr.expressions[ii], input, frame), 't0', 4);
- case 5:
- result = _context21.t0;
- _context21.next = 24;
- break;
+ case 4:
+ result = _context12.t0;
- case 8:
- if (!(proc && proc._jsonata_function === true)) {
- _context21.next = 16;
- break;
- }
+ case 5:
+ ii++;
+ _context12.next = 2;
+ break;
- focus = {
- environment: environment,
- input: input
- }; // the `focus` is passed in as the `this` for the invoked function
+ case 8:
+ return _context12.abrupt('return', result);
- result = proc.implementation.apply(focus, validatedArgs); // `proc.implementation` might be a generator function
- // and `result` might be a generator - if so, yield
+ case 9:
+ case 'end':
+ return _context12.stop();
+ }
+ }
+ }, _marked12);
+ }
+ /**
+ * Prepare a regex
+ * @param {Object} expr - expression containing regex
+ * @returns {Function} Higher order function representing prepared regex
+ */
+
+ function evaluateRegex(expr) {
+ var re = new RegExp(expr.value);
+
+ var closure = function closure(str) {
+ var result;
+ var match = re.exec(str);
+
+ if (match !== null) {
+ result = {
+ match: match[0],
+ start: match.index,
+ end: match.index + match[0].length,
+ groups: [],
+ };
- if (!isIterable(result)) {
- _context21.next = 14;
- break;
- }
+ if (match.length > 1) {
+ for (var i = 1; i < match.length; i++) {
+ result.groups.push(match[i]);
+ }
+ }
- return _context21.delegateYield(result, "t1", 13);
+ result.next = function () {
+ if (re.lastIndex >= str.length) {
+ return undefined;
+ } else {
+ var next = closure(str);
+
+ if (next && next.match === '') {
+ // matches zero length string; this will never progress
+ throw {
+ code: 'D1004',
+ stack: new Error().stack,
+ position: expr.position,
+ value: expr.value.source,
+ };
+ }
- case 13:
- result = _context21.t1;
+ return next;
+ }
+ };
+ }
- case 14:
- _context21.next = 24;
- break;
+ return result;
+ };
- case 16:
- if (!(typeof proc === 'function')) {
- _context21.next = 23;
- break;
+ return closure;
}
+ /**
+ * Evaluate variable against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateVariable(expr, input, environment) {
+ // lookup the variable value in the environment
+ var result; // if the variable name is empty string, then it refers to context value
- // typically these are functions that are returned by the invocation of plugin functions
- // the `input` is being passed in as the `this` for the invoked function
- // this is so that functions that return objects containing functions can chain
- // e.g. $func().next().next()
- result = proc.apply(input, validatedArgs);
- /* istanbul ignore next */
+ if (expr.value === '') {
+ result = input && input.outerWrapper ? input[0] : input;
+ } else {
+ result = environment.lookup(expr.value);
+ }
- if (!isIterable(result)) {
- _context21.next = 21;
- break;
+ return result;
}
+ /**
+ * sort / order-by operator
+ * @param {Object} expr - AST for operator
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Ordered sequence
+ */
- return _context21.delegateYield(result, "t2", 20);
+ function evaluateSortExpression(expr, input, environment) {
+ var result, lhs, isTupleSort, comparator, focus;
+ return regeneratorRuntime.wrap(function evaluateSortExpression$(_context14) {
+ while (1) {
+ switch ((_context14.prev = _context14.next)) {
+ case 0:
+ // evaluate the lhs, then sort the results in order according to rhs expression
+ //var lhs = yield * evaluate(expr.lhs, input, environment);
+ lhs = input;
+ isTupleSort = input.tupleStream ? true : false; // sort the lhs array
+ // use comparator function
- case 20:
- result = _context21.t2;
+ comparator =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function comparator(a, b) {
+ var comp, index, term, context, env, aa, bb, atype, btype;
+ return regeneratorRuntime.wrap(function comparator$(_context13) {
+ while (1) {
+ switch ((_context13.prev = _context13.next)) {
+ case 0:
+ // eslint-disable-line require-yield
+ // expr.terms is an array of order-by in priority order
+ comp = 0;
+ index = 0;
- case 21:
- _context21.next = 24;
- break;
+ case 2:
+ if (!(comp === 0 && index < expr.terms.length)) {
+ _context13.next = 35;
+ break;
+ }
- case 23:
- throw {
- code: "T1006",
- stack: new Error().stack
- };
+ term = expr.terms[index]; //evaluate the sort term in the context of a
- case 24:
- _context21.next = 30;
- break;
+ context = a;
+ env = environment;
- case 26:
- _context21.prev = 26;
- _context21.t3 = _context21["catch"](0);
+ if (isTupleSort) {
+ context = a['@'];
+ env = createFrameFromTuple(environment, a);
+ }
- if (proc) {
- if (typeof _context21.t3.token == 'undefined' && typeof proc.token !== 'undefined') {
- _context21.t3.token = proc.token;
- }
+ return _context13.delegateYield(_evaluate(term.expression, context, env), 't0', 8);
- _context21.t3.position = proc.position;
- }
+ case 8:
+ aa = _context13.t0;
+ //evaluate the sort term in the context of b
+ context = b;
+ env = environment;
- throw _context21.t3;
+ if (isTupleSort) {
+ context = b['@'];
+ env = createFrameFromTuple(environment, b);
+ }
- case 30:
- return _context21.abrupt("return", result);
+ return _context13.delegateYield(_evaluate(term.expression, context, env), 't1', 13);
- case 31:
- case "end":
- return _context21.stop();
- }
- }
- }, _marked17, null, [[0, 26]]);
- }
- /**
- * Evaluate lambda against input data
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {{lambda: boolean, input: *, environment: *, arguments: *, body: *}} Evaluated input data
- */
-
-
- function evaluateLambda(expr, input, environment) {
- // make a function (closure)
- var procedure = {
- _jsonata_lambda: true,
- input: input,
- environment: environment,
- arguments: expr.arguments,
- signature: expr.signature,
- body: expr.body
- };
+ case 13:
+ bb = _context13.t1;
+ // type checks
+ atype = _typeof(aa);
+ btype = _typeof(bb); // undefined should be last in sort order
- if (expr.thunk === true) {
- procedure.thunk = true;
- }
+ if (!(atype === 'undefined')) {
+ _context13.next = 19;
+ break;
+ }
- procedure.apply =
- /*#__PURE__*/
- regeneratorRuntime.mark(function _callee(self, args) {
- return regeneratorRuntime.wrap(function _callee$(_context22) {
- while (1) {
- switch (_context22.prev = _context22.next) {
- case 0:
- return _context22.delegateYield(apply(procedure, args, input, self.environment), "t0", 1);
-
- case 1:
- return _context22.abrupt("return", _context22.t0);
-
- case 2:
- case "end":
- return _context22.stop();
- }
- }
- }, _callee);
- });
- return procedure;
- }
- /**
- * Evaluate partial application
- * @param {Object} expr - JSONata expression
- * @param {Object} input - Input data to evaluate against
- * @param {Object} environment - Environment
- * @returns {*} Evaluated input data
- */
-
-
- function evaluatePartialApplication(expr, input, environment) {
- var result, evaluatedArgs, ii, arg, proc;
- return regeneratorRuntime.wrap(function evaluatePartialApplication$(_context23) {
- while (1) {
- switch (_context23.prev = _context23.next) {
- case 0:
- // partially apply a function
- // evaluate the arguments
- evaluatedArgs = [];
- ii = 0;
-
- case 2:
- if (!(ii < expr.arguments.length)) {
- _context23.next = 15;
- break;
- }
+ // swap them, unless btype is also undefined
+ comp = btype === 'undefined' ? 0 : 1;
+ return _context13.abrupt('continue', 32);
- arg = expr.arguments[ii];
+ case 19:
+ if (!(btype === 'undefined')) {
+ _context13.next = 22;
+ break;
+ }
- if (!(arg.type === 'operator' && arg.value === '?')) {
- _context23.next = 8;
- break;
- }
+ comp = -1;
+ return _context13.abrupt('continue', 32);
+
+ case 22:
+ if (
+ !(
+ !(atype === 'string' || atype === 'number') ||
+ !(btype === 'string' || btype === 'number')
+ )
+ ) {
+ _context13.next = 24;
+ break;
+ }
- evaluatedArgs.push(arg);
- _context23.next = 12;
- break;
+ throw {
+ code: 'T2008',
+ stack: new Error().stack,
+ position: expr.position,
+ value: !(atype === 'string' || atype === 'number') ? aa : bb,
+ };
+
+ case 24:
+ if (!(atype !== btype)) {
+ _context13.next = 26;
+ break;
+ }
- case 8:
- _context23.t0 = evaluatedArgs;
- return _context23.delegateYield(_evaluate(arg, input, environment), "t1", 10);
+ throw {
+ code: 'T2007',
+ stack: new Error().stack,
+ position: expr.position,
+ value: aa,
+ value2: bb,
+ };
+
+ case 26:
+ if (!(aa === bb)) {
+ _context13.next = 30;
+ break;
+ }
- case 10:
- _context23.t2 = _context23.t1;
+ return _context13.abrupt('continue', 32);
- _context23.t0.push.call(_context23.t0, _context23.t2);
+ case 30:
+ if (aa < bb) {
+ comp = -1;
+ } else {
+ comp = 1;
+ }
- case 12:
- ii++;
- _context23.next = 2;
- break;
+ case 31:
+ if (term.descending === true) {
+ comp = -comp;
+ }
- case 15:
- return _context23.delegateYield(_evaluate(expr.procedure, input, environment), "t3", 16);
+ case 32:
+ index++;
+ _context13.next = 2;
+ break;
- case 16:
- proc = _context23.t3;
+ case 35:
+ return _context13.abrupt('return', comp === 1);
- if (!(typeof proc === 'undefined' && expr.procedure.type === 'path' && environment.lookup(expr.procedure.steps[0].value))) {
- _context23.next = 19;
- break;
- }
+ case 36:
+ case 'end':
+ return _context13.stop();
+ }
+ }
+ }, comparator);
+ });
+ focus = {
+ environment: environment,
+ input: input,
+ }; // the `focus` is passed in as the `this` for the invoked function
- throw {
- code: "T1007",
- stack: new Error().stack,
- position: expr.position,
- token: expr.procedure.steps[0].value
- };
+ return _context14.delegateYield(fn.sort.apply(focus, [lhs, comparator]), 't0', 5);
- case 19:
- if (!isLambda(proc)) {
- _context23.next = 23;
- break;
- }
+ case 5:
+ result = _context14.t0;
+ return _context14.abrupt('return', result);
- result = partialApplyProcedure(proc, evaluatedArgs);
- _context23.next = 32;
- break;
+ case 7:
+ case 'end':
+ return _context14.stop();
+ }
+ }
+ }, _marked13);
+ }
+ /**
+ * create a transformer function
+ * @param {Object} expr - AST for operator
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} tranformer function
+ */
+
+ function evaluateTransformExpression(expr, input, environment) {
+ // create a function to implement the transform definition
+ var transformer =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function transformer(obj) {
+ var cloneFunction, result, matches, ii, match, update, updateType, prop, deletions, val, jj;
+ return regeneratorRuntime.wrap(function transformer$(_context15) {
+ while (1) {
+ switch ((_context15.prev = _context15.next)) {
+ case 0:
+ if (!(typeof obj === 'undefined')) {
+ _context15.next = 2;
+ break;
+ }
- case 23:
- if (!(proc && proc._jsonata_function === true)) {
- _context23.next = 27;
- break;
- }
+ return _context15.abrupt('return', undefined);
- result = partialApplyNativeFunction(proc.implementation, evaluatedArgs);
- _context23.next = 32;
- break;
+ case 2:
+ // this function returns a copy of obj with changes specified by the pattern/operation
+ cloneFunction = environment.lookup('clone');
- case 27:
- if (!(typeof proc === 'function')) {
- _context23.next = 31;
- break;
- }
+ if (isFunction(cloneFunction)) {
+ _context15.next = 5;
+ break;
+ }
- result = partialApplyNativeFunction(proc, evaluatedArgs);
- _context23.next = 32;
- break;
+ throw {
+ code: 'T2013',
+ stack: new Error().stack,
+ position: expr.position,
+ };
- case 31:
- throw {
- code: "T1008",
- stack: new Error().stack,
- position: expr.position,
- token: expr.procedure.type === 'path' ? expr.procedure.steps[0].value : expr.procedure.value
- };
+ case 5:
+ return _context15.delegateYield(apply(cloneFunction, [obj], null, environment), 't0', 6);
- case 32:
- return _context23.abrupt("return", result);
+ case 6:
+ result = _context15.t0;
+ return _context15.delegateYield(_evaluate(expr.pattern, result, environment), 't1', 8);
- case 33:
- case "end":
- return _context23.stop();
- }
- }
- }, _marked18);
- }
- /**
- * Validate the arguments against the signature validator (if it exists)
- * @param {Function} signature - validator function
- * @param {Array} args - function arguments
- * @param {*} context - context value
- * @returns {Array} - validated arguments
- */
-
-
- function validateArguments(signature, args, context) {
- if (typeof signature === 'undefined') {
- // nothing to validate
- return args;
- }
+ case 8:
+ matches = _context15.t1;
- var validatedArgs = signature.validate(args, context);
- return validatedArgs;
- }
- /**
- * Apply procedure
- * @param {Object} proc - Procedure
- * @param {Array} args - Arguments
- * @returns {*} Result of procedure
- */
-
-
- function applyProcedure(proc, args) {
- var result, env;
- return regeneratorRuntime.wrap(function applyProcedure$(_context24) {
- while (1) {
- switch (_context24.prev = _context24.next) {
- case 0:
- env = createFrame(proc.environment);
- proc.arguments.forEach(function (param, index) {
- env.bind(param.value, args[index]);
- });
+ if (!(typeof matches !== 'undefined')) {
+ _context15.next = 33;
+ break;
+ }
- if (!(typeof proc.body === 'function')) {
- _context24.next = 7;
- break;
- }
+ if (!Array.isArray(matches)) {
+ matches = [matches];
+ }
- return _context24.delegateYield(applyNativeFunction(proc.body, env), "t0", 4);
+ ii = 0;
- case 4:
- result = _context24.t0;
- _context24.next = 9;
- break;
+ case 12:
+ if (!(ii < matches.length)) {
+ _context15.next = 33;
+ break;
+ }
- case 7:
- return _context24.delegateYield(_evaluate(proc.body, proc.input, env), "t1", 8);
+ match = matches[ii]; // evaluate the update value for each match
- case 8:
- result = _context24.t1;
+ return _context15.delegateYield(_evaluate(expr.update, match, environment), 't2', 15);
- case 9:
- return _context24.abrupt("return", result);
+ case 15:
+ update = _context15.t2;
+ // update must be an object
+ updateType = _typeof(update);
- case 10:
- case "end":
- return _context24.stop();
- }
- }
- }, _marked19);
- }
- /**
- * Partially apply procedure
- * @param {Object} proc - Procedure
- * @param {Array} args - Arguments
- * @returns {{lambda: boolean, input: *, environment: {bind, lookup}, arguments: Array, body: *}} Result of partially applied procedure
- */
-
-
- function partialApplyProcedure(proc, args) {
- // create a closure, bind the supplied parameters and return a function that takes the remaining (?) parameters
- var env = createFrame(proc.environment);
- var unboundArgs = [];
- proc.arguments.forEach(function (param, index) {
- var arg = args[index];
-
- if (arg && arg.type === 'operator' && arg.value === '?') {
- unboundArgs.push(param);
- } else {
- env.bind(param.value, arg);
- }
- });
- var procedure = {
- _jsonata_lambda: true,
- input: proc.input,
- environment: env,
- arguments: unboundArgs,
- body: proc.body
- };
- return procedure;
- }
- /**
- * Partially apply native function
- * @param {Function} native - Native function
- * @param {Array} args - Arguments
- * @returns {{lambda: boolean, input: *, environment: {bind, lookup}, arguments: Array, body: *}} Result of partially applying native function
- */
-
-
- function partialApplyNativeFunction(_native, args) {
- // create a lambda function that wraps and invokes the native function
- // get the list of declared arguments from the native function
- // this has to be picked out from the toString() value
- var sigArgs = getNativeFunctionArguments(_native);
- sigArgs = sigArgs.map(function (sigArg) {
- return '$' + sigArg.trim();
- });
- var body = 'function(' + sigArgs.join(', ') + '){ _ }';
- var bodyAST = parser(body);
- bodyAST.body = _native;
- var partial = partialApplyProcedure(bodyAST, args);
- return partial;
- }
- /**
- * Apply native function
- * @param {Object} proc - Procedure
- * @param {Object} env - Environment
- * @returns {*} Result of applying native function
- */
-
-
- function applyNativeFunction(proc, env) {
- var sigArgs, args, focus, result;
- return regeneratorRuntime.wrap(function applyNativeFunction$(_context25) {
- while (1) {
- switch (_context25.prev = _context25.next) {
- case 0:
- sigArgs = getNativeFunctionArguments(proc); // generate the array of arguments for invoking the function - look them up in the environment
-
- args = sigArgs.map(function (sigArg) {
- return env.lookup(sigArg.trim());
- });
- focus = {
- environment: env
- };
- result = proc.apply(focus, args);
+ if (!(updateType !== 'undefined')) {
+ _context15.next = 21;
+ break;
+ }
+
+ if (!(updateType !== 'object' || update === null || Array.isArray(update))) {
+ _context15.next = 20;
+ break;
+ }
+
+ throw {
+ code: 'T2011',
+ stack: new Error().stack,
+ position: expr.update.position,
+ value: update,
+ };
+
+ case 20:
+ // merge the update
+ for (prop in update) {
+ match[prop] = update[prop];
+ }
+
+ case 21:
+ if (!(typeof expr['delete'] !== 'undefined')) {
+ _context15.next = 30;
+ break;
+ }
+
+ return _context15.delegateYield(_evaluate(expr['delete'], match, environment), 't3', 23);
+
+ case 23:
+ deletions = _context15.t3;
+
+ if (!(typeof deletions !== 'undefined')) {
+ _context15.next = 30;
+ break;
+ }
+
+ val = deletions;
+
+ if (!Array.isArray(deletions)) {
+ deletions = [deletions];
+ }
+
+ if (isArrayOfStrings(deletions)) {
+ _context15.next = 29;
+ break;
+ }
+
+ throw {
+ code: 'T2012',
+ stack: new Error().stack,
+ position: expr['delete'].position,
+ value: val,
+ };
- if (!isIterable(result)) {
- _context25.next = 7;
- break;
+ case 29:
+ for (jj = 0; jj < deletions.length; jj++) {
+ delete match[deletions[jj]];
+ }
+
+ case 30:
+ ii++;
+ _context15.next = 12;
+ break;
+
+ case 33:
+ return _context15.abrupt('return', result);
+
+ case 34:
+ case 'end':
+ return _context15.stop();
+ }
+ }
+ }, transformer);
+ });
+ return defineFunction(transformer, '<(oa):o>');
}
- return _context25.delegateYield(result, "t0", 6);
+ var chainAST = parser('function($f, $g) { function($x){ $g($f($x)) } }');
+ /**
+ * Apply the function on the RHS using the sequence on the LHS as the first argument
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
- case 6:
- result = _context25.t0;
+ function evaluateApplyExpression(expr, input, environment) {
+ var result, lhs, func, chain;
+ return regeneratorRuntime.wrap(function evaluateApplyExpression$(_context16) {
+ while (1) {
+ switch ((_context16.prev = _context16.next)) {
+ case 0:
+ return _context16.delegateYield(_evaluate(expr.lhs, input, environment), 't0', 1);
- case 7:
- return _context25.abrupt("return", result);
+ case 1:
+ lhs = _context16.t0;
- case 8:
- case "end":
- return _context25.stop();
- }
- }
- }, _marked20);
- }
- /**
- * Get native function arguments
- * @param {Function} func - Function
- * @returns {*|Array} Native function arguments
- */
+ if (!(expr.rhs.type === 'function')) {
+ _context16.next = 7;
+ break;
+ }
+ return _context16.delegateYield(
+ evaluateFunction(expr.rhs, input, environment, {
+ context: lhs,
+ }),
+ 't1',
+ 4
+ );
- function getNativeFunctionArguments(func) {
- var signature = func.toString();
- var sigParens = /\(([^)]*)\)/.exec(signature)[1]; // the contents of the parens
+ case 4:
+ result = _context16.t1;
+ _context16.next = 20;
+ break;
- var sigArgs = sigParens.split(',');
- return sigArgs;
- }
- /**
- * Creates a function definition
- * @param {Function} func - function implementation in Javascript
- * @param {string} signature - JSONata function signature definition
- * @returns {{implementation: *, signature: *}} function definition
- */
-
-
- function defineFunction(func, signature) {
- var definition = {
- _jsonata_function: true,
- implementation: func
- };
+ case 7:
+ return _context16.delegateYield(_evaluate(expr.rhs, input, environment), 't2', 8);
- if (typeof signature !== 'undefined') {
- definition.signature = parseSignature(signature);
- }
+ case 8:
+ func = _context16.t2;
- return definition;
- }
- /**
- * parses and evaluates the supplied expression
- * @param {string} expr - expression to evaluate
- * @returns {*} - result of evaluating the expression
- */
-
-
- function functionEval(expr, focus) {
- var input, ast, result;
- return regeneratorRuntime.wrap(function functionEval$(_context26) {
- while (1) {
- switch (_context26.prev = _context26.next) {
- case 0:
- if (!(typeof expr === 'undefined')) {
- _context26.next = 2;
- break;
- }
+ if (isFunction(func)) {
+ _context16.next = 11;
+ break;
+ }
- return _context26.abrupt("return", undefined);
+ throw {
+ code: 'T2006',
+ stack: new Error().stack,
+ position: expr.position,
+ value: func,
+ };
- case 2:
- input = this.input;
+ case 11:
+ if (!isFunction(lhs)) {
+ _context16.next = 18;
+ break;
+ }
- if (typeof focus !== 'undefined') {
- input = focus;
- }
+ return _context16.delegateYield(_evaluate(chainAST, null, environment), 't3', 13);
- _context26.prev = 4;
- ast = parser(expr, false);
- _context26.next = 12;
- break;
-
- case 8:
- _context26.prev = 8;
- _context26.t0 = _context26["catch"](4);
- // error parsing the expression passed to $eval
- populateMessage(_context26.t0);
- throw {
- stack: new Error().stack,
- code: "D3120",
- value: _context26.t0.message,
- error: _context26.t0
- };
+ case 13:
+ chain = _context16.t3;
+ return _context16.delegateYield(apply(chain, [lhs, func], null, environment), 't4', 15);
- case 12:
- _context26.prev = 12;
- return _context26.delegateYield(_evaluate(ast, input, this.environment), "t1", 14);
-
- case 14:
- result = _context26.t1;
- _context26.next = 21;
- break;
-
- case 17:
- _context26.prev = 17;
- _context26.t2 = _context26["catch"](12);
- // error evaluating the expression passed to $eval
- populateMessage(_context26.t2);
- throw {
- stack: new Error().stack,
- code: "D3121",
- value: _context26.t2.message,
- error: _context26.t2
- };
+ case 15:
+ result = _context16.t4;
+ _context16.next = 20;
+ break;
- case 21:
- return _context26.abrupt("return", result);
+ case 18:
+ return _context16.delegateYield(apply(func, [lhs], null, environment), 't5', 19);
- case 22:
- case "end":
- return _context26.stop();
- }
- }
- }, _marked21, this, [[4, 8], [12, 17]]);
- }
- /**
- * Clones an object
- * @param {Object} arg - object to clone (deep copy)
- * @returns {*} - the cloned object
- */
+ case 19:
+ result = _context16.t5;
+ case 20:
+ return _context16.abrupt('return', result);
- function functionClone(arg) {
- // undefined inputs always return undefined
- if (typeof arg === 'undefined') {
- return undefined;
- }
+ case 21:
+ case 'end':
+ return _context16.stop();
+ }
+ }
+ }, _marked14);
+ }
+ /**
+ * Evaluate function against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluateFunction(expr, input, environment, applyto) {
+ var result, proc, evaluatedArgs, _loop, jj, procName;
+
+ return regeneratorRuntime.wrap(
+ function evaluateFunction$(_context19) {
+ while (1) {
+ switch ((_context19.prev = _context19.next)) {
+ case 0:
+ return _context19.delegateYield(_evaluate(expr.procedure, input, environment), 't0', 1);
+
+ case 1:
+ proc = _context19.t0;
+
+ if (
+ !(
+ typeof proc === 'undefined' &&
+ expr.procedure.type === 'path' &&
+ environment.lookup(expr.procedure.steps[0].value)
+ )
+ ) {
+ _context19.next = 4;
+ break;
+ }
- return JSON.parse(fn.string(arg));
- }
- /**
- * Create frame
- * @param {Object} enclosingEnvironment - Enclosing environment
- * @returns {{bind: bind, lookup: lookup}} Created frame
- */
-
-
- function createFrame(enclosingEnvironment) {
- var bindings = {};
- return {
- bind: function bind(name, value) {
- bindings[name] = value;
- },
- lookup: function lookup(name) {
- var value;
-
- if (bindings.hasOwnProperty(name)) {
- value = bindings[name];
- } else if (enclosingEnvironment) {
- value = enclosingEnvironment.lookup(name);
- }
+ throw {
+ code: 'T1005',
+ stack: new Error().stack,
+ position: expr.position,
+ token: expr.procedure.steps[0].value,
+ };
+
+ case 4:
+ evaluatedArgs = [];
+
+ if (typeof applyto !== 'undefined') {
+ evaluatedArgs.push(applyto.context);
+ } // eager evaluation - evaluate the arguments
+
+ _loop =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function _loop() {
+ var arg, closure;
+ return regeneratorRuntime.wrap(function _loop$(_context18) {
+ while (1) {
+ switch ((_context18.prev = _context18.next)) {
+ case 0:
+ return _context18.delegateYield(
+ _evaluate(expr.arguments[jj], input, environment),
+ 't0',
+ 1
+ );
+
+ case 1:
+ arg = _context18.t0;
+
+ if (isFunction(arg)) {
+ // wrap this in a closure
+ closure =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function closure() {
+ var _len,
+ params,
+ _key,
+ _args17 = arguments;
+
+ return regeneratorRuntime.wrap(function closure$(_context17) {
+ while (1) {
+ switch ((_context17.prev = _context17.next)) {
+ case 0:
+ for (
+ _len = _args17.length, params = new Array(_len), _key = 0;
+ _key < _len;
+ _key++
+ ) {
+ params[_key] = _args17[_key];
+ }
+
+ return _context17.delegateYield(
+ apply(arg, params, null, environment),
+ 't0',
+ 2
+ );
+
+ case 2:
+ return _context17.abrupt('return', _context17.t0);
+
+ case 3:
+ case 'end':
+ return _context17.stop();
+ }
+ }
+ }, closure);
+ });
+ closure.arity = getFunctionArity(arg);
+ evaluatedArgs.push(closure);
+ } else {
+ evaluatedArgs.push(arg);
+ }
+
+ case 3:
+ case 'end':
+ return _context18.stop();
+ }
+ }
+ }, _loop);
+ });
+ jj = 0;
+
+ case 8:
+ if (!(jj < expr.arguments.length)) {
+ _context19.next = 13;
+ break;
+ }
- return value;
- },
- timestamp: enclosingEnvironment ? enclosingEnvironment.timestamp : null,
- async: enclosingEnvironment ? enclosingEnvironment.async : false
- };
- } // Function registration
-
-
- staticFrame.bind('sum', defineFunction(fn.sum, ':n>'));
- staticFrame.bind('count', defineFunction(fn.count, ''));
- staticFrame.bind('max', defineFunction(fn.max, ':n>'));
- staticFrame.bind('min', defineFunction(fn.min, ':n>'));
- staticFrame.bind('average', defineFunction(fn.average, ':n>'));
- staticFrame.bind('string', defineFunction(fn.string, ''));
- staticFrame.bind('substring', defineFunction(fn.substring, ''));
- staticFrame.bind('substringBefore', defineFunction(fn.substringBefore, ''));
- staticFrame.bind('substringAfter', defineFunction(fn.substringAfter, ''));
- staticFrame.bind('lowercase', defineFunction(fn.lowercase, ''));
- staticFrame.bind('uppercase', defineFunction(fn.uppercase, ''));
- staticFrame.bind('length', defineFunction(fn.length, ''));
- staticFrame.bind('trim', defineFunction(fn.trim, ''));
- staticFrame.bind('pad', defineFunction(fn.pad, ''));
- staticFrame.bind('match', defineFunction(fn.match, 'n?:a>'));
- staticFrame.bind('contains', defineFunction(fn.contains, '')); // TODO ):b>
-
- staticFrame.bind('replace', defineFunction(fn.replace, '')); // TODO )(sf)n?:s>
-
- staticFrame.bind('split', defineFunction(fn.split, '>')); // TODO )n?:a>
-
- staticFrame.bind('join', defineFunction(fn.join, 's?:s>'));
- staticFrame.bind('formatNumber', defineFunction(fn.formatNumber, ''));
- staticFrame.bind('formatBase', defineFunction(fn.formatBase, ''));
- staticFrame.bind('formatInteger', defineFunction(datetime.formatInteger, ''));
- staticFrame.bind('parseInteger', defineFunction(datetime.parseInteger, ''));
- staticFrame.bind('number', defineFunction(fn.number, '<(nsb)-:n>'));
- staticFrame.bind('floor', defineFunction(fn.floor, ''));
- staticFrame.bind('ceil', defineFunction(fn.ceil, ''));
- staticFrame.bind('round', defineFunction(fn.round, ''));
- staticFrame.bind('abs', defineFunction(fn.abs, ''));
- staticFrame.bind('sqrt', defineFunction(fn.sqrt, ''));
- staticFrame.bind('power', defineFunction(fn.power, ''));
- staticFrame.bind('random', defineFunction(fn.random, '<:n>'));
- staticFrame.bind('boolean', defineFunction(fn["boolean"], ''));
- staticFrame.bind('not', defineFunction(fn.not, ''));
- staticFrame.bind('map', defineFunction(fn.map, ''));
- staticFrame.bind('zip', defineFunction(fn.zip, ''));
- staticFrame.bind('filter', defineFunction(fn.filter, ''));
- staticFrame.bind('single', defineFunction(fn.single, ''));
- staticFrame.bind('reduce', defineFunction(fn.foldLeft, '')); // TODO aj?:j>
-
- staticFrame.bind('sift', defineFunction(fn.sift, ''));
- staticFrame.bind('keys', defineFunction(fn.keys, '>'));
- staticFrame.bind('lookup', defineFunction(fn.lookup, ''));
- staticFrame.bind('append', defineFunction(fn.append, ''));
- staticFrame.bind('exists', defineFunction(fn.exists, ''));
- staticFrame.bind('spread', defineFunction(fn.spread, '>'));
- staticFrame.bind('merge', defineFunction(fn.merge, ':o>'));
- staticFrame.bind('reverse', defineFunction(fn.reverse, ''));
- staticFrame.bind('each', defineFunction(fn.each, ''));
- staticFrame.bind('error', defineFunction(fn.error, ''));
- staticFrame.bind('assert', defineFunction(fn.assert, ''));
- staticFrame.bind('sort', defineFunction(fn.sort, ''));
- staticFrame.bind('shuffle', defineFunction(fn.shuffle, ''));
- staticFrame.bind('distinct', defineFunction(fn.distinct, ''));
- staticFrame.bind('base64encode', defineFunction(fn.base64encode, ''));
- staticFrame.bind('base64decode', defineFunction(fn.base64decode, ''));
- staticFrame.bind('encodeUrlComponent', defineFunction(fn.encodeUrlComponent, ''));
- staticFrame.bind('encodeUrl', defineFunction(fn.encodeUrl, ''));
- staticFrame.bind('decodeUrlComponent', defineFunction(fn.decodeUrlComponent, ''));
- staticFrame.bind('decodeUrl', defineFunction(fn.decodeUrl, ''));
- staticFrame.bind('eval', defineFunction(functionEval, ''));
- staticFrame.bind('toMillis', defineFunction(datetime.toMillis, ''));
- staticFrame.bind('fromMillis', defineFunction(datetime.fromMillis, ''));
- staticFrame.bind('clone', defineFunction(functionClone, '<(oa)-:o>'));
- /**
- * Error codes
- *
- * Sxxxx - Static errors (compile time)
- * Txxxx - Type errors
- * Dxxxx - Dynamic errors (evaluate time)
- * 01xx - tokenizer
- * 02xx - parser
- * 03xx - regex parser
- * 04xx - function signature parser/evaluator
- * 10xx - evaluator
- * 20xx - operators
- * 3xxx - functions (blocks of 10 for each function)
- */
-
- var errorCodes = {
- "S0101": "String literal must be terminated by a matching quote",
- "S0102": "Number out of range: {{token}}",
- "S0103": "Unsupported escape sequence: \\{{token}}",
- "S0104": "The escape sequence \\u must be followed by 4 hex digits",
- "S0105": "Quoted property name must be terminated with a backquote (`)",
- "S0106": "Comment has no closing tag",
- "S0201": "Syntax error: {{token}}",
- "S0202": "Expected {{value}}, got {{token}}",
- "S0203": "Expected {{value}} before end of expression",
- "S0204": "Unknown operator: {{token}}",
- "S0205": "Unexpected token: {{token}}",
- "S0206": "Unknown expression type: {{token}}",
- "S0207": "Unexpected end of expression",
- "S0208": "Parameter {{value}} of function definition must be a variable name (start with $)",
- "S0209": "A predicate cannot follow a grouping expression in a step",
- "S0210": "Each step can only have one grouping expression",
- "S0211": "The symbol {{token}} cannot be used as a unary operator",
- "S0212": "The left side of := must be a variable name (start with $)",
- "S0213": "The literal value {{value}} cannot be used as a step within a path expression",
- "S0214": "The right side of {{token}} must be a variable name (start with $)",
- "S0215": "A context variable binding must precede any predicates on a step",
- "S0216": "A context variable binding must precede the 'order-by' clause on a step",
- "S0301": "Empty regular expressions are not allowed",
- "S0302": "No terminating / in regular expression",
- "S0402": "Choice groups containing parameterized types are not supported",
- "S0401": "Type parameters can only be applied to functions and arrays",
- "S0500": "Attempted to evaluate an expression containing syntax error(s)",
- "T0410": "Argument {{index}} of function {{token}} does not match function signature",
- "T0411": "Context value is not a compatible type with argument {{index}} of function {{token}}",
- "T0412": "Argument {{index}} of function {{token}} must be an array of {{type}}",
- "D1001": "Number out of range: {{value}}",
- "D1002": "Cannot negate a non-numeric value: {{value}}",
- "T1003": "Key in object structure must evaluate to a string; got: {{value}}",
- "D1004": "Regular expression matches zero length string",
- "T1005": "Attempted to invoke a non-function. Did you mean ${{{token}}}?",
- "T1006": "Attempted to invoke a non-function",
- "T1007": "Attempted to partially apply a non-function. Did you mean ${{{token}}}?",
- "T1008": "Attempted to partially apply a non-function",
- "D1009": "Multiple key definitions evaluate to same key: {{value}}",
- "T1010": "The matcher function argument passed to function {{token}} does not return the correct object structure",
- "T2001": "The left side of the {{token}} operator must evaluate to a number",
- "T2002": "The right side of the {{token}} operator must evaluate to a number",
- "T2003": "The left side of the range operator (..) must evaluate to an integer",
- "T2004": "The right side of the range operator (..) must evaluate to an integer",
- "D2005": "The left side of := must be a variable name (start with $)",
- // defunct - replaced by S0212 parser error
- "T2006": "The right side of the function application operator ~> must be a function",
- "T2007": "Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",
- "T2008": "The expressions within an order-by clause must evaluate to numeric or string values",
- "T2009": "The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",
- "T2010": "The expressions either side of operator {{token}} must evaluate to numeric or string values",
- "T2011": "The insert/update clause of the transform expression must evaluate to an object: {{value}}",
- "T2012": "The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",
- "T2013": "The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",
- "D2014": "The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",
- "D3001": "Attempting to invoke string function on Infinity or NaN",
- "D3010": "Second argument of replace function cannot be an empty string",
- "D3011": "Fourth argument of replace function must evaluate to a positive number",
- "D3012": "Attempted to replace a matched string with a non-string value",
- "D3020": "Third argument of split function must evaluate to a positive number",
- "D3030": "Unable to cast value to a number: {{value}}",
- "D3040": "Third argument of match function must evaluate to a positive number",
- "D3050": "The second argument of reduce function must be a function with at least two arguments",
- "D3060": "The sqrt function cannot be applied to a negative number: {{value}}",
- "D3061": "The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",
- "D3070": "The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",
- "D3080": "The picture string must only contain a maximum of two sub-pictures",
- "D3081": "The sub-picture must not contain more than one instance of the 'decimal-separator' character",
- "D3082": "The sub-picture must not contain more than one instance of the 'percent' character",
- "D3083": "The sub-picture must not contain more than one instance of the 'per-mille' character",
- "D3084": "The sub-picture must not contain both a 'percent' and a 'per-mille' character",
- "D3085": "The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",
- "D3086": "The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",
- "D3087": "The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",
- "D3088": "The sub-picture must not contain a 'grouping-separator' at the end of the integer part",
- "D3089": "The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",
- "D3090": "The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",
- "D3091": "The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",
- "D3092": "A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",
- "D3093": "The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",
- "D3100": "The radix of the formatBase function must be between 2 and 36. It was given {{value}}",
- "D3110": "The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",
- "D3120": "Syntax error in expression passed to function eval: {{value}}",
- "D3121": "Dynamic error evaluating the expression passed to function eval: {{value}}",
- "D3130": "Formatting an integer as a sequence starting with {{value}} is not supported by this implementation",
- "D3131": "In a decimal digit pattern, all digits must be from the same decimal group",
- "D3132": "Unknown component specifier {{value}} in date/time picture string",
- "D3133": "The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",
- "D3134": "The timezone integer format specifier cannot have more than four digits",
- "D3135": "No matching closing bracket ']' in date/time picture string",
- "D3136": "The date/time picture string is missing specifiers required to parse the timestamp",
- "D3137": "{{{message}}}",
- "D3138": "The $single() function expected exactly 1 matching result. Instead it matched more.",
- "D3139": "The $single() function expected exactly 1 matching result. Instead it matched 0.",
- "D3140": "Malformed URL passed to ${{{functionName}}}(): {{value}}",
- "D3141": "{{{message}}}"
- };
- /**
- * lookup a message template from the catalog and substitute the inserts.
- * Populates `err.message` with the substituted message. Leaves `err.message`
- * untouched if code lookup fails.
- * @param {string} err - error code to lookup
- * @returns {undefined} - `err` is modified in place
- */
-
- function populateMessage(err) {
- var template = errorCodes[err.code];
-
- if (typeof template !== 'undefined') {
- // if there are any handlebars, replace them with the field references
- // triple braces - replace with value
- // double braces - replace with json stringified value
- var message = template.replace(/\{\{\{([^}]+)}}}/g, function () {
- return err[arguments[1]];
- });
- message = message.replace(/\{\{([^}]+)}}/g, function () {
- return JSON.stringify(err[arguments[1]]);
- });
- err.message = message;
- } // Otherwise retain the original `err.message`
+ return _context19.delegateYield(_loop(), 't1', 10);
- }
- /**
- * JSONata
- * @param {Object} expr - JSONata expression
- * @param {boolean} options - recover: attempt to recover on parse error
- * @returns {{evaluate: evaluate, assign: assign}} Evaluated expression
- */
+ case 10:
+ jj++;
+ _context19.next = 8;
+ break;
+ case 13:
+ // apply the procedure
+ procName =
+ expr.procedure.type === 'path' ? expr.procedure.steps[0].value : expr.procedure.value;
+ _context19.prev = 14;
- function jsonata(expr, options) {
- var _ast;
+ if (_typeof(proc) === 'object') {
+ proc.token = procName;
+ proc.position = expr.position;
+ }
- var _errors;
+ return _context19.delegateYield(apply(proc, evaluatedArgs, input, environment), 't2', 17);
- try {
- _ast = parser(expr, options && options.recover);
- _errors = _ast.errors;
- delete _ast.errors;
- } catch (err) {
- // insert error message into structure
- populateMessage(err); // possible side-effects on `err`
+ case 17:
+ result = _context19.t2;
+ _context19.next = 25;
+ break;
- throw err;
- }
+ case 20:
+ _context19.prev = 20;
+ _context19.t3 = _context19['catch'](14);
- var environment = createFrame(staticFrame);
- var timestamp = new Date(); // will be overridden on each call to evalute()
-
- environment.bind('now', defineFunction(function (picture, timezone) {
- return datetime.fromMillis(timestamp.getTime(), picture, timezone);
- }, ''));
- environment.bind('millis', defineFunction(function () {
- return timestamp.getTime();
- }, '<:n>'));
- return {
- evaluate: function evaluate(input, bindings, callback) {
- // throw if the expression compiled with syntax errors
- if (typeof _errors !== 'undefined') {
- var err = {
- code: 'S0500',
- position: 0
- };
- populateMessage(err); // possible side-effects on `err`
+ if (!_context19.t3.position) {
+ // add the position field to the error
+ _context19.t3.position = expr.position;
+ }
- throw err;
- }
+ if (!_context19.t3.token) {
+ // and the function identifier
+ _context19.t3.token = procName;
+ }
- if (typeof bindings !== 'undefined') {
- var exec_env; // the variable bindings have been passed in - create a frame to hold these
+ throw _context19.t3;
- exec_env = createFrame(environment);
+ case 25:
+ return _context19.abrupt('return', result);
- for (var v in bindings) {
- exec_env.bind(v, bindings[v]);
- }
- } else {
- exec_env = environment;
- } // put the input document into the environment as the root object
+ case 26:
+ case 'end':
+ return _context19.stop();
+ }
+ }
+ },
+ _marked15,
+ null,
+ [[14, 20]]
+ );
+ }
+ /**
+ * Apply procedure or function
+ * @param {Object} proc - Procedure
+ * @param {Array} args - Arguments
+ * @param {Object} input - input
+ * @param {Object} environment - environment
+ * @returns {*} Result of procedure
+ */
+
+ function apply(proc, args, input, environment) {
+ var result, next, evaluatedArgs, ii;
+ return regeneratorRuntime.wrap(function apply$(_context20) {
+ while (1) {
+ switch ((_context20.prev = _context20.next)) {
+ case 0:
+ return _context20.delegateYield(applyInner(proc, args, input, environment), 't0', 1);
+ case 1:
+ result = _context20.t0;
- exec_env.bind('$', input); // capture the timestamp and put it in the execution environment
- // the $now() and $millis() functions will return this value - whenever it is called
+ case 2:
+ if (!(isLambda(result) && result.thunk === true)) {
+ _context20.next = 21;
+ break;
+ }
- timestamp = new Date();
- exec_env.timestamp = timestamp; // if the input is a JSON array, then wrap it in a singleton sequence so it gets treated as a single input
+ return _context20.delegateYield(
+ _evaluate(result.body.procedure, result.input, result.environment),
+ 't1',
+ 4
+ );
- if (Array.isArray(input) && !isSequence(input)) {
- input = createSequence(input);
- input.outerWrapper = true;
- }
+ case 4:
+ next = _context20.t1;
- var result, it; // if a callback function is supplied, then drive the generator in a promise chain
+ if (result.body.procedure.type === 'variable') {
+ next.token = result.body.procedure.value;
+ }
- if (typeof callback === 'function') {
- exec_env.async = true;
+ next.position = result.body.procedure.position;
+ evaluatedArgs = [];
+ ii = 0;
- var catchHandler = function catchHandler(err) {
- populateMessage(err); // possible side-effects on `err`
+ case 9:
+ if (!(ii < result.body.arguments.length)) {
+ _context20.next = 17;
+ break;
+ }
- callback(err, null);
- };
+ _context20.t2 = evaluatedArgs;
+ return _context20.delegateYield(
+ _evaluate(result.body.arguments[ii], result.input, result.environment),
+ 't3',
+ 12
+ );
- var thenHandler = function thenHandler(response) {
- result = it.next(response);
+ case 12:
+ _context20.t4 = _context20.t3;
- if (result.done) {
- callback(null, result.value);
- } else {
- result.value.then(thenHandler)["catch"](catchHandler);
- }
- };
+ _context20.t2.push.call(_context20.t2, _context20.t4);
- it = _evaluate(_ast, input, exec_env);
- result = it.next();
- result.value.then(thenHandler)["catch"](catchHandler);
- } else {
- // no callback function - drive the generator to completion synchronously
- try {
- it = _evaluate(_ast, input, exec_env);
- result = it.next();
+ case 14:
+ ii++;
+ _context20.next = 9;
+ break;
- while (!result.done) {
- result = it.next(result.value);
- }
+ case 17:
+ return _context20.delegateYield(applyInner(next, evaluatedArgs, input, environment), 't5', 18);
- return result.value;
- } catch (err) {
- // insert error message into structure
- populateMessage(err); // possible side-effects on `err`
+ case 18:
+ result = _context20.t5;
+ _context20.next = 2;
+ break;
- throw err;
- }
- }
- },
- assign: function assign(name, value) {
- environment.bind(name, value);
- },
- registerFunction: function registerFunction(name, implementation, signature) {
- var func = defineFunction(implementation, signature);
- environment.bind(name, func);
- },
- ast: function ast() {
- return _ast;
- },
- errors: function errors() {
- return _errors;
- }
- };
- }
+ case 21:
+ return _context20.abrupt('return', result);
- jsonata.parser = parser; // TODO remove this in a future release - use ast() instead
+ case 22:
+ case 'end':
+ return _context20.stop();
+ }
+ }
+ }, _marked16);
+ }
+ /**
+ * Apply procedure or function
+ * @param {Object} proc - Procedure
+ * @param {Array} args - Arguments
+ * @param {Object} input - input
+ * @param {Object} environment - environment
+ * @returns {*} Result of procedure
+ */
+
+ function applyInner(proc, args, input, environment) {
+ var result, validatedArgs, focus;
+ return regeneratorRuntime.wrap(
+ function applyInner$(_context21) {
+ while (1) {
+ switch ((_context21.prev = _context21.next)) {
+ case 0:
+ _context21.prev = 0;
+ validatedArgs = args;
+
+ if (proc) {
+ validatedArgs = validateArguments(proc.signature, args, input);
+ }
- return jsonata;
-}();
+ if (!isLambda(proc)) {
+ _context21.next = 8;
+ break;
+ }
-module.exports = jsonata;
-},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(require,module,exports){
-"use strict";
+ return _context21.delegateYield(applyProcedure(proc, validatedArgs), 't0', 5);
-/**
- * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
-var parseSignature = require('./signature');
+ case 5:
+ result = _context21.t0;
+ _context21.next = 24;
+ break;
-var parser = function () {
- 'use strict';
+ case 8:
+ if (!(proc && proc._jsonata_function === true)) {
+ _context21.next = 16;
+ break;
+ }
- var operators = {
- '.': 75,
- '[': 80,
- ']': 0,
- '{': 70,
- '}': 0,
- '(': 80,
- ')': 0,
- ',': 0,
- '@': 80,
- '#': 80,
- ';': 80,
- ':': 80,
- '?': 20,
- '+': 50,
- '-': 50,
- '*': 60,
- '/': 60,
- '%': 60,
- '|': 20,
- '=': 40,
- '<': 40,
- '>': 40,
- '^': 40,
- '**': 60,
- '..': 20,
- ':=': 10,
- '!=': 40,
- '<=': 40,
- '>=': 40,
- '~>': 40,
- 'and': 30,
- 'or': 25,
- 'in': 40,
- '&': 50,
- '!': 0,
- // not an operator, but needed as a stop character for name tokens
- '~': 0 // not an operator, but needed as a stop character for name tokens
+ focus = {
+ environment: environment,
+ input: input,
+ }; // the `focus` is passed in as the `this` for the invoked function
- };
- var escapes = {
- // JSON string escape sequences - see json.org
- '"': '"',
- '\\': '\\',
- '/': '/',
- 'b': '\b',
- 'f': '\f',
- 'n': '\n',
- 'r': '\r',
- 't': '\t'
- }; // Tokenizer (lexer) - invoked by the parser to return one token at a time
-
- var tokenizer = function tokenizer(path) {
- var position = 0;
- var length = path.length;
-
- var create = function create(type, value) {
- var obj = {
- type: type,
- value: value,
- position: position
- };
- return obj;
- };
+ result = proc.implementation.apply(focus, validatedArgs); // `proc.implementation` might be a generator function
+ // and `result` might be a generator - if so, yield
- var scanRegex = function scanRegex() {
- // the prefix '/' will have been previously scanned. Find the end of the regex.
- // search for closing '/' ignoring any that are escaped, or within brackets
- var start = position;
- var depth = 0;
- var pattern;
- var flags;
-
- while (position < length) {
- var currentChar = path.charAt(position);
-
- if (currentChar === '/' && path.charAt(position - 1) !== '\\' && depth === 0) {
- // end of regex found
- pattern = path.substring(start, position);
-
- if (pattern === '') {
- throw {
- code: "S0301",
- stack: new Error().stack,
- position: position
- };
- }
+ if (!isIterable(result)) {
+ _context21.next = 14;
+ break;
+ }
- position++;
- currentChar = path.charAt(position); // flags
+ return _context21.delegateYield(result, 't1', 13);
- start = position;
+ case 13:
+ result = _context21.t1;
- while (currentChar === 'i' || currentChar === 'm') {
- position++;
- currentChar = path.charAt(position);
- }
+ case 14:
+ _context21.next = 24;
+ break;
- flags = path.substring(start, position) + 'g';
- return new RegExp(pattern, flags);
- }
+ case 16:
+ if (!(typeof proc === 'function')) {
+ _context21.next = 23;
+ break;
+ }
- if ((currentChar === '(' || currentChar === '[' || currentChar === '{') && path.charAt(position - 1) !== '\\') {
- depth++;
- }
+ // typically these are functions that are returned by the invocation of plugin functions
+ // the `input` is being passed in as the `this` for the invoked function
+ // this is so that functions that return objects containing functions can chain
+ // e.g. $func().next().next()
+ result = proc.apply(input, validatedArgs);
+ /* istanbul ignore next */
- if ((currentChar === ')' || currentChar === ']' || currentChar === '}') && path.charAt(position - 1) !== '\\') {
- depth--;
- }
+ if (!isIterable(result)) {
+ _context21.next = 21;
+ break;
+ }
- position++;
- }
+ return _context21.delegateYield(result, 't2', 20);
- throw {
- code: "S0302",
- stack: new Error().stack,
- position: position
- };
- };
+ case 20:
+ result = _context21.t2;
- var next = function next(prefix) {
- if (position >= length) return null;
- var currentChar = path.charAt(position); // skip whitespace
+ case 21:
+ _context21.next = 24;
+ break;
- while (position < length && ' \t\n\r\v'.indexOf(currentChar) > -1) {
- position++;
- currentChar = path.charAt(position);
- } // skip comments
+ case 23:
+ throw {
+ code: 'T1006',
+ stack: new Error().stack,
+ };
+ case 24:
+ _context21.next = 30;
+ break;
- if (currentChar === '/' && path.charAt(position + 1) === '*') {
- var commentStart = position;
- position += 2;
- currentChar = path.charAt(position);
+ case 26:
+ _context21.prev = 26;
+ _context21.t3 = _context21['catch'](0);
- while (!(currentChar === '*' && path.charAt(position + 1) === '/')) {
- currentChar = path.charAt(++position);
+ if (proc) {
+ if (typeof _context21.t3.token == 'undefined' && typeof proc.token !== 'undefined') {
+ _context21.t3.token = proc.token;
+ }
- if (position >= length) {
- // no closing tag
- throw {
- code: "S0106",
- stack: new Error().stack,
- position: commentStart
- };
- }
- }
+ _context21.t3.position = proc.position;
+ }
- position += 2;
- currentChar = path.charAt(position);
- return next(prefix); // need this to swallow any following whitespace
- } // test for regex
+ throw _context21.t3;
+ case 30:
+ return _context21.abrupt('return', result);
- if (prefix !== true && currentChar === '/') {
- position++;
- return create('regex', scanRegex());
- } // handle double-char operators
+ case 31:
+ case 'end':
+ return _context21.stop();
+ }
+ }
+ },
+ _marked17,
+ null,
+ [[0, 26]]
+ );
+ }
+ /**
+ * Evaluate lambda against input data
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {{lambda: boolean, input: *, environment: *, arguments: *, body: *}} Evaluated input data
+ */
+
+ function evaluateLambda(expr, input, environment) {
+ // make a function (closure)
+ var procedure = {
+ _jsonata_lambda: true,
+ input: input,
+ environment: environment,
+ arguments: expr.arguments,
+ signature: expr.signature,
+ body: expr.body,
+ };
+ if (expr.thunk === true) {
+ procedure.thunk = true;
+ }
- if (currentChar === '.' && path.charAt(position + 1) === '.') {
- // double-dot .. range operator
- position += 2;
- return create('operator', '..');
- }
+ procedure.apply =
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function _callee(self, args) {
+ return regeneratorRuntime.wrap(function _callee$(_context22) {
+ while (1) {
+ switch ((_context22.prev = _context22.next)) {
+ case 0:
+ return _context22.delegateYield(apply(procedure, args, input, self.environment), 't0', 1);
+
+ case 1:
+ return _context22.abrupt('return', _context22.t0);
+
+ case 2:
+ case 'end':
+ return _context22.stop();
+ }
+ }
+ }, _callee);
+ });
+ return procedure;
+ }
+ /**
+ * Evaluate partial application
+ * @param {Object} expr - JSONata expression
+ * @param {Object} input - Input data to evaluate against
+ * @param {Object} environment - Environment
+ * @returns {*} Evaluated input data
+ */
+
+ function evaluatePartialApplication(expr, input, environment) {
+ var result, evaluatedArgs, ii, arg, proc;
+ return regeneratorRuntime.wrap(function evaluatePartialApplication$(_context23) {
+ while (1) {
+ switch ((_context23.prev = _context23.next)) {
+ case 0:
+ // partially apply a function
+ // evaluate the arguments
+ evaluatedArgs = [];
+ ii = 0;
- if (currentChar === ':' && path.charAt(position + 1) === '=') {
- // := assignment
- position += 2;
- return create('operator', ':=');
- }
+ case 2:
+ if (!(ii < expr.arguments.length)) {
+ _context23.next = 15;
+ break;
+ }
- if (currentChar === '!' && path.charAt(position + 1) === '=') {
- // !=
- position += 2;
- return create('operator', '!=');
- }
+ arg = expr.arguments[ii];
- if (currentChar === '>' && path.charAt(position + 1) === '=') {
- // >=
- position += 2;
- return create('operator', '>=');
- }
+ if (!(arg.type === 'operator' && arg.value === '?')) {
+ _context23.next = 8;
+ break;
+ }
- if (currentChar === '<' && path.charAt(position + 1) === '=') {
- // <=
- position += 2;
- return create('operator', '<=');
- }
+ evaluatedArgs.push(arg);
+ _context23.next = 12;
+ break;
- if (currentChar === '*' && path.charAt(position + 1) === '*') {
- // ** descendant wildcard
- position += 2;
- return create('operator', '**');
- }
+ case 8:
+ _context23.t0 = evaluatedArgs;
+ return _context23.delegateYield(_evaluate(arg, input, environment), 't1', 10);
- if (currentChar === '~' && path.charAt(position + 1) === '>') {
- // ~> chain function
- position += 2;
- return create('operator', '~>');
- } // test for single char operators
+ case 10:
+ _context23.t2 = _context23.t1;
+ _context23.t0.push.call(_context23.t0, _context23.t2);
- if (Object.prototype.hasOwnProperty.call(operators, currentChar)) {
- position++;
- return create('operator', currentChar);
- } // test for string literals
+ case 12:
+ ii++;
+ _context23.next = 2;
+ break;
+ case 15:
+ return _context23.delegateYield(_evaluate(expr.procedure, input, environment), 't3', 16);
- if (currentChar === '"' || currentChar === "'") {
- var quoteType = currentChar; // double quoted string literal - find end of string
+ case 16:
+ proc = _context23.t3;
- position++;
- var qstr = "";
+ if (
+ !(
+ typeof proc === 'undefined' &&
+ expr.procedure.type === 'path' &&
+ environment.lookup(expr.procedure.steps[0].value)
+ )
+ ) {
+ _context23.next = 19;
+ break;
+ }
- while (position < length) {
- currentChar = path.charAt(position);
+ throw {
+ code: 'T1007',
+ stack: new Error().stack,
+ position: expr.position,
+ token: expr.procedure.steps[0].value,
+ };
- if (currentChar === '\\') {
- // escape sequence
- position++;
- currentChar = path.charAt(position);
+ case 19:
+ if (!isLambda(proc)) {
+ _context23.next = 23;
+ break;
+ }
- if (Object.prototype.hasOwnProperty.call(escapes, currentChar)) {
- qstr += escapes[currentChar];
- } else if (currentChar === 'u') {
- // \u should be followed by 4 hex digits
- var octets = path.substr(position + 1, 4);
+ result = partialApplyProcedure(proc, evaluatedArgs);
+ _context23.next = 32;
+ break;
- if (/^[0-9a-fA-F]+$/.test(octets)) {
- var codepoint = parseInt(octets, 16);
- qstr += String.fromCharCode(codepoint);
- position += 4;
- } else {
- throw {
- code: "S0104",
- stack: new Error().stack,
- position: position
- };
- }
- } else {
- // illegal escape sequence
- throw {
- code: "S0103",
- stack: new Error().stack,
- position: position,
- token: currentChar
- };
- }
- } else if (currentChar === quoteType) {
- position++;
- return create('string', qstr);
- } else {
- qstr += currentChar;
- }
+ case 23:
+ if (!(proc && proc._jsonata_function === true)) {
+ _context23.next = 27;
+ break;
+ }
- position++;
- }
+ result = partialApplyNativeFunction(proc.implementation, evaluatedArgs);
+ _context23.next = 32;
+ break;
- throw {
- code: "S0101",
- stack: new Error().stack,
- position: position
- };
- } // test for numbers
+ case 27:
+ if (!(typeof proc === 'function')) {
+ _context23.next = 31;
+ break;
+ }
+ result = partialApplyNativeFunction(proc, evaluatedArgs);
+ _context23.next = 32;
+ break;
- var numregex = /^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/;
- var match = numregex.exec(path.substring(position));
+ case 31:
+ throw {
+ code: 'T1008',
+ stack: new Error().stack,
+ position: expr.position,
+ token: expr.procedure.type === 'path' ? expr.procedure.steps[0].value : expr.procedure.value,
+ };
- if (match !== null) {
- var num = parseFloat(match[0]);
+ case 32:
+ return _context23.abrupt('return', result);
- if (!isNaN(num) && isFinite(num)) {
- position += match[0].length;
- return create('number', num);
- } else {
- throw {
- code: "S0102",
- stack: new Error().stack,
- position: position,
- token: match[0]
- };
- }
- } // test for quoted names (backticks)
+ case 33:
+ case 'end':
+ return _context23.stop();
+ }
+ }
+ }, _marked18);
+ }
+ /**
+ * Validate the arguments against the signature validator (if it exists)
+ * @param {Function} signature - validator function
+ * @param {Array} args - function arguments
+ * @param {*} context - context value
+ * @returns {Array} - validated arguments
+ */
+
+ function validateArguments(signature, args, context) {
+ if (typeof signature === 'undefined') {
+ // nothing to validate
+ return args;
+ }
+ var validatedArgs = signature.validate(args, context);
+ return validatedArgs;
+ }
+ /**
+ * Apply procedure
+ * @param {Object} proc - Procedure
+ * @param {Array} args - Arguments
+ * @returns {*} Result of procedure
+ */
- var name;
+ function applyProcedure(proc, args) {
+ var result, env;
+ return regeneratorRuntime.wrap(function applyProcedure$(_context24) {
+ while (1) {
+ switch ((_context24.prev = _context24.next)) {
+ case 0:
+ env = createFrame(proc.environment);
+ proc.arguments.forEach(function (param, index) {
+ env.bind(param.value, args[index]);
+ });
- if (currentChar === '`') {
- // scan for closing quote
- position++;
- var end = path.indexOf('`', position);
+ if (!(typeof proc.body === 'function')) {
+ _context24.next = 7;
+ break;
+ }
- if (end !== -1) {
- name = path.substring(position, end);
- position = end + 1;
- return create('name', name);
- }
+ return _context24.delegateYield(applyNativeFunction(proc.body, env), 't0', 4);
- position = length;
- throw {
- code: "S0105",
- stack: new Error().stack,
- position: position
- };
- } // test for names
+ case 4:
+ result = _context24.t0;
+ _context24.next = 9;
+ break;
+ case 7:
+ return _context24.delegateYield(_evaluate(proc.body, proc.input, env), 't1', 8);
- var i = position;
- var ch;
+ case 8:
+ result = _context24.t1;
- for (;;) {
- ch = path.charAt(i);
+ case 9:
+ return _context24.abrupt('return', result);
- if (i === length || ' \t\n\r\v'.indexOf(ch) > -1 || Object.prototype.hasOwnProperty.call(operators, ch)) {
- if (path.charAt(position) === '$') {
- // variable reference
- name = path.substring(position + 1, i);
- position = i;
- return create('variable', name);
- } else {
- name = path.substring(position, i);
- position = i;
+ case 10:
+ case 'end':
+ return _context24.stop();
+ }
+ }
+ }, _marked19);
+ }
+ /**
+ * Partially apply procedure
+ * @param {Object} proc - Procedure
+ * @param {Array} args - Arguments
+ * @returns {{lambda: boolean, input: *, environment: {bind, lookup}, arguments: Array, body: *}} Result of partially applied procedure
+ */
+
+ function partialApplyProcedure(proc, args) {
+ // create a closure, bind the supplied parameters and return a function that takes the remaining (?) parameters
+ var env = createFrame(proc.environment);
+ var unboundArgs = [];
+ proc.arguments.forEach(function (param, index) {
+ var arg = args[index];
+
+ if (arg && arg.type === 'operator' && arg.value === '?') {
+ unboundArgs.push(param);
+ } else {
+ env.bind(param.value, arg);
+ }
+ });
+ var procedure = {
+ _jsonata_lambda: true,
+ input: proc.input,
+ environment: env,
+ arguments: unboundArgs,
+ body: proc.body,
+ };
+ return procedure;
+ }
+ /**
+ * Partially apply native function
+ * @param {Function} native - Native function
+ * @param {Array} args - Arguments
+ * @returns {{lambda: boolean, input: *, environment: {bind, lookup}, arguments: Array, body: *}} Result of partially applying native function
+ */
+
+ function partialApplyNativeFunction(_native, args) {
+ // create a lambda function that wraps and invokes the native function
+ // get the list of declared arguments from the native function
+ // this has to be picked out from the toString() value
+ var sigArgs = getNativeFunctionArguments(_native);
+ sigArgs = sigArgs.map(function (sigArg) {
+ return '$' + sigArg.trim();
+ });
+ var body = 'function(' + sigArgs.join(', ') + '){ _ }';
+ var bodyAST = parser(body);
+ bodyAST.body = _native;
+ var partial = partialApplyProcedure(bodyAST, args);
+ return partial;
+ }
+ /**
+ * Apply native function
+ * @param {Object} proc - Procedure
+ * @param {Object} env - Environment
+ * @returns {*} Result of applying native function
+ */
+
+ function applyNativeFunction(proc, env) {
+ var sigArgs, args, focus, result;
+ return regeneratorRuntime.wrap(function applyNativeFunction$(_context25) {
+ while (1) {
+ switch ((_context25.prev = _context25.next)) {
+ case 0:
+ sigArgs = getNativeFunctionArguments(proc); // generate the array of arguments for invoking the function - look them up in the environment
+
+ args = sigArgs.map(function (sigArg) {
+ return env.lookup(sigArg.trim());
+ });
+ focus = {
+ environment: env,
+ };
+ result = proc.apply(focus, args);
- switch (name) {
- case 'or':
- case 'in':
- case 'and':
- return create('operator', name);
+ if (!isIterable(result)) {
+ _context25.next = 7;
+ break;
+ }
- case 'true':
- return create('value', true);
+ return _context25.delegateYield(result, 't0', 6);
- case 'false':
- return create('value', false);
+ case 6:
+ result = _context25.t0;
- case 'null':
- return create('value', null);
+ case 7:
+ return _context25.abrupt('return', result);
- default:
- if (position === length && name === '') {
- // whitespace at end of input
- return null;
+ case 8:
+ case 'end':
+ return _context25.stop();
+ }
}
+ }, _marked20);
+ }
+ /**
+ * Get native function arguments
+ * @param {Function} func - Function
+ * @returns {*|Array} Native function arguments
+ */
+
+ function getNativeFunctionArguments(func) {
+ var signature = func.toString();
+ var sigParens = /\(([^)]*)\)/.exec(signature)[1]; // the contents of the parens
+
+ var sigArgs = sigParens.split(',');
+ return sigArgs;
+ }
+ /**
+ * Creates a function definition
+ * @param {Function} func - function implementation in Javascript
+ * @param {string} signature - JSONata function signature definition
+ * @returns {{implementation: *, signature: *}} function definition
+ */
+
+ function defineFunction(func, signature) {
+ var definition = {
+ _jsonata_function: true,
+ implementation: func,
+ };
- return create('name', name);
- }
- }
- } else {
- i++;
- }
- }
- };
+ if (typeof signature !== 'undefined') {
+ definition.signature = parseSignature(signature);
+ }
- return next;
- }; // This parser implements the 'Top down operator precedence' algorithm developed by Vaughan R Pratt; http://dl.acm.org/citation.cfm?id=512931.
- // and builds on the Javascript framework described by Douglas Crockford at http://javascript.crockford.com/tdop/tdop.html
- // and in 'Beautiful Code', edited by Andy Oram and Greg Wilson, Copyright 2007 O'Reilly Media, Inc. 798-0-596-51004-6
+ return definition;
+ }
+ /**
+ * parses and evaluates the supplied expression
+ * @param {string} expr - expression to evaluate
+ * @returns {*} - result of evaluating the expression
+ */
+
+ function functionEval(expr, focus) {
+ var input, ast, result;
+ return regeneratorRuntime.wrap(
+ function functionEval$(_context26) {
+ while (1) {
+ switch ((_context26.prev = _context26.next)) {
+ case 0:
+ if (!(typeof expr === 'undefined')) {
+ _context26.next = 2;
+ break;
+ }
+ return _context26.abrupt('return', undefined);
- var parser = function parser(source, recover) {
- var node;
- var lexer;
- var symbol_table = {};
- var errors = [];
+ case 2:
+ input = this.input;
- var remainingTokens = function remainingTokens() {
- var remaining = [];
+ if (typeof focus !== 'undefined') {
+ input = focus;
+ }
- if (node.id !== '(end)') {
- remaining.push({
- type: node.type,
- value: node.value,
- position: node.position
- });
- }
+ _context26.prev = 4;
+ ast = parser(expr, false);
+ _context26.next = 12;
+ break;
- var nxt = lexer();
+ case 8:
+ _context26.prev = 8;
+ _context26.t0 = _context26['catch'](4);
+ // error parsing the expression passed to $eval
+ populateMessage(_context26.t0);
+ throw {
+ stack: new Error().stack,
+ code: 'D3120',
+ value: _context26.t0.message,
+ error: _context26.t0,
+ };
+
+ case 12:
+ _context26.prev = 12;
+ return _context26.delegateYield(_evaluate(ast, input, this.environment), 't1', 14);
+
+ case 14:
+ result = _context26.t1;
+ _context26.next = 21;
+ break;
- while (nxt !== null) {
- remaining.push(nxt);
- nxt = lexer();
- }
+ case 17:
+ _context26.prev = 17;
+ _context26.t2 = _context26['catch'](12);
+ // error evaluating the expression passed to $eval
+ populateMessage(_context26.t2);
+ throw {
+ stack: new Error().stack,
+ code: 'D3121',
+ value: _context26.t2.message,
+ error: _context26.t2,
+ };
+
+ case 21:
+ return _context26.abrupt('return', result);
+
+ case 22:
+ case 'end':
+ return _context26.stop();
+ }
+ }
+ },
+ _marked21,
+ this,
+ [
+ [4, 8],
+ [12, 17],
+ ]
+ );
+ }
+ /**
+ * Clones an object
+ * @param {Object} arg - object to clone (deep copy)
+ * @returns {*} - the cloned object
+ */
+
+ function functionClone(arg) {
+ // undefined inputs always return undefined
+ if (typeof arg === 'undefined') {
+ return undefined;
+ }
- return remaining;
- };
+ return JSON.parse(fn.string(arg));
+ }
+ /**
+ * Create frame
+ * @param {Object} enclosingEnvironment - Enclosing environment
+ * @returns {{bind: bind, lookup: lookup}} Created frame
+ */
+
+ function createFrame(enclosingEnvironment) {
+ var bindings = {};
+ return {
+ bind: function bind(name, value) {
+ bindings[name] = value;
+ },
+ lookup: function lookup(name) {
+ var value;
+
+ if (bindings.hasOwnProperty(name)) {
+ value = bindings[name];
+ } else if (enclosingEnvironment) {
+ value = enclosingEnvironment.lookup(name);
+ }
- var base_symbol = {
- nud: function nud() {
- // error - symbol has been invoked as a unary operator
- var err = {
- code: 'S0211',
- token: this.value,
- position: this.position
- };
-
- if (recover) {
- err.remaining = remainingTokens();
- err.type = 'error';
- errors.push(err);
- return err;
- } else {
- err.stack = new Error().stack;
- throw err;
- }
- }
- };
+ return value;
+ },
+ timestamp: enclosingEnvironment ? enclosingEnvironment.timestamp : null,
+ async: enclosingEnvironment ? enclosingEnvironment.async : false,
+ };
+ } // Function registration
+
+ staticFrame.bind('sum', defineFunction(fn.sum, ':n>'));
+ staticFrame.bind('count', defineFunction(fn.count, ''));
+ staticFrame.bind('max', defineFunction(fn.max, ':n>'));
+ staticFrame.bind('min', defineFunction(fn.min, ':n>'));
+ staticFrame.bind('average', defineFunction(fn.average, ':n>'));
+ staticFrame.bind('string', defineFunction(fn.string, ''));
+ staticFrame.bind('substring', defineFunction(fn.substring, ''));
+ staticFrame.bind('substringBefore', defineFunction(fn.substringBefore, ''));
+ staticFrame.bind('substringAfter', defineFunction(fn.substringAfter, ''));
+ staticFrame.bind('lowercase', defineFunction(fn.lowercase, ''));
+ staticFrame.bind('uppercase', defineFunction(fn.uppercase, ''));
+ staticFrame.bind('length', defineFunction(fn.length, ''));
+ staticFrame.bind('trim', defineFunction(fn.trim, ''));
+ staticFrame.bind('pad', defineFunction(fn.pad, ''));
+ staticFrame.bind('match', defineFunction(fn.match, 'n?:a>'));
+ staticFrame.bind('contains', defineFunction(fn.contains, '')); // TODO ):b>
+
+ staticFrame.bind('replace', defineFunction(fn.replace, '')); // TODO )(sf)n?:s>
+
+ staticFrame.bind('split', defineFunction(fn.split, '>')); // TODO )n?:a>
+
+ staticFrame.bind('join', defineFunction(fn.join, 's?:s>'));
+ staticFrame.bind('formatNumber', defineFunction(fn.formatNumber, ''));
+ staticFrame.bind('formatBase', defineFunction(fn.formatBase, ''));
+ staticFrame.bind('formatInteger', defineFunction(datetime.formatInteger, ''));
+ staticFrame.bind('parseInteger', defineFunction(datetime.parseInteger, ''));
+ staticFrame.bind('number', defineFunction(fn.number, '<(nsb)-:n>'));
+ staticFrame.bind('floor', defineFunction(fn.floor, ''));
+ staticFrame.bind('ceil', defineFunction(fn.ceil, ''));
+ staticFrame.bind('round', defineFunction(fn.round, ''));
+ staticFrame.bind('abs', defineFunction(fn.abs, ''));
+ staticFrame.bind('sqrt', defineFunction(fn.sqrt, ''));
+ staticFrame.bind('power', defineFunction(fn.power, ''));
+ staticFrame.bind('random', defineFunction(fn.random, '<:n>'));
+ staticFrame.bind('boolean', defineFunction(fn['boolean'], ''));
+ staticFrame.bind('not', defineFunction(fn.not, ''));
+ staticFrame.bind('map', defineFunction(fn.map, ''));
+ staticFrame.bind('zip', defineFunction(fn.zip, ''));
+ staticFrame.bind('filter', defineFunction(fn.filter, ''));
+ staticFrame.bind('single', defineFunction(fn.single, ''));
+ staticFrame.bind('reduce', defineFunction(fn.foldLeft, '')); // TODO aj?:j>
+
+ staticFrame.bind('sift', defineFunction(fn.sift, ''));
+ staticFrame.bind('keys', defineFunction(fn.keys, '>'));
+ staticFrame.bind('lookup', defineFunction(fn.lookup, ''));
+ staticFrame.bind('append', defineFunction(fn.append, ''));
+ staticFrame.bind('exists', defineFunction(fn.exists, ''));
+ staticFrame.bind('spread', defineFunction(fn.spread, '>'));
+ staticFrame.bind('merge', defineFunction(fn.merge, ':o>'));
+ staticFrame.bind('reverse', defineFunction(fn.reverse, ''));
+ staticFrame.bind('each', defineFunction(fn.each, ''));
+ staticFrame.bind('error', defineFunction(fn.error, ''));
+ staticFrame.bind('assert', defineFunction(fn.assert, ''));
+ staticFrame.bind('sort', defineFunction(fn.sort, ''));
+ staticFrame.bind('shuffle', defineFunction(fn.shuffle, ''));
+ staticFrame.bind('distinct', defineFunction(fn.distinct, ''));
+ staticFrame.bind('base64encode', defineFunction(fn.base64encode, ''));
+ staticFrame.bind('base64decode', defineFunction(fn.base64decode, ''));
+ staticFrame.bind('encodeUrlComponent', defineFunction(fn.encodeUrlComponent, ''));
+ staticFrame.bind('encodeUrl', defineFunction(fn.encodeUrl, ''));
+ staticFrame.bind('decodeUrlComponent', defineFunction(fn.decodeUrlComponent, ''));
+ staticFrame.bind('decodeUrl', defineFunction(fn.decodeUrl, ''));
+ staticFrame.bind('eval', defineFunction(functionEval, ''));
+ staticFrame.bind('toMillis', defineFunction(datetime.toMillis, ''));
+ staticFrame.bind('fromMillis', defineFunction(datetime.fromMillis, ''));
+ staticFrame.bind('clone', defineFunction(functionClone, '<(oa)-:o>'));
+ /**
+ * Error codes
+ *
+ * Sxxxx - Static errors (compile time)
+ * Txxxx - Type errors
+ * Dxxxx - Dynamic errors (evaluate time)
+ * 01xx - tokenizer
+ * 02xx - parser
+ * 03xx - regex parser
+ * 04xx - function signature parser/evaluator
+ * 10xx - evaluator
+ * 20xx - operators
+ * 3xxx - functions (blocks of 10 for each function)
+ */
+
+ var errorCodes = {
+ S0101: 'String literal must be terminated by a matching quote',
+ S0102: 'Number out of range: {{token}}',
+ S0103: 'Unsupported escape sequence: \\{{token}}',
+ S0104: 'The escape sequence \\u must be followed by 4 hex digits',
+ S0105: 'Quoted property name must be terminated with a backquote (`)',
+ S0106: 'Comment has no closing tag',
+ S0201: 'Syntax error: {{token}}',
+ S0202: 'Expected {{value}}, got {{token}}',
+ S0203: 'Expected {{value}} before end of expression',
+ S0204: 'Unknown operator: {{token}}',
+ S0205: 'Unexpected token: {{token}}',
+ S0206: 'Unknown expression type: {{token}}',
+ S0207: 'Unexpected end of expression',
+ S0208: 'Parameter {{value}} of function definition must be a variable name (start with $)',
+ S0209: 'A predicate cannot follow a grouping expression in a step',
+ S0210: 'Each step can only have one grouping expression',
+ S0211: 'The symbol {{token}} cannot be used as a unary operator',
+ S0212: 'The left side of := must be a variable name (start with $)',
+ S0213: 'The literal value {{value}} cannot be used as a step within a path expression',
+ S0214: 'The right side of {{token}} must be a variable name (start with $)',
+ S0215: 'A context variable binding must precede any predicates on a step',
+ S0216: "A context variable binding must precede the 'order-by' clause on a step",
+ S0301: 'Empty regular expressions are not allowed',
+ S0302: 'No terminating / in regular expression',
+ S0402: 'Choice groups containing parameterized types are not supported',
+ S0401: 'Type parameters can only be applied to functions and arrays',
+ S0500: 'Attempted to evaluate an expression containing syntax error(s)',
+ T0410: 'Argument {{index}} of function {{token}} does not match function signature',
+ T0411: 'Context value is not a compatible type with argument {{index}} of function {{token}}',
+ T0412: 'Argument {{index}} of function {{token}} must be an array of {{type}}',
+ D1001: 'Number out of range: {{value}}',
+ D1002: 'Cannot negate a non-numeric value: {{value}}',
+ T1003: 'Key in object structure must evaluate to a string; got: {{value}}',
+ D1004: 'Regular expression matches zero length string',
+ T1005: 'Attempted to invoke a non-function. Did you mean ${{{token}}}?',
+ T1006: 'Attempted to invoke a non-function',
+ T1007: 'Attempted to partially apply a non-function. Did you mean ${{{token}}}?',
+ T1008: 'Attempted to partially apply a non-function',
+ D1009: 'Multiple key definitions evaluate to same key: {{value}}',
+ T1010:
+ 'The matcher function argument passed to function {{token}} does not return the correct object structure',
+ T2001: 'The left side of the {{token}} operator must evaluate to a number',
+ T2002: 'The right side of the {{token}} operator must evaluate to a number',
+ T2003: 'The left side of the range operator (..) must evaluate to an integer',
+ T2004: 'The right side of the range operator (..) must evaluate to an integer',
+ D2005: 'The left side of := must be a variable name (start with $)',
+ // defunct - replaced by S0212 parser error
+ T2006: 'The right side of the function application operator ~> must be a function',
+ T2007: 'Type mismatch when comparing values {{value}} and {{value2}} in order-by clause',
+ T2008: 'The expressions within an order-by clause must evaluate to numeric or string values',
+ T2009:
+ 'The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type',
+ T2010: 'The expressions either side of operator {{token}} must evaluate to numeric or string values',
+ T2011: 'The insert/update clause of the transform expression must evaluate to an object: {{value}}',
+ T2012:
+ 'The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}',
+ T2013:
+ 'The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.',
+ D2014:
+ 'The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.',
+ D3001: 'Attempting to invoke string function on Infinity or NaN',
+ D3010: 'Second argument of replace function cannot be an empty string',
+ D3011: 'Fourth argument of replace function must evaluate to a positive number',
+ D3012: 'Attempted to replace a matched string with a non-string value',
+ D3020: 'Third argument of split function must evaluate to a positive number',
+ D3030: 'Unable to cast value to a number: {{value}}',
+ D3040: 'Third argument of match function must evaluate to a positive number',
+ D3050: 'The second argument of reduce function must be a function with at least two arguments',
+ D3060: 'The sqrt function cannot be applied to a negative number: {{value}}',
+ D3061:
+ 'The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}',
+ D3070:
+ 'The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function',
+ D3080: 'The picture string must only contain a maximum of two sub-pictures',
+ D3081: "The sub-picture must not contain more than one instance of the 'decimal-separator' character",
+ D3082: "The sub-picture must not contain more than one instance of the 'percent' character",
+ D3083: "The sub-picture must not contain more than one instance of the 'per-mille' character",
+ D3084: "The sub-picture must not contain both a 'percent' and a 'per-mille' character",
+ D3085:
+ "The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",
+ D3086:
+ 'The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character',
+ D3087:
+ "The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",
+ D3088: "The sub-picture must not contain a 'grouping-separator' at the end of the integer part",
+ D3089: "The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",
+ D3090:
+ "The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",
+ D3091:
+ "The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",
+ D3092:
+ "A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",
+ D3093:
+ "The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",
+ D3100: 'The radix of the formatBase function must be between 2 and 36. It was given {{value}}',
+ D3110: 'The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}',
+ D3120: 'Syntax error in expression passed to function eval: {{value}}',
+ D3121: 'Dynamic error evaluating the expression passed to function eval: {{value}}',
+ D3130:
+ 'Formatting an integer as a sequence starting with {{value}} is not supported by this implementation',
+ D3131: 'In a decimal digit pattern, all digits must be from the same decimal group',
+ D3132: 'Unknown component specifier {{value}} in date/time picture string',
+ D3133:
+ "The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",
+ D3134: 'The timezone integer format specifier cannot have more than four digits',
+ D3135: "No matching closing bracket ']' in date/time picture string",
+ D3136: 'The date/time picture string is missing specifiers required to parse the timestamp',
+ D3137: '{{{message}}}',
+ D3138: 'The $single() function expected exactly 1 matching result. Instead it matched more.',
+ D3139: 'The $single() function expected exactly 1 matching result. Instead it matched 0.',
+ D3140: 'Malformed URL passed to ${{{functionName}}}(): {{value}}',
+ D3141: '{{{message}}}',
+ };
+ /**
+ * lookup a message template from the catalog and substitute the inserts.
+ * Populates `err.message` with the substituted message. Leaves `err.message`
+ * untouched if code lookup fails.
+ * @param {string} err - error code to lookup
+ * @returns {undefined} - `err` is modified in place
+ */
+
+ function populateMessage(err) {
+ var template = errorCodes[err.code];
+
+ if (typeof template !== 'undefined') {
+ // if there are any handlebars, replace them with the field references
+ // triple braces - replace with value
+ // double braces - replace with json stringified value
+ var message = template.replace(/\{\{\{([^}]+)}}}/g, function () {
+ return err[arguments[1]];
+ });
+ message = message.replace(/\{\{([^}]+)}}/g, function () {
+ return JSON.stringify(err[arguments[1]]);
+ });
+ err.message = message;
+ } // Otherwise retain the original `err.message`
+ }
+ /**
+ * JSONata
+ * @param {Object} expr - JSONata expression
+ * @param {boolean} options - recover: attempt to recover on parse error
+ * @returns {{evaluate: evaluate, assign: assign}} Evaluated expression
+ */
+
+ function jsonata(expr, options) {
+ var _ast;
+
+ var _errors;
+
+ try {
+ _ast = parser(expr, options && options.recover);
+ _errors = _ast.errors;
+ delete _ast.errors;
+ } catch (err) {
+ // insert error message into structure
+ populateMessage(err); // possible side-effects on `err`
+
+ throw err;
+ }
- var symbol = function symbol(id, bp) {
- var s = symbol_table[id];
- bp = bp || 0;
+ var environment = createFrame(staticFrame);
+ var timestamp = new Date(); // will be overridden on each call to evalute()
+
+ environment.bind(
+ 'now',
+ defineFunction(function (picture, timezone) {
+ return datetime.fromMillis(timestamp.getTime(), picture, timezone);
+ }, '')
+ );
+ environment.bind(
+ 'millis',
+ defineFunction(function () {
+ return timestamp.getTime();
+ }, '<:n>')
+ );
+ return {
+ evaluate: function evaluate(input, bindings, callback) {
+ // throw if the expression compiled with syntax errors
+ if (typeof _errors !== 'undefined') {
+ var err = {
+ code: 'S0500',
+ position: 0,
+ };
+ populateMessage(err); // possible side-effects on `err`
+
+ throw err;
+ }
- if (s) {
- if (bp >= s.lbp) {
- s.lbp = bp;
- }
- } else {
- s = Object.create(base_symbol);
- s.id = s.value = id;
- s.lbp = bp;
- symbol_table[id] = s;
- }
+ if (typeof bindings !== 'undefined') {
+ var exec_env; // the variable bindings have been passed in - create a frame to hold these
- return s;
- };
+ exec_env = createFrame(environment);
+
+ for (var v in bindings) {
+ exec_env.bind(v, bindings[v]);
+ }
+ } else {
+ exec_env = environment;
+ } // put the input document into the environment as the root object
- var handleError = function handleError(err) {
- if (recover) {
- // tokenize the rest of the buffer and add it to an error token
- err.remaining = remainingTokens();
- errors.push(err);
- var symbol = symbol_table["(error)"];
- node = Object.create(symbol);
- node.error = err;
- node.type = "(error)";
- return node;
- } else {
- err.stack = new Error().stack;
- throw err;
- }
- };
+ exec_env.bind('$', input); // capture the timestamp and put it in the execution environment
+ // the $now() and $millis() functions will return this value - whenever it is called
- var advance = function advance(id, infix) {
- if (id && node.id !== id) {
- var code;
+ timestamp = new Date();
+ exec_env.timestamp = timestamp; // if the input is a JSON array, then wrap it in a singleton sequence so it gets treated as a single input
- if (node.id === '(end)') {
- // unexpected end of buffer
- code = "S0203";
- } else {
- code = "S0202";
- }
+ if (Array.isArray(input) && !isSequence(input)) {
+ input = createSequence(input);
+ input.outerWrapper = true;
+ }
- var err = {
- code: code,
- position: node.position,
- token: node.value,
- value: id
- };
- return handleError(err);
- }
+ var result, it; // if a callback function is supplied, then drive the generator in a promise chain
- var next_token = lexer(infix);
+ if (typeof callback === 'function') {
+ exec_env.async = true;
- if (next_token === null) {
- node = symbol_table["(end)"];
- node.position = source.length;
- return node;
- }
+ var catchHandler = function catchHandler(err) {
+ populateMessage(err); // possible side-effects on `err`
- var value = next_token.value;
- var type = next_token.type;
- var symbol;
+ callback(err, null);
+ };
- switch (type) {
- case 'name':
- case 'variable':
- symbol = symbol_table["(name)"];
- break;
+ var thenHandler = function thenHandler(response) {
+ result = it.next(response);
- case 'operator':
- symbol = symbol_table[value];
+ if (result.done) {
+ callback(null, result.value);
+ } else {
+ result.value.then(thenHandler)['catch'](catchHandler);
+ }
+ };
- if (!symbol) {
- return handleError({
- code: "S0204",
- stack: new Error().stack,
- position: next_token.position,
- token: value
- });
- }
+ it = _evaluate(_ast, input, exec_env);
+ result = it.next();
+ result.value.then(thenHandler)['catch'](catchHandler);
+ } else {
+ // no callback function - drive the generator to completion synchronously
+ try {
+ it = _evaluate(_ast, input, exec_env);
+ result = it.next();
- break;
+ while (!result.done) {
+ result = it.next(result.value);
+ }
- case 'string':
- case 'number':
- case 'value':
- symbol = symbol_table["(literal)"];
- break;
+ return result.value;
+ } catch (err) {
+ // insert error message into structure
+ populateMessage(err); // possible side-effects on `err`
- case 'regex':
- type = "regex";
- symbol = symbol_table["(regex)"];
- break;
+ throw err;
+ }
+ }
+ },
+ assign: function assign(name, value) {
+ environment.bind(name, value);
+ },
+ registerFunction: function registerFunction(name, implementation, signature) {
+ var func = defineFunction(implementation, signature);
+ environment.bind(name, func);
+ },
+ ast: function ast() {
+ return _ast;
+ },
+ errors: function errors() {
+ return _errors;
+ },
+ };
+ }
- /* istanbul ignore next */
+ jsonata.parser = parser; // TODO remove this in a future release - use ast() instead
+
+ return jsonata;
+ })();
+
+ module.exports = jsonata;
+ },
+ { './datetime': 1, './functions': 2, './parser': 4, './signature': 5, './utils': 6 },
+ ],
+ 4: [
+ function (require, module, exports) {
+ 'use strict';
+
+ /**
+ * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
+ * Project name: JSONata
+ * This project is licensed under the MIT License, see LICENSE
+ */
+ var parseSignature = require('./signature');
+
+ var parser = (function () {
+ 'use strict';
+
+ var operators = {
+ '.': 75,
+ '[': 80,
+ ']': 0,
+ '{': 70,
+ '}': 0,
+ '(': 80,
+ ')': 0,
+ ',': 0,
+ '@': 80,
+ '#': 80,
+ ';': 80,
+ ':': 80,
+ '?': 20,
+ '+': 50,
+ '-': 50,
+ '*': 60,
+ '/': 60,
+ '%': 60,
+ '|': 20,
+ '=': 40,
+ '<': 40,
+ '>': 40,
+ '^': 40,
+ '**': 60,
+ '..': 20,
+ ':=': 10,
+ '!=': 40,
+ '<=': 40,
+ '>=': 40,
+ '~>': 40,
+ and: 30,
+ or: 25,
+ in: 40,
+ '&': 50,
+ '!': 0,
+ // not an operator, but needed as a stop character for name tokens
+ '~': 0, // not an operator, but needed as a stop character for name tokens
+ };
+ var escapes = {
+ // JSON string escape sequences - see json.org
+ '"': '"',
+ '\\': '\\',
+ '/': '/',
+ b: '\b',
+ f: '\f',
+ n: '\n',
+ r: '\r',
+ t: '\t',
+ }; // Tokenizer (lexer) - invoked by the parser to return one token at a time
+
+ var tokenizer = function tokenizer(path) {
+ var position = 0;
+ var length = path.length;
+
+ var create = function create(type, value) {
+ var obj = {
+ type: type,
+ value: value,
+ position: position,
+ };
+ return obj;
+ };
- default:
- return handleError({
- code: "S0205",
- stack: new Error().stack,
- position: next_token.position,
- token: value
- });
- }
+ var scanRegex = function scanRegex() {
+ // the prefix '/' will have been previously scanned. Find the end of the regex.
+ // search for closing '/' ignoring any that are escaped, or within brackets
+ var start = position;
+ var depth = 0;
+ var pattern;
+ var flags;
- node = Object.create(symbol);
- node.value = value;
- node.type = type;
- node.position = next_token.position;
- return node;
- }; // Pratt's algorithm
+ while (position < length) {
+ var currentChar = path.charAt(position);
+ if (currentChar === '/' && path.charAt(position - 1) !== '\\' && depth === 0) {
+ // end of regex found
+ pattern = path.substring(start, position);
- var expression = function expression(rbp) {
- var left;
- var t = node;
- advance(null, true);
- left = t.nud();
+ if (pattern === '') {
+ throw {
+ code: 'S0301',
+ stack: new Error().stack,
+ position: position,
+ };
+ }
- while (rbp < node.lbp) {
- t = node;
- advance();
- left = t.led(left);
- }
+ position++;
+ currentChar = path.charAt(position); // flags
- return left;
- };
+ start = position;
- var terminal = function terminal(id) {
- var s = symbol(id, 0);
+ while (currentChar === 'i' || currentChar === 'm') {
+ position++;
+ currentChar = path.charAt(position);
+ }
- s.nud = function () {
- return this;
- };
- }; // match infix operators
- //
- // left associative
+ flags = path.substring(start, position) + 'g';
+ return new RegExp(pattern, flags);
+ }
+ if (
+ (currentChar === '(' || currentChar === '[' || currentChar === '{') &&
+ path.charAt(position - 1) !== '\\'
+ ) {
+ depth++;
+ }
- var infix = function infix(id, bp, led) {
- var bindingPower = bp || operators[id];
- var s = symbol(id, bindingPower);
+ if (
+ (currentChar === ')' || currentChar === ']' || currentChar === '}') &&
+ path.charAt(position - 1) !== '\\'
+ ) {
+ depth--;
+ }
- s.led = led || function (left) {
- this.lhs = left;
- this.rhs = expression(bindingPower);
- this.type = "binary";
- return this;
- };
+ position++;
+ }
- return s;
- }; // match infix operators
- //
- // right associative
+ throw {
+ code: 'S0302',
+ stack: new Error().stack,
+ position: position,
+ };
+ };
+ var next = function next(prefix) {
+ if (position >= length) return null;
+ var currentChar = path.charAt(position); // skip whitespace
- var infixr = function infixr(id, bp, led) {
- var s = symbol(id, bp);
- s.led = led;
- return s;
- }; // match prefix operators
- //
+ while (position < length && ' \t\n\r\v'.indexOf(currentChar) > -1) {
+ position++;
+ currentChar = path.charAt(position);
+ } // skip comments
+ if (currentChar === '/' && path.charAt(position + 1) === '*') {
+ var commentStart = position;
+ position += 2;
+ currentChar = path.charAt(position);
- var prefix = function prefix(id, nud) {
- var s = symbol(id);
+ while (!(currentChar === '*' && path.charAt(position + 1) === '/')) {
+ currentChar = path.charAt(++position);
- s.nud = nud || function () {
- this.expression = expression(70);
- this.type = "unary";
- return this;
- };
+ if (position >= length) {
+ // no closing tag
+ throw {
+ code: 'S0106',
+ stack: new Error().stack,
+ position: commentStart,
+ };
+ }
+ }
- return s;
- };
+ position += 2;
+ currentChar = path.charAt(position);
+ return next(prefix); // need this to swallow any following whitespace
+ } // test for regex
- terminal("(end)");
- terminal("(name)");
- terminal("(literal)");
- terminal("(regex)");
- symbol(":");
- symbol(";");
- symbol(",");
- symbol(")");
- symbol("]");
- symbol("}");
- symbol(".."); // range operator
+ if (prefix !== true && currentChar === '/') {
+ position++;
+ return create('regex', scanRegex());
+ } // handle double-char operators
- infix("."); // field reference
+ if (currentChar === '.' && path.charAt(position + 1) === '.') {
+ // double-dot .. range operator
+ position += 2;
+ return create('operator', '..');
+ }
- infix("+"); // numeric addition
+ if (currentChar === ':' && path.charAt(position + 1) === '=') {
+ // := assignment
+ position += 2;
+ return create('operator', ':=');
+ }
- infix("-"); // numeric subtraction
+ if (currentChar === '!' && path.charAt(position + 1) === '=') {
+ // !=
+ position += 2;
+ return create('operator', '!=');
+ }
- infix("*"); // numeric multiplication
+ if (currentChar === '>' && path.charAt(position + 1) === '=') {
+ // >=
+ position += 2;
+ return create('operator', '>=');
+ }
- infix("/"); // numeric division
+ if (currentChar === '<' && path.charAt(position + 1) === '=') {
+ // <=
+ position += 2;
+ return create('operator', '<=');
+ }
- infix("%"); // numeric modulus
+ if (currentChar === '*' && path.charAt(position + 1) === '*') {
+ // ** descendant wildcard
+ position += 2;
+ return create('operator', '**');
+ }
- infix("="); // equality
+ if (currentChar === '~' && path.charAt(position + 1) === '>') {
+ // ~> chain function
+ position += 2;
+ return create('operator', '~>');
+ } // test for single char operators
+
+ if (Object.prototype.hasOwnProperty.call(operators, currentChar)) {
+ position++;
+ return create('operator', currentChar);
+ } // test for string literals
+
+ if (currentChar === '"' || currentChar === "'") {
+ var quoteType = currentChar; // double quoted string literal - find end of string
+
+ position++;
+ var qstr = '';
+
+ while (position < length) {
+ currentChar = path.charAt(position);
+
+ if (currentChar === '\\') {
+ // escape sequence
+ position++;
+ currentChar = path.charAt(position);
+
+ if (Object.prototype.hasOwnProperty.call(escapes, currentChar)) {
+ qstr += escapes[currentChar];
+ } else if (currentChar === 'u') {
+ // \u should be followed by 4 hex digits
+ var octets = path.substr(position + 1, 4);
+
+ if (/^[0-9a-fA-F]+$/.test(octets)) {
+ var codepoint = parseInt(octets, 16);
+ qstr += String.fromCharCode(codepoint);
+ position += 4;
+ } else {
+ throw {
+ code: 'S0104',
+ stack: new Error().stack,
+ position: position,
+ };
+ }
+ } else {
+ // illegal escape sequence
+ throw {
+ code: 'S0103',
+ stack: new Error().stack,
+ position: position,
+ token: currentChar,
+ };
+ }
+ } else if (currentChar === quoteType) {
+ position++;
+ return create('string', qstr);
+ } else {
+ qstr += currentChar;
+ }
- infix("<"); // less than
+ position++;
+ }
- infix(">"); // greater than
+ throw {
+ code: 'S0101',
+ stack: new Error().stack,
+ position: position,
+ };
+ } // test for numbers
- infix("!="); // not equal to
+ var numregex = /^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/;
+ var match = numregex.exec(path.substring(position));
- infix("<="); // less than or equal
+ if (match !== null) {
+ var num = parseFloat(match[0]);
- infix(">="); // greater than or equal
+ if (!isNaN(num) && isFinite(num)) {
+ position += match[0].length;
+ return create('number', num);
+ } else {
+ throw {
+ code: 'S0102',
+ stack: new Error().stack,
+ position: position,
+ token: match[0],
+ };
+ }
+ } // test for quoted names (backticks)
- infix("&"); // string concatenation
+ var name;
- infix("and"); // Boolean AND
+ if (currentChar === '`') {
+ // scan for closing quote
+ position++;
+ var end = path.indexOf('`', position);
- infix("or"); // Boolean OR
+ if (end !== -1) {
+ name = path.substring(position, end);
+ position = end + 1;
+ return create('name', name);
+ }
- infix("in"); // is member of array
+ position = length;
+ throw {
+ code: 'S0105',
+ stack: new Error().stack,
+ position: position,
+ };
+ } // test for names
+
+ var i = position;
+ var ch;
+
+ for (;;) {
+ ch = path.charAt(i);
+
+ if (
+ i === length ||
+ ' \t\n\r\v'.indexOf(ch) > -1 ||
+ Object.prototype.hasOwnProperty.call(operators, ch)
+ ) {
+ if (path.charAt(position) === '$') {
+ // variable reference
+ name = path.substring(position + 1, i);
+ position = i;
+ return create('variable', name);
+ } else {
+ name = path.substring(position, i);
+ position = i;
- terminal("and"); // the 'keywords' can also be used as terminals (field names)
+ switch (name) {
+ case 'or':
+ case 'in':
+ case 'and':
+ return create('operator', name);
- terminal("or"); //
+ case 'true':
+ return create('value', true);
- terminal("in"); //
+ case 'false':
+ return create('value', false);
- prefix("-"); // unary numeric negation
+ case 'null':
+ return create('value', null);
- infix("~>"); // function application
+ default:
+ if (position === length && name === '') {
+ // whitespace at end of input
+ return null;
+ }
- infixr("(error)", 10, function (left) {
- this.lhs = left;
- this.error = node.error;
- this.remaining = remainingTokens();
- this.type = 'error';
- return this;
- }); // field wildcard (single level)
+ return create('name', name);
+ }
+ }
+ } else {
+ i++;
+ }
+ }
+ };
- prefix('*', function () {
- this.type = "wildcard";
- return this;
- }); // descendant wildcard (multi-level)
+ return next;
+ }; // This parser implements the 'Top down operator precedence' algorithm developed by Vaughan R Pratt; http://dl.acm.org/citation.cfm?id=512931.
+ // and builds on the Javascript framework described by Douglas Crockford at http://javascript.crockford.com/tdop/tdop.html
+ // and in 'Beautiful Code', edited by Andy Oram and Greg Wilson, Copyright 2007 O'Reilly Media, Inc. 798-0-596-51004-6
+
+ var parser = function parser(source, recover) {
+ var node;
+ var lexer;
+ var symbol_table = {};
+ var errors = [];
+
+ var remainingTokens = function remainingTokens() {
+ var remaining = [];
+
+ if (node.id !== '(end)') {
+ remaining.push({
+ type: node.type,
+ value: node.value,
+ position: node.position,
+ });
+ }
- prefix('**', function () {
- this.type = "descendant";
- return this;
- }); // function invocation
+ var nxt = lexer();
- infix("(", operators['('], function (left) {
- // left is is what we are trying to invoke
- this.procedure = left;
- this.type = 'function';
- this.arguments = [];
+ while (nxt !== null) {
+ remaining.push(nxt);
+ nxt = lexer();
+ }
- if (node.id !== ')') {
- for (;;) {
- if (node.type === 'operator' && node.id === '?') {
- // partial function application
- this.type = 'partial';
- this.arguments.push(node);
- advance('?');
- } else {
- this.arguments.push(expression(0));
- }
+ return remaining;
+ };
- if (node.id !== ',') break;
- advance(',');
- }
- }
+ var base_symbol = {
+ nud: function nud() {
+ // error - symbol has been invoked as a unary operator
+ var err = {
+ code: 'S0211',
+ token: this.value,
+ position: this.position,
+ };
- advance(")", true); // if the name of the function is 'function' or λ, then this is function definition (lambda function)
-
- if (left.type === 'name' && (left.value === 'function' || left.value === "\u03BB")) {
- // all of the args must be VARIABLE tokens
- this.arguments.forEach(function (arg, index) {
- if (arg.type !== 'variable') {
- return handleError({
- code: "S0208",
- stack: new Error().stack,
- position: arg.position,
- token: arg.value,
- value: index + 1
- });
- }
- });
- this.type = 'lambda'; // is the next token a '<' - if so, parse the function signature
+ if (recover) {
+ err.remaining = remainingTokens();
+ err.type = 'error';
+ errors.push(err);
+ return err;
+ } else {
+ err.stack = new Error().stack;
+ throw err;
+ }
+ },
+ };
- if (node.id === '<') {
- var sigPos = node.position;
- var depth = 1;
- var sig = '<';
+ var symbol = function symbol(id, bp) {
+ var s = symbol_table[id];
+ bp = bp || 0;
- while (depth > 0 && node.id !== '{' && node.id !== '(end)') {
- var tok = advance();
+ if (s) {
+ if (bp >= s.lbp) {
+ s.lbp = bp;
+ }
+ } else {
+ s = Object.create(base_symbol);
+ s.id = s.value = id;
+ s.lbp = bp;
+ symbol_table[id] = s;
+ }
- if (tok.id === '>') {
- depth--;
- } else if (tok.id === '<') {
- depth++;
- }
+ return s;
+ };
- sig += tok.value;
- }
+ var handleError = function handleError(err) {
+ if (recover) {
+ // tokenize the rest of the buffer and add it to an error token
+ err.remaining = remainingTokens();
+ errors.push(err);
+ var symbol = symbol_table['(error)'];
+ node = Object.create(symbol);
+ node.error = err;
+ node.type = '(error)';
+ return node;
+ } else {
+ err.stack = new Error().stack;
+ throw err;
+ }
+ };
- advance('>');
+ var advance = function advance(id, infix) {
+ if (id && node.id !== id) {
+ var code;
- try {
- this.signature = parseSignature(sig);
- } catch (err) {
- // insert the position into this error
- err.position = sigPos + err.offset;
- return handleError(err);
- }
- } // parse the function body
+ if (node.id === '(end)') {
+ // unexpected end of buffer
+ code = 'S0203';
+ } else {
+ code = 'S0202';
+ }
+ var err = {
+ code: code,
+ position: node.position,
+ token: node.value,
+ value: id,
+ };
+ return handleError(err);
+ }
- advance('{');
- this.body = expression(0);
- advance('}');
- }
+ var next_token = lexer(infix);
- return this;
- }); // parenthesis - block expression
+ if (next_token === null) {
+ node = symbol_table['(end)'];
+ node.position = source.length;
+ return node;
+ }
- prefix("(", function () {
- var expressions = [];
+ var value = next_token.value;
+ var type = next_token.type;
+ var symbol;
- while (node.id !== ")") {
- expressions.push(expression(0));
+ switch (type) {
+ case 'name':
+ case 'variable':
+ symbol = symbol_table['(name)'];
+ break;
- if (node.id !== ";") {
- break;
- }
+ case 'operator':
+ symbol = symbol_table[value];
- advance(";");
- }
+ if (!symbol) {
+ return handleError({
+ code: 'S0204',
+ stack: new Error().stack,
+ position: next_token.position,
+ token: value,
+ });
+ }
- advance(")", true);
- this.type = 'block';
- this.expressions = expressions;
- return this;
- }); // array constructor
-
- prefix("[", function () {
- var a = [];
-
- if (node.id !== "]") {
- for (;;) {
- var item = expression(0);
-
- if (node.id === "..") {
- // range operator
- var range = {
- type: "binary",
- value: "..",
- position: node.position,
- lhs: item
- };
- advance("..");
- range.rhs = expression(0);
- item = range;
- }
+ break;
- a.push(item);
+ case 'string':
+ case 'number':
+ case 'value':
+ symbol = symbol_table['(literal)'];
+ break;
- if (node.id !== ",") {
- break;
- }
+ case 'regex':
+ type = 'regex';
+ symbol = symbol_table['(regex)'];
+ break;
- advance(",");
- }
- }
+ /* istanbul ignore next */
- advance("]", true);
- this.expressions = a;
- this.type = "unary";
- return this;
- }); // filter - predicate or array index
+ default:
+ return handleError({
+ code: 'S0205',
+ stack: new Error().stack,
+ position: next_token.position,
+ token: value,
+ });
+ }
- infix("[", operators['['], function (left) {
- if (node.id === "]") {
- // empty predicate means maintain singleton arrays in the output
- var step = left;
+ node = Object.create(symbol);
+ node.value = value;
+ node.type = type;
+ node.position = next_token.position;
+ return node;
+ }; // Pratt's algorithm
+
+ var expression = function expression(rbp) {
+ var left;
+ var t = node;
+ advance(null, true);
+ left = t.nud();
+
+ while (rbp < node.lbp) {
+ t = node;
+ advance();
+ left = t.led(left);
+ }
- while (step && step.type === 'binary' && step.value === '[') {
- step = step.lhs;
- }
+ return left;
+ };
- step.keepArray = true;
- advance("]");
- return left;
- } else {
- this.lhs = left;
- this.rhs = expression(operators[']']);
- this.type = 'binary';
- advance("]", true);
- return this;
- }
- }); // order-by
-
- infix("^", operators['^'], function (left) {
- advance("(");
- var terms = [];
-
- for (;;) {
- var term = {
- descending: false
- };
-
- if (node.id === "<") {
- // ascending sort
- advance("<");
- } else if (node.id === ">") {
- // descending sort
- term.descending = true;
- advance(">");
- } else {//unspecified - default to ascending
- }
+ var terminal = function terminal(id) {
+ var s = symbol(id, 0);
- term.expression = expression(0);
- terms.push(term);
+ s.nud = function () {
+ return this;
+ };
+ }; // match infix operators
+ //
+ // left associative
+
+ var infix = function infix(id, bp, led) {
+ var bindingPower = bp || operators[id];
+ var s = symbol(id, bindingPower);
+
+ s.led =
+ led ||
+ function (left) {
+ this.lhs = left;
+ this.rhs = expression(bindingPower);
+ this.type = 'binary';
+ return this;
+ };
- if (node.id !== ",") {
- break;
- }
+ return s;
+ }; // match infix operators
+ //
+ // right associative
+
+ var infixr = function infixr(id, bp, led) {
+ var s = symbol(id, bp);
+ s.led = led;
+ return s;
+ }; // match prefix operators
+ //
+
+ var prefix = function prefix(id, nud) {
+ var s = symbol(id);
+
+ s.nud =
+ nud ||
+ function () {
+ this.expression = expression(70);
+ this.type = 'unary';
+ return this;
+ };
- advance(",");
- }
+ return s;
+ };
- advance(")");
- this.lhs = left;
- this.rhs = terms;
- this.type = 'binary';
- return this;
- });
+ terminal('(end)');
+ terminal('(name)');
+ terminal('(literal)');
+ terminal('(regex)');
+ symbol(':');
+ symbol(';');
+ symbol(',');
+ symbol(')');
+ symbol(']');
+ symbol('}');
+ symbol('..'); // range operator
- var objectParser = function objectParser(left) {
- var a = [];
+ infix('.'); // field reference
- if (node.id !== "}") {
- for (;;) {
- var n = expression(0);
- advance(":");
- var v = expression(0);
- a.push([n, v]); // holds an array of name/value expression pairs
+ infix('+'); // numeric addition
- if (node.id !== ",") {
- break;
- }
+ infix('-'); // numeric subtraction
- advance(",");
- }
- }
+ infix('*'); // numeric multiplication
- advance("}", true);
+ infix('/'); // numeric division
- if (typeof left === 'undefined') {
- // NUD - unary prefix form
- this.lhs = a;
- this.type = "unary";
- } else {
- // LED - binary infix form
- this.lhs = left;
- this.rhs = a;
- this.type = 'binary';
- }
+ infix('%'); // numeric modulus
- return this;
- }; // object constructor
+ infix('='); // equality
+ infix('<'); // less than
- prefix("{", objectParser); // object grouping
+ infix('>'); // greater than
- infix("{", operators['{'], objectParser); // bind variable
+ infix('!='); // not equal to
- infixr(":=", operators[':='], function (left) {
- if (left.type !== 'variable') {
- return handleError({
- code: "S0212",
- stack: new Error().stack,
- position: left.position,
- token: left.value
- });
- }
+ infix('<='); // less than or equal
- this.lhs = left;
- this.rhs = expression(operators[':='] - 1); // subtract 1 from bindingPower for right associative operators
+ infix('>='); // greater than or equal
- this.type = "binary";
- return this;
- }); // focus variable bind
+ infix('&'); // string concatenation
- infix("@", operators['@'], function (left) {
- this.lhs = left;
- this.rhs = expression(operators['@']);
+ infix('and'); // Boolean AND
- if (this.rhs.type !== 'variable') {
- return handleError({
- code: "S0214",
- stack: new Error().stack,
- position: this.rhs.position,
- token: "@"
- });
- }
+ infix('or'); // Boolean OR
- this.type = "binary";
- return this;
- }); // index (position) variable bind
+ infix('in'); // is member of array
- infix("#", operators['#'], function (left) {
- this.lhs = left;
- this.rhs = expression(operators['#']);
+ terminal('and'); // the 'keywords' can also be used as terminals (field names)
- if (this.rhs.type !== 'variable') {
- return handleError({
- code: "S0214",
- stack: new Error().stack,
- position: this.rhs.position,
- token: "#"
- });
- }
+ terminal('or'); //
- this.type = "binary";
- return this;
- }); // if/then/else ternary operator ?:
+ terminal('in'); //
- infix("?", operators['?'], function (left) {
- this.type = 'condition';
- this.condition = left;
- this.then = expression(0);
+ prefix('-'); // unary numeric negation
- if (node.id === ':') {
- // else condition
- advance(":");
- this["else"] = expression(0);
- }
+ infix('~>'); // function application
- return this;
- }); // object transformer
+ infixr('(error)', 10, function (left) {
+ this.lhs = left;
+ this.error = node.error;
+ this.remaining = remainingTokens();
+ this.type = 'error';
+ return this;
+ }); // field wildcard (single level)
- prefix("|", function () {
- this.type = 'transform';
- this.pattern = expression(0);
- advance('|');
- this.update = expression(0);
+ prefix('*', function () {
+ this.type = 'wildcard';
+ return this;
+ }); // descendant wildcard (multi-level)
- if (node.id === ',') {
- advance(',');
- this["delete"] = expression(0);
- }
+ prefix('**', function () {
+ this.type = 'descendant';
+ return this;
+ }); // function invocation
- advance('|');
- return this;
- }); // tail call optimization
- // this is invoked by the post parser to analyse lambda functions to see
- // if they make a tail call. If so, it is replaced by a thunk which will
- // be invoked by the trampoline loop during function application.
- // This enables tail-recursive functions to be written without growing the stack
-
- var tail_call_optimize = function tail_call_optimize(expr) {
- var result;
-
- if (expr.type === 'function' && !expr.predicate) {
- var thunk = {
- type: 'lambda',
- thunk: true,
- arguments: [],
- position: expr.position
- };
- thunk.body = expr;
- result = thunk;
- } else if (expr.type === 'condition') {
- // analyse both branches
- expr.then = tail_call_optimize(expr.then);
-
- if (typeof expr["else"] !== 'undefined') {
- expr["else"] = tail_call_optimize(expr["else"]);
- }
+ infix('(', operators['('], function (left) {
+ // left is is what we are trying to invoke
+ this.procedure = left;
+ this.type = 'function';
+ this.arguments = [];
- result = expr;
- } else if (expr.type === 'block') {
- // only the last expression in the block
- var length = expr.expressions.length;
+ if (node.id !== ')') {
+ for (;;) {
+ if (node.type === 'operator' && node.id === '?') {
+ // partial function application
+ this.type = 'partial';
+ this.arguments.push(node);
+ advance('?');
+ } else {
+ this.arguments.push(expression(0));
+ }
- if (length > 0) {
- expr.expressions[length - 1] = tail_call_optimize(expr.expressions[length - 1]);
- }
+ if (node.id !== ',') break;
+ advance(',');
+ }
+ }
- result = expr;
- } else {
- result = expr;
- }
+ advance(')', true); // if the name of the function is 'function' or λ, then this is function definition (lambda function)
- return result;
- }; // post-parse stage
- // the purpose of this is flatten the parts of the AST representing location paths,
- // converting them to arrays of steps which in turn may contain arrays of predicates.
- // following this, nodes containing '.' and '[' should be eliminated from the AST.
-
-
- var ast_optimize = function ast_optimize(expr) {
- var result;
-
- switch (expr.type) {
- case 'binary':
- switch (expr.value) {
- case '.':
- var lstep = ast_optimize(expr.lhs);
- result = {
- type: 'path',
- steps: []
- };
+ if (left.type === 'name' && (left.value === 'function' || left.value === '\u03BB')) {
+ // all of the args must be VARIABLE tokens
+ this.arguments.forEach(function (arg, index) {
+ if (arg.type !== 'variable') {
+ return handleError({
+ code: 'S0208',
+ stack: new Error().stack,
+ position: arg.position,
+ token: arg.value,
+ value: index + 1,
+ });
+ }
+ });
+ this.type = 'lambda'; // is the next token a '<' - if so, parse the function signature
- if (lstep.type === 'path') {
- Array.prototype.push.apply(result.steps, lstep.steps);
- } else {
- result.steps = [lstep];
- }
+ if (node.id === '<') {
+ var sigPos = node.position;
+ var depth = 1;
+ var sig = '<';
- var rest = ast_optimize(expr.rhs);
+ while (depth > 0 && node.id !== '{' && node.id !== '(end)') {
+ var tok = advance();
- if (rest.type === 'function' && rest.procedure.type === 'path' && rest.procedure.steps.length === 1 && rest.procedure.steps[0].type === 'name' && result.steps[result.steps.length - 1].type === 'function') {
- // next function in chain of functions - will override a thenable
- result.steps[result.steps.length - 1].nextFunction = rest.procedure.steps[0].value;
- }
+ if (tok.id === '>') {
+ depth--;
+ } else if (tok.id === '<') {
+ depth++;
+ }
- if (rest.type !== 'path') {
- if (typeof rest.predicate !== 'undefined') {
- rest.stages = rest.predicate;
- delete rest.predicate;
- }
+ sig += tok.value;
+ }
- rest = {
- type: 'path',
- steps: [rest]
- };
- }
+ advance('>');
- Array.prototype.push.apply(result.steps, rest.steps); // any steps within a path that are string literals, should be changed to 'name'
+ try {
+ this.signature = parseSignature(sig);
+ } catch (err) {
+ // insert the position into this error
+ err.position = sigPos + err.offset;
+ return handleError(err);
+ }
+ } // parse the function body
- result.steps.filter(function (step) {
- if (step.type === 'number' || step.type === 'value') {
- // don't allow steps to be numbers or the values true/false/null
- throw {
- code: "S0213",
- stack: new Error().stack,
- position: step.position,
- value: step.value
- };
+ advance('{');
+ this.body = expression(0);
+ advance('}');
}
- return step.type === 'string';
- }).forEach(function (lit) {
- lit.type = 'name';
- }); // any step that signals keeping a singleton array, should be flagged on the path
+ return this;
+ }); // parenthesis - block expression
- if (result.steps.filter(function (step) {
- return step.keepArray === true;
- }).length > 0) {
- result.keepSingletonArray = true;
- } // if first step is a path constructor, flag it for special handling
+ prefix('(', function () {
+ var expressions = [];
+ while (node.id !== ')') {
+ expressions.push(expression(0));
- var firststep = result.steps[0];
+ if (node.id !== ';') {
+ break;
+ }
- if (firststep.type === 'unary' && firststep.value === '[') {
- firststep.consarray = true;
- } // if the last step is an array constructor, flag it so it doesn't flatten
+ advance(';');
+ }
+ advance(')', true);
+ this.type = 'block';
+ this.expressions = expressions;
+ return this;
+ }); // array constructor
+
+ prefix('[', function () {
+ var a = [];
+
+ if (node.id !== ']') {
+ for (;;) {
+ var item = expression(0);
+
+ if (node.id === '..') {
+ // range operator
+ var range = {
+ type: 'binary',
+ value: '..',
+ position: node.position,
+ lhs: item,
+ };
+ advance('..');
+ range.rhs = expression(0);
+ item = range;
+ }
- var laststep = result.steps[result.steps.length - 1];
+ a.push(item);
- if (laststep.type === 'unary' && laststep.value === '[') {
- laststep.consarray = true;
- }
+ if (node.id !== ',') {
+ break;
+ }
- break;
+ advance(',');
+ }
+ }
- case '[':
- // predicated step
- // LHS is a step or a predicated step
- // RHS is the predicate expr
- result = ast_optimize(expr.lhs);
- var step = result;
- var type = 'predicate';
+ advance(']', true);
+ this.expressions = a;
+ this.type = 'unary';
+ return this;
+ }); // filter - predicate or array index
- if (result.type === 'path') {
- step = result.steps[result.steps.length - 1];
- type = 'stages';
- }
+ infix('[', operators['['], function (left) {
+ if (node.id === ']') {
+ // empty predicate means maintain singleton arrays in the output
+ var step = left;
- if (typeof step.group !== 'undefined') {
- throw {
- code: "S0209",
- stack: new Error().stack,
- position: expr.position
- };
- }
+ while (step && step.type === 'binary' && step.value === '[') {
+ step = step.lhs;
+ }
- if (typeof step[type] === 'undefined') {
- step[type] = [];
- }
+ step.keepArray = true;
+ advance(']');
+ return left;
+ } else {
+ this.lhs = left;
+ this.rhs = expression(operators[']']);
+ this.type = 'binary';
+ advance(']', true);
+ return this;
+ }
+ }); // order-by
- step[type].push({
- type: 'filter',
- expr: ast_optimize(expr.rhs),
- position: expr.position
- });
- break;
+ infix('^', operators['^'], function (left) {
+ advance('(');
+ var terms = [];
- case '{':
- // group-by
- // LHS is a step or a predicated step
- // RHS is the object constructor expr
- result = ast_optimize(expr.lhs);
+ for (;;) {
+ var term = {
+ descending: false,
+ };
- if (typeof result.group !== 'undefined') {
- throw {
- code: "S0210",
- stack: new Error().stack,
- position: expr.position
- };
- } // object constructor - process each pair
+ if (node.id === '<') {
+ // ascending sort
+ advance('<');
+ } else if (node.id === '>') {
+ // descending sort
+ term.descending = true;
+ advance('>');
+ } else {
+ //unspecified - default to ascending
+ }
+ term.expression = expression(0);
+ terms.push(term);
- result.group = {
- lhs: expr.rhs.map(function (pair) {
- return [ast_optimize(pair[0]), ast_optimize(pair[1])];
- }),
- position: expr.position
- };
- break;
-
- case '^':
- // order-by
- // LHS is the array to be ordered
- // RHS defines the terms
- result = ast_optimize(expr.lhs);
- var tms = expr.rhs.map(function (terms) {
- return {
- descending: terms.descending,
- expression: ast_optimize(terms.expression)
- };
- });
+ if (node.id !== ',') {
+ break;
+ }
- if (result.type !== 'path') {
- result = {
- type: 'path',
- steps: [result]
- };
- }
+ advance(',');
+ }
- result.steps.push({
- type: 'sort',
- terms: tms,
- position: expr.position
+ advance(')');
+ this.lhs = left;
+ this.rhs = terms;
+ this.type = 'binary';
+ return this;
});
- break;
- case ':=':
- result = {
- type: 'bind',
- value: expr.value,
- position: expr.position
- };
- result.lhs = ast_optimize(expr.lhs);
- result.rhs = ast_optimize(expr.rhs);
- break;
+ var objectParser = function objectParser(left) {
+ var a = [];
- case '@':
- result = ast_optimize(expr.lhs);
- step = result;
+ if (node.id !== '}') {
+ for (;;) {
+ var n = expression(0);
+ advance(':');
+ var v = expression(0);
+ a.push([n, v]); // holds an array of name/value expression pairs
- if (result.type === 'path') {
- step = result.steps[result.steps.length - 1];
- } // throw error if there are any predicates defined at this point
- // at this point the only type of stages can be predicates
+ if (node.id !== ',') {
+ break;
+ }
+ advance(',');
+ }
+ }
- if (typeof step.stages !== 'undefined') {
- throw {
- code: "S0215",
- stack: new Error().stack,
- position: expr.position
- };
- } // also throw if this is applied after an 'order-by' clause
+ advance('}', true);
+ if (typeof left === 'undefined') {
+ // NUD - unary prefix form
+ this.lhs = a;
+ this.type = 'unary';
+ } else {
+ // LED - binary infix form
+ this.lhs = left;
+ this.rhs = a;
+ this.type = 'binary';
+ }
- if (step.type === 'sort') {
- throw {
- code: "S0216",
- stack: new Error().stack,
- position: expr.position
- };
- }
+ return this;
+ }; // object constructor
- if (expr.keepArray) {
- step.keepArray = true;
- }
+ prefix('{', objectParser); // object grouping
- step.focus = expr.rhs.value;
- step.tuple = true;
- break;
+ infix('{', operators['{'], objectParser); // bind variable
- case '#':
- result = ast_optimize(expr.lhs);
- step = result;
+ infixr(':=', operators[':='], function (left) {
+ if (left.type !== 'variable') {
+ return handleError({
+ code: 'S0212',
+ stack: new Error().stack,
+ position: left.position,
+ token: left.value,
+ });
+ }
- if (result.type === 'path') {
- step = result.steps[result.steps.length - 1];
- }
+ this.lhs = left;
+ this.rhs = expression(operators[':='] - 1); // subtract 1 from bindingPower for right associative operators
- if (typeof step.stages === 'undefined') {
- step.index = expr.rhs.value;
- } else {
- step.stages.push({
- type: 'index',
- value: expr.rhs.value,
- position: expr.position
- });
- }
+ this.type = 'binary';
+ return this;
+ }); // focus variable bind
- step.tuple = true;
- break;
+ infix('@', operators['@'], function (left) {
+ this.lhs = left;
+ this.rhs = expression(operators['@']);
- case '~>':
- result = {
- type: 'apply',
- value: expr.value,
- position: expr.position
- };
- result.lhs = ast_optimize(expr.lhs);
- result.rhs = ast_optimize(expr.rhs);
- break;
-
- default:
- result = {
- type: expr.type,
- value: expr.value,
- position: expr.position
- };
- result.lhs = ast_optimize(expr.lhs);
- result.rhs = ast_optimize(expr.rhs);
- }
+ if (this.rhs.type !== 'variable') {
+ return handleError({
+ code: 'S0214',
+ stack: new Error().stack,
+ position: this.rhs.position,
+ token: '@',
+ });
+ }
- break;
+ this.type = 'binary';
+ return this;
+ }); // index (position) variable bind
- case 'unary':
- result = {
- type: expr.type,
- value: expr.value,
- position: expr.position
- };
+ infix('#', operators['#'], function (left) {
+ this.lhs = left;
+ this.rhs = expression(operators['#']);
- if (expr.value === '[') {
- // array constructor - process each item
- result.expressions = expr.expressions.map(function (item) {
- return ast_optimize(item);
- });
- } else if (expr.value === '{') {
- // object constructor - process each pair
- result.lhs = expr.lhs.map(function (pair) {
- return [ast_optimize(pair[0]), ast_optimize(pair[1])];
- });
- } else {
- // all other unary expressions - just process the expression
- result.expression = ast_optimize(expr.expression); // if unary minus on a number, then pre-process
+ if (this.rhs.type !== 'variable') {
+ return handleError({
+ code: 'S0214',
+ stack: new Error().stack,
+ position: this.rhs.position,
+ token: '#',
+ });
+ }
- if (expr.value === '-' && result.expression.type === 'number') {
- result = result.expression;
- result.value = -result.value;
- }
- }
+ this.type = 'binary';
+ return this;
+ }); // if/then/else ternary operator ?:
- break;
+ infix('?', operators['?'], function (left) {
+ this.type = 'condition';
+ this.condition = left;
+ this.then = expression(0);
- case 'function':
- case 'partial':
- result = {
- type: expr.type,
- name: expr.name,
- value: expr.value,
- position: expr.position
- };
- result.arguments = expr.arguments.map(function (arg) {
- return ast_optimize(arg);
- });
- result.procedure = ast_optimize(expr.procedure);
- break;
+ if (node.id === ':') {
+ // else condition
+ advance(':');
+ this['else'] = expression(0);
+ }
- case 'lambda':
- result = {
- type: expr.type,
- arguments: expr.arguments,
- signature: expr.signature,
- position: expr.position
- };
- var body = ast_optimize(expr.body);
- result.body = tail_call_optimize(body);
- break;
+ return this;
+ }); // object transformer
+
+ prefix('|', function () {
+ this.type = 'transform';
+ this.pattern = expression(0);
+ advance('|');
+ this.update = expression(0);
+
+ if (node.id === ',') {
+ advance(',');
+ this['delete'] = expression(0);
+ }
+
+ advance('|');
+ return this;
+ }); // tail call optimization
+ // this is invoked by the post parser to analyse lambda functions to see
+ // if they make a tail call. If so, it is replaced by a thunk which will
+ // be invoked by the trampoline loop during function application.
+ // This enables tail-recursive functions to be written without growing the stack
+
+ var tail_call_optimize = function tail_call_optimize(expr) {
+ var result;
+
+ if (expr.type === 'function' && !expr.predicate) {
+ var thunk = {
+ type: 'lambda',
+ thunk: true,
+ arguments: [],
+ position: expr.position,
+ };
+ thunk.body = expr;
+ result = thunk;
+ } else if (expr.type === 'condition') {
+ // analyse both branches
+ expr.then = tail_call_optimize(expr.then);
+
+ if (typeof expr['else'] !== 'undefined') {
+ expr['else'] = tail_call_optimize(expr['else']);
+ }
- case 'condition':
- result = {
- type: expr.type,
- position: expr.position
- };
- result.condition = ast_optimize(expr.condition);
- result.then = ast_optimize(expr.then);
+ result = expr;
+ } else if (expr.type === 'block') {
+ // only the last expression in the block
+ var length = expr.expressions.length;
- if (typeof expr["else"] !== 'undefined') {
- result["else"] = ast_optimize(expr["else"]);
- }
+ if (length > 0) {
+ expr.expressions[length - 1] = tail_call_optimize(expr.expressions[length - 1]);
+ }
- break;
+ result = expr;
+ } else {
+ result = expr;
+ }
- case 'transform':
- result = {
- type: expr.type,
- position: expr.position
- };
- result.pattern = ast_optimize(expr.pattern);
- result.update = ast_optimize(expr.update);
+ return result;
+ }; // post-parse stage
+ // the purpose of this is flatten the parts of the AST representing location paths,
+ // converting them to arrays of steps which in turn may contain arrays of predicates.
+ // following this, nodes containing '.' and '[' should be eliminated from the AST.
+
+ var ast_optimize = function ast_optimize(expr) {
+ var result;
+
+ switch (expr.type) {
+ case 'binary':
+ switch (expr.value) {
+ case '.':
+ var lstep = ast_optimize(expr.lhs);
+ result = {
+ type: 'path',
+ steps: [],
+ };
+
+ if (lstep.type === 'path') {
+ Array.prototype.push.apply(result.steps, lstep.steps);
+ } else {
+ result.steps = [lstep];
+ }
- if (typeof expr["delete"] !== 'undefined') {
- result["delete"] = ast_optimize(expr["delete"]);
- }
+ var rest = ast_optimize(expr.rhs);
+
+ if (
+ rest.type === 'function' &&
+ rest.procedure.type === 'path' &&
+ rest.procedure.steps.length === 1 &&
+ rest.procedure.steps[0].type === 'name' &&
+ result.steps[result.steps.length - 1].type === 'function'
+ ) {
+ // next function in chain of functions - will override a thenable
+ result.steps[result.steps.length - 1].nextFunction = rest.procedure.steps[0].value;
+ }
- break;
+ if (rest.type !== 'path') {
+ if (typeof rest.predicate !== 'undefined') {
+ rest.stages = rest.predicate;
+ delete rest.predicate;
+ }
- case 'block':
- result = {
- type: expr.type,
- position: expr.position
- }; // array of expressions - process each one
+ rest = {
+ type: 'path',
+ steps: [rest],
+ };
+ }
- result.expressions = expr.expressions.map(function (item) {
- var part = ast_optimize(item);
+ Array.prototype.push.apply(result.steps, rest.steps); // any steps within a path that are string literals, should be changed to 'name'
+
+ result.steps
+ .filter(function (step) {
+ if (step.type === 'number' || step.type === 'value') {
+ // don't allow steps to be numbers or the values true/false/null
+ throw {
+ code: 'S0213',
+ stack: new Error().stack,
+ position: step.position,
+ value: step.value,
+ };
+ }
- if (part.consarray || part.type === 'path' && part.steps[0].consarray) {
- result.consarray = true;
- }
+ return step.type === 'string';
+ })
+ .forEach(function (lit) {
+ lit.type = 'name';
+ }); // any step that signals keeping a singleton array, should be flagged on the path
- return part;
- }); // TODO scan the array of expressions to see if any of them assign variables
- // if so, need to mark the block as one that needs to create a new frame
+ if (
+ result.steps.filter(function (step) {
+ return step.keepArray === true;
+ }).length > 0
+ ) {
+ result.keepSingletonArray = true;
+ } // if first step is a path constructor, flag it for special handling
- break;
+ var firststep = result.steps[0];
- case 'name':
- result = {
- type: 'path',
- steps: [expr]
- };
+ if (firststep.type === 'unary' && firststep.value === '[') {
+ firststep.consarray = true;
+ } // if the last step is an array constructor, flag it so it doesn't flatten
- if (expr.keepArray) {
- result.keepSingletonArray = true;
- }
+ var laststep = result.steps[result.steps.length - 1];
- break;
+ if (laststep.type === 'unary' && laststep.value === '[') {
+ laststep.consarray = true;
+ }
- case 'string':
- case 'number':
- case 'value':
- case 'wildcard':
- case 'descendant':
- case 'variable':
- case 'regex':
- result = expr;
- break;
+ break;
- case 'operator':
- // the tokens 'and' and 'or' might have been used as a name rather than an operator
- if (expr.value === 'and' || expr.value === 'or' || expr.value === 'in') {
- expr.type = 'name';
- result = ast_optimize(expr);
- } else
- /* istanbul ignore else */
- if (expr.value === '?') {
- // partial application
- result = expr;
- } else {
- throw {
- code: "S0201",
- stack: new Error().stack,
- position: expr.position,
- token: expr.value
- };
- }
+ case '[':
+ // predicated step
+ // LHS is a step or a predicated step
+ // RHS is the predicate expr
+ result = ast_optimize(expr.lhs);
+ var step = result;
+ var type = 'predicate';
+
+ if (result.type === 'path') {
+ step = result.steps[result.steps.length - 1];
+ type = 'stages';
+ }
- break;
+ if (typeof step.group !== 'undefined') {
+ throw {
+ code: 'S0209',
+ stack: new Error().stack,
+ position: expr.position,
+ };
+ }
- case 'error':
- result = expr;
+ if (typeof step[type] === 'undefined') {
+ step[type] = [];
+ }
- if (expr.lhs) {
- result = ast_optimize(expr.lhs);
- }
+ step[type].push({
+ type: 'filter',
+ expr: ast_optimize(expr.rhs),
+ position: expr.position,
+ });
+ break;
- break;
+ case '{':
+ // group-by
+ // LHS is a step or a predicated step
+ // RHS is the object constructor expr
+ result = ast_optimize(expr.lhs);
+
+ if (typeof result.group !== 'undefined') {
+ throw {
+ code: 'S0210',
+ stack: new Error().stack,
+ position: expr.position,
+ };
+ } // object constructor - process each pair
+
+ result.group = {
+ lhs: expr.rhs.map(function (pair) {
+ return [ast_optimize(pair[0]), ast_optimize(pair[1])];
+ }),
+ position: expr.position,
+ };
+ break;
- default:
- var code = "S0206";
- /* istanbul ignore else */
+ case '^':
+ // order-by
+ // LHS is the array to be ordered
+ // RHS defines the terms
+ result = ast_optimize(expr.lhs);
+ var tms = expr.rhs.map(function (terms) {
+ return {
+ descending: terms.descending,
+ expression: ast_optimize(terms.expression),
+ };
+ });
- if (expr.id === '(end)') {
- code = "S0207";
- }
+ if (result.type !== 'path') {
+ result = {
+ type: 'path',
+ steps: [result],
+ };
+ }
- var err = {
- code: code,
- position: expr.position,
- token: expr.value
- };
+ result.steps.push({
+ type: 'sort',
+ terms: tms,
+ position: expr.position,
+ });
+ break;
- if (recover) {
- errors.push(err);
- return {
- type: 'error',
- error: err
- };
- } else {
- err.stack = new Error().stack;
- throw err;
- }
+ case ':=':
+ result = {
+ type: 'bind',
+ value: expr.value,
+ position: expr.position,
+ };
+ result.lhs = ast_optimize(expr.lhs);
+ result.rhs = ast_optimize(expr.rhs);
+ break;
- }
+ case '@':
+ result = ast_optimize(expr.lhs);
+ step = result;
+
+ if (result.type === 'path') {
+ step = result.steps[result.steps.length - 1];
+ } // throw error if there are any predicates defined at this point
+ // at this point the only type of stages can be predicates
+
+ if (typeof step.stages !== 'undefined') {
+ throw {
+ code: 'S0215',
+ stack: new Error().stack,
+ position: expr.position,
+ };
+ } // also throw if this is applied after an 'order-by' clause
+
+ if (step.type === 'sort') {
+ throw {
+ code: 'S0216',
+ stack: new Error().stack,
+ position: expr.position,
+ };
+ }
- if (expr.keepArray) {
- result.keepArray = true;
- }
+ if (expr.keepArray) {
+ step.keepArray = true;
+ }
- return result;
- }; // now invoke the tokenizer and the parser and return the syntax tree
+ step.focus = expr.rhs.value;
+ step.tuple = true;
+ break;
+ case '#':
+ result = ast_optimize(expr.lhs);
+ step = result;
- lexer = tokenizer(source);
- advance(); // parse the tokens
+ if (result.type === 'path') {
+ step = result.steps[result.steps.length - 1];
+ }
- var expr = expression(0);
+ if (typeof step.stages === 'undefined') {
+ step.index = expr.rhs.value;
+ } else {
+ step.stages.push({
+ type: 'index',
+ value: expr.rhs.value,
+ position: expr.position,
+ });
+ }
- if (node.id !== '(end)') {
- var err = {
- code: "S0201",
- position: node.position,
- token: node.value
- };
- handleError(err);
- }
+ step.tuple = true;
+ break;
- expr = ast_optimize(expr);
+ case '~>':
+ result = {
+ type: 'apply',
+ value: expr.value,
+ position: expr.position,
+ };
+ result.lhs = ast_optimize(expr.lhs);
+ result.rhs = ast_optimize(expr.rhs);
+ break;
- if (errors.length > 0) {
- expr.errors = errors;
- }
+ default:
+ result = {
+ type: expr.type,
+ value: expr.value,
+ position: expr.position,
+ };
+ result.lhs = ast_optimize(expr.lhs);
+ result.rhs = ast_optimize(expr.rhs);
+ }
- return expr;
- };
+ break;
- return parser;
-}();
+ case 'unary':
+ result = {
+ type: expr.type,
+ value: expr.value,
+ position: expr.position,
+ };
-module.exports = parser;
-},{"./signature":5}],5:[function(require,module,exports){
-"use strict";
+ if (expr.value === '[') {
+ // array constructor - process each item
+ result.expressions = expr.expressions.map(function (item) {
+ return ast_optimize(item);
+ });
+ } else if (expr.value === '{') {
+ // object constructor - process each pair
+ result.lhs = expr.lhs.map(function (pair) {
+ return [ast_optimize(pair[0]), ast_optimize(pair[1])];
+ });
+ } else {
+ // all other unary expressions - just process the expression
+ result.expression = ast_optimize(expr.expression); // if unary minus on a number, then pre-process
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+ if (expr.value === '-' && result.expression.type === 'number') {
+ result = result.expression;
+ result.value = -result.value;
+ }
+ }
-/**
- * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
-var utils = require('./utils');
-
-var signature = function () {
- 'use strict'; // A mapping between the function signature symbols and the full plural of the type
- // Expected to be used in error messages
-
- var arraySignatureMapping = {
- "a": "arrays",
- "b": "booleans",
- "f": "functions",
- "n": "numbers",
- "o": "objects",
- "s": "strings"
- };
- /**
- * Parses a function signature definition and returns a validation function
- * @param {string} signature - the signature between the
- * @returns {Function} validation function
- */
-
- function parseSignature(signature) {
- // create a Regex that represents this signature and return a function that when invoked,
- // returns the validated (possibly fixed-up) arguments, or throws a validation error
- // step through the signature, one symbol at a time
- var position = 1;
- var params = [];
- var param = {};
- var prevParam = param;
-
- while (position < signature.length) {
- var symbol = signature.charAt(position);
-
- if (symbol === ':') {
- // TODO figure out what to do with the return type
- // ignore it for now
- break;
- }
+ break;
+
+ case 'function':
+ case 'partial':
+ result = {
+ type: expr.type,
+ name: expr.name,
+ value: expr.value,
+ position: expr.position,
+ };
+ result.arguments = expr.arguments.map(function (arg) {
+ return ast_optimize(arg);
+ });
+ result.procedure = ast_optimize(expr.procedure);
+ break;
+
+ case 'lambda':
+ result = {
+ type: expr.type,
+ arguments: expr.arguments,
+ signature: expr.signature,
+ position: expr.position,
+ };
+ var body = ast_optimize(expr.body);
+ result.body = tail_call_optimize(body);
+ break;
+
+ case 'condition':
+ result = {
+ type: expr.type,
+ position: expr.position,
+ };
+ result.condition = ast_optimize(expr.condition);
+ result.then = ast_optimize(expr.then);
+
+ if (typeof expr['else'] !== 'undefined') {
+ result['else'] = ast_optimize(expr['else']);
+ }
- var next = function next() {
- params.push(param);
- prevParam = param;
- param = {};
- };
+ break;
- var findClosingBracket = function findClosingBracket(str, start, openSymbol, closeSymbol) {
- // returns the position of the closing symbol (e.g. bracket) in a string
- // that balances the opening symbol at position start
- var depth = 1;
- var position = start;
+ case 'transform':
+ result = {
+ type: expr.type,
+ position: expr.position,
+ };
+ result.pattern = ast_optimize(expr.pattern);
+ result.update = ast_optimize(expr.update);
- while (position < str.length) {
- position++;
- symbol = str.charAt(position);
+ if (typeof expr['delete'] !== 'undefined') {
+ result['delete'] = ast_optimize(expr['delete']);
+ }
- if (symbol === closeSymbol) {
- depth--;
+ break;
- if (depth === 0) {
- // we're done
- break; // out of while loop
- }
- } else if (symbol === openSymbol) {
- depth++;
- }
- }
+ case 'block':
+ result = {
+ type: expr.type,
+ position: expr.position,
+ }; // array of expressions - process each one
- return position;
- };
+ result.expressions = expr.expressions.map(function (item) {
+ var part = ast_optimize(item);
- switch (symbol) {
- case 's': // string
+ if (part.consarray || (part.type === 'path' && part.steps[0].consarray)) {
+ result.consarray = true;
+ }
- case 'n': // number
+ return part;
+ }); // TODO scan the array of expressions to see if any of them assign variables
+ // if so, need to mark the block as one that needs to create a new frame
- case 'b': // boolean
+ break;
- case 'l': // not so sure about expecting null?
+ case 'name':
+ result = {
+ type: 'path',
+ steps: [expr],
+ };
- case 'o':
- // object
- param.regex = '[' + symbol + 'm]';
- param.type = symbol;
- next();
- break;
+ if (expr.keepArray) {
+ result.keepSingletonArray = true;
+ }
- case 'a':
- // array
- // normally treat any value as singleton array
- param.regex = '[asnblfom]';
- param.type = symbol;
- param.array = true;
- next();
- break;
+ break;
+
+ case 'string':
+ case 'number':
+ case 'value':
+ case 'wildcard':
+ case 'descendant':
+ case 'variable':
+ case 'regex':
+ result = expr;
+ break;
+
+ case 'operator':
+ // the tokens 'and' and 'or' might have been used as a name rather than an operator
+ if (expr.value === 'and' || expr.value === 'or' || expr.value === 'in') {
+ expr.type = 'name';
+ result = ast_optimize(expr);
+ } else if (expr.value === '?') {
+ /* istanbul ignore else */
+ // partial application
+ result = expr;
+ } else {
+ throw {
+ code: 'S0201',
+ stack: new Error().stack,
+ position: expr.position,
+ token: expr.value,
+ };
+ }
- case 'f':
- // function
- param.regex = 'f';
- param.type = symbol;
- next();
- break;
+ break;
- case 'j':
- // any JSON type
- param.regex = '[asnblom]';
- param.type = symbol;
- next();
- break;
+ case 'error':
+ result = expr;
- case 'x':
- // any type
- param.regex = '[asnblfom]';
- param.type = symbol;
- next();
- break;
+ if (expr.lhs) {
+ result = ast_optimize(expr.lhs);
+ }
- case '-':
- // use context if param not supplied
- prevParam.context = true;
- prevParam.contextRegex = new RegExp(prevParam.regex); // pre-compiled to test the context type at runtime
+ break;
- prevParam.regex += '?';
- break;
+ default:
+ var code = 'S0206';
+ /* istanbul ignore else */
- case '?': // optional param
+ if (expr.id === '(end)') {
+ code = 'S0207';
+ }
- case '+':
- // one or more
- prevParam.regex += symbol;
- break;
+ var err = {
+ code: code,
+ position: expr.position,
+ token: expr.value,
+ };
+
+ if (recover) {
+ errors.push(err);
+ return {
+ type: 'error',
+ error: err,
+ };
+ } else {
+ err.stack = new Error().stack;
+ throw err;
+ }
+ }
- case '(':
- // choice of types
- // search forward for matching ')'
- var endParen = findClosingBracket(signature, position, '(', ')');
- var choice = signature.substring(position + 1, endParen);
+ if (expr.keepArray) {
+ result.keepArray = true;
+ }
- if (choice.indexOf('<') === -1) {
- // no parameterized types, simple regex
- param.regex = '[' + choice + 'm]';
- } else {
- // TODO harder
- throw {
- code: "S0402",
- stack: new Error().stack,
- value: choice,
- offset: position
- };
- }
+ return result;
+ }; // now invoke the tokenizer and the parser and return the syntax tree
- param.type = '(' + choice + ')';
- position = endParen;
- next();
- break;
+ lexer = tokenizer(source);
+ advance(); // parse the tokens
- case '<':
- // type parameter - can only be applied to 'a' and 'f'
- if (prevParam.type === 'a' || prevParam.type === 'f') {
- // search forward for matching '>'
- var endPos = findClosingBracket(signature, position, '<', '>');
- prevParam.subtype = signature.substring(position + 1, endPos);
- position = endPos;
- } else {
- throw {
- code: "S0401",
- stack: new Error().stack,
- value: prevParam.type,
- offset: position
- };
- }
+ var expr = expression(0);
- break;
- }
+ if (node.id !== '(end)') {
+ var err = {
+ code: 'S0201',
+ position: node.position,
+ token: node.value,
+ };
+ handleError(err);
+ }
- position++;
- }
+ expr = ast_optimize(expr);
- var regexStr = '^' + params.map(function (param) {
- return '(' + param.regex + ')';
- }).join('') + '$';
- var regex = new RegExp(regexStr);
+ if (errors.length > 0) {
+ expr.errors = errors;
+ }
- var getSymbol = function getSymbol(value) {
- var symbol;
+ return expr;
+ };
- if (utils.isFunction(value)) {
- symbol = 'f';
- } else {
- var type = _typeof(value);
-
- switch (type) {
- case 'string':
- symbol = 's';
- break;
-
- case 'number':
- symbol = 'n';
- break;
-
- case 'boolean':
- symbol = 'b';
- break;
-
- case 'object':
- if (value === null) {
- symbol = 'l';
- } else if (Array.isArray(value)) {
- symbol = 'a';
+ return parser;
+ })();
+
+ module.exports = parser;
+ },
+ { './signature': 5 },
+ ],
+ 5: [
+ function (require, module, exports) {
+ 'use strict';
+
+ function _typeof(obj) {
+ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
+ _typeof = function _typeof(obj) {
+ return typeof obj;
+ };
} else {
- symbol = 'o';
+ _typeof = function _typeof(obj) {
+ return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
+ ? 'symbol'
+ : typeof obj;
+ };
}
+ return _typeof(obj);
+ }
- break;
-
- case 'undefined':
- default:
- // any value can be undefined, but should be allowed to match
- symbol = 'm';
- // m for missing
- }
- }
-
- return symbol;
- };
+ /**
+ * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
+ * Project name: JSONata
+ * This project is licensed under the MIT License, see LICENSE
+ */
+ var utils = require('./utils');
+
+ var signature = (function () {
+ 'use strict'; // A mapping between the function signature symbols and the full plural of the type
+ // Expected to be used in error messages
+
+ var arraySignatureMapping = {
+ a: 'arrays',
+ b: 'booleans',
+ f: 'functions',
+ n: 'numbers',
+ o: 'objects',
+ s: 'strings',
+ };
+ /**
+ * Parses a function signature definition and returns a validation function
+ * @param {string} signature - the signature between the
+ * @returns {Function} validation function
+ */
+
+ function parseSignature(signature) {
+ // create a Regex that represents this signature and return a function that when invoked,
+ // returns the validated (possibly fixed-up) arguments, or throws a validation error
+ // step through the signature, one symbol at a time
+ var position = 1;
+ var params = [];
+ var param = {};
+ var prevParam = param;
+
+ while (position < signature.length) {
+ var symbol = signature.charAt(position);
+
+ if (symbol === ':') {
+ // TODO figure out what to do with the return type
+ // ignore it for now
+ break;
+ }
- var throwValidationError = function throwValidationError(badArgs, badSig) {
- // to figure out where this went wrong we need apply each component of the
- // regex to each argument until we get to the one that fails to match
- var partialPattern = '^';
- var goodTo = 0;
-
- for (var index = 0; index < params.length; index++) {
- partialPattern += params[index].regex;
- var match = badSig.match(partialPattern);
-
- if (match === null) {
- // failed here
- throw {
- code: "T0410",
- stack: new Error().stack,
- value: badArgs[goodTo],
- index: goodTo + 1
- };
- }
+ var next = function next() {
+ params.push(param);
+ prevParam = param;
+ param = {};
+ };
- goodTo = match[0].length;
- } // if it got this far, it's probably because of extraneous arguments (we
- // haven't added the trailing '$' in the regex yet.
+ var findClosingBracket = function findClosingBracket(str, start, openSymbol, closeSymbol) {
+ // returns the position of the closing symbol (e.g. bracket) in a string
+ // that balances the opening symbol at position start
+ var depth = 1;
+ var position = start;
+ while (position < str.length) {
+ position++;
+ symbol = str.charAt(position);
- throw {
- code: "T0410",
- stack: new Error().stack,
- value: badArgs[goodTo],
- index: goodTo + 1
- };
- };
+ if (symbol === closeSymbol) {
+ depth--;
- return {
- definition: signature,
- validate: function validate(args, context) {
- var suppliedSig = '';
- args.forEach(function (arg) {
- suppliedSig += getSymbol(arg);
- });
- var isValid = regex.exec(suppliedSig);
-
- if (isValid) {
- var validatedArgs = [];
- var argIndex = 0;
- params.forEach(function (param, index) {
- var arg = args[argIndex];
- var match = isValid[index + 1];
-
- if (match === '') {
- if (param.context && param.contextRegex) {
- // substitute context value for missing arg
- // first check that the context value is the right type
- var contextType = getSymbol(context); // test contextType against the regex for this arg (without the trailing ?)
-
- if (param.contextRegex.test(contextType)) {
- validatedArgs.push(context);
- } else {
- // context value not compatible with this argument
- throw {
- code: "T0411",
- stack: new Error().stack,
- value: context,
- index: argIndex + 1
- };
- }
- } else {
- validatedArgs.push(arg);
- argIndex++;
- }
- } else {
- // may have matched multiple args (if the regex ends with a '+'
- // split into single tokens
- match.split('').forEach(function (single) {
- if (param.type === 'a') {
- if (single === 'm') {
- // missing (undefined)
- arg = undefined;
- } else {
- arg = args[argIndex];
- var arrayOK = true; // is there type information on the contents of the array?
-
- if (typeof param.subtype !== 'undefined') {
- if (single !== 'a' && match !== param.subtype) {
- arrayOK = false;
- } else if (single === 'a') {
- if (arg.length > 0) {
- var itemType = getSymbol(arg[0]);
-
- if (itemType !== param.subtype.charAt(0)) {
- // TODO recurse further
- arrayOK = false;
- } else {
- // make sure every item in the array is this type
- var differentItems = arg.filter(function (val) {
- return getSymbol(val) !== itemType;
- });
- arrayOK = differentItems.length === 0;
- }
- }
+ if (depth === 0) {
+ // we're done
+ break; // out of while loop
}
+ } else if (symbol === openSymbol) {
+ depth++;
}
+ }
+
+ return position;
+ };
- if (!arrayOK) {
+ switch (symbol) {
+ case 's': // string
+
+ case 'n': // number
+
+ case 'b': // boolean
+
+ case 'l': // not so sure about expecting null?
+
+ case 'o':
+ // object
+ param.regex = '[' + symbol + 'm]';
+ param.type = symbol;
+ next();
+ break;
+
+ case 'a':
+ // array
+ // normally treat any value as singleton array
+ param.regex = '[asnblfom]';
+ param.type = symbol;
+ param.array = true;
+ next();
+ break;
+
+ case 'f':
+ // function
+ param.regex = 'f';
+ param.type = symbol;
+ next();
+ break;
+
+ case 'j':
+ // any JSON type
+ param.regex = '[asnblom]';
+ param.type = symbol;
+ next();
+ break;
+
+ case 'x':
+ // any type
+ param.regex = '[asnblfom]';
+ param.type = symbol;
+ next();
+ break;
+
+ case '-':
+ // use context if param not supplied
+ prevParam.context = true;
+ prevParam.contextRegex = new RegExp(prevParam.regex); // pre-compiled to test the context type at runtime
+
+ prevParam.regex += '?';
+ break;
+
+ case '?': // optional param
+
+ case '+':
+ // one or more
+ prevParam.regex += symbol;
+ break;
+
+ case '(':
+ // choice of types
+ // search forward for matching ')'
+ var endParen = findClosingBracket(signature, position, '(', ')');
+ var choice = signature.substring(position + 1, endParen);
+
+ if (choice.indexOf('<') === -1) {
+ // no parameterized types, simple regex
+ param.regex = '[' + choice + 'm]';
+ } else {
+ // TODO harder
throw {
- code: "T0412",
+ code: 'S0402',
stack: new Error().stack,
- value: arg,
- index: argIndex + 1,
- type: arraySignatureMapping[param.subtype]
+ value: choice,
+ offset: position,
};
- } // the function expects an array. If it's not one, make it so
-
+ }
- if (single !== 'a') {
- arg = [arg];
+ param.type = '(' + choice + ')';
+ position = endParen;
+ next();
+ break;
+
+ case '<':
+ // type parameter - can only be applied to 'a' and 'f'
+ if (prevParam.type === 'a' || prevParam.type === 'f') {
+ // search forward for matching '>'
+ var endPos = findClosingBracket(signature, position, '<', '>');
+ prevParam.subtype = signature.substring(position + 1, endPos);
+ position = endPos;
+ } else {
+ throw {
+ code: 'S0401',
+ stack: new Error().stack,
+ value: prevParam.type,
+ offset: position,
+ };
}
- }
- validatedArgs.push(arg);
- argIndex++;
- } else {
- validatedArgs.push(arg);
- argIndex++;
+ break;
}
- });
- }
- });
- return validatedArgs;
- }
-
- throwValidationError(args, suppliedSig);
- }
- };
- }
-
- return parseSignature;
-}();
-
-module.exports = signature;
-},{"./utils":6}],6:[function(require,module,exports){
-"use strict";
-
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-/**
- * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
- * Project name: JSONata
- * This project is licensed under the MIT License, see LICENSE
- */
-var utils = function () {
- 'use strict';
- /**
- * Check if value is a finite number
- * @param {float} n - number to evaluate
- * @returns {boolean} True if n is a finite number
- */
-
- function isNumeric(n) {
- var isNum = false;
-
- if (typeof n === 'number') {
- isNum = !isNaN(n);
-
- if (isNum && !isFinite(n)) {
- throw {
- code: "D1001",
- value: n,
- stack: new Error().stack
- };
- }
- }
-
- return isNum;
- }
- /**
- * Returns true if the arg is an array of strings
- * @param {*} arg - the item to test
- * @returns {boolean} True if arg is an array of strings
- */
+ position++;
+ }
- function isArrayOfStrings(arg) {
- var result = false;
- /* istanbul ignore else */
+ var regexStr =
+ '^' +
+ params
+ .map(function (param) {
+ return '(' + param.regex + ')';
+ })
+ .join('') +
+ '$';
+ var regex = new RegExp(regexStr);
+
+ var getSymbol = function getSymbol(value) {
+ var symbol;
+
+ if (utils.isFunction(value)) {
+ symbol = 'f';
+ } else {
+ var type = _typeof(value);
- if (Array.isArray(arg)) {
- result = arg.filter(function (item) {
- return typeof item !== 'string';
- }).length === 0;
- }
+ switch (type) {
+ case 'string':
+ symbol = 's';
+ break;
- return result;
- }
- /**
- * Returns true if the arg is an array of numbers
- * @param {*} arg - the item to test
- * @returns {boolean} True if arg is an array of numbers
- */
+ case 'number':
+ symbol = 'n';
+ break;
+ case 'boolean':
+ symbol = 'b';
+ break;
- function isArrayOfNumbers(arg) {
- var result = false;
+ case 'object':
+ if (value === null) {
+ symbol = 'l';
+ } else if (Array.isArray(value)) {
+ symbol = 'a';
+ } else {
+ symbol = 'o';
+ }
- if (Array.isArray(arg)) {
- result = arg.filter(function (item) {
- return !isNumeric(item);
- }).length === 0;
- }
+ break;
- return result;
- }
- /**
- * Create an empty sequence to contain query results
- * @returns {Array} - empty sequence
- */
+ case 'undefined':
+ default:
+ // any value can be undefined, but should be allowed to match
+ symbol = 'm';
+ // m for missing
+ }
+ }
+ return symbol;
+ };
- function createSequence() {
- var sequence = [];
- sequence.sequence = true;
+ var throwValidationError = function throwValidationError(badArgs, badSig) {
+ // to figure out where this went wrong we need apply each component of the
+ // regex to each argument until we get to the one that fails to match
+ var partialPattern = '^';
+ var goodTo = 0;
+
+ for (var index = 0; index < params.length; index++) {
+ partialPattern += params[index].regex;
+ var match = badSig.match(partialPattern);
+
+ if (match === null) {
+ // failed here
+ throw {
+ code: 'T0410',
+ stack: new Error().stack,
+ value: badArgs[goodTo],
+ index: goodTo + 1,
+ };
+ }
- if (arguments.length === 1) {
- sequence.push(arguments[0]);
- }
+ goodTo = match[0].length;
+ } // if it got this far, it's probably because of extraneous arguments (we
+ // haven't added the trailing '$' in the regex yet.
- return sequence;
- }
- /**
- * Tests if a value is a sequence
- * @param {*} value the value to test
- * @returns {boolean} true if it's a sequence
- */
+ throw {
+ code: 'T0410',
+ stack: new Error().stack,
+ value: badArgs[goodTo],
+ index: goodTo + 1,
+ };
+ };
+ return {
+ definition: signature,
+ validate: function validate(args, context) {
+ var suppliedSig = '';
+ args.forEach(function (arg) {
+ suppliedSig += getSymbol(arg);
+ });
+ var isValid = regex.exec(suppliedSig);
+
+ if (isValid) {
+ var validatedArgs = [];
+ var argIndex = 0;
+ params.forEach(function (param, index) {
+ var arg = args[argIndex];
+ var match = isValid[index + 1];
+
+ if (match === '') {
+ if (param.context && param.contextRegex) {
+ // substitute context value for missing arg
+ // first check that the context value is the right type
+ var contextType = getSymbol(context); // test contextType against the regex for this arg (without the trailing ?)
+
+ if (param.contextRegex.test(contextType)) {
+ validatedArgs.push(context);
+ } else {
+ // context value not compatible with this argument
+ throw {
+ code: 'T0411',
+ stack: new Error().stack,
+ value: context,
+ index: argIndex + 1,
+ };
+ }
+ } else {
+ validatedArgs.push(arg);
+ argIndex++;
+ }
+ } else {
+ // may have matched multiple args (if the regex ends with a '+'
+ // split into single tokens
+ match.split('').forEach(function (single) {
+ if (param.type === 'a') {
+ if (single === 'm') {
+ // missing (undefined)
+ arg = undefined;
+ } else {
+ arg = args[argIndex];
+ var arrayOK = true; // is there type information on the contents of the array?
+
+ if (typeof param.subtype !== 'undefined') {
+ if (single !== 'a' && match !== param.subtype) {
+ arrayOK = false;
+ } else if (single === 'a') {
+ if (arg.length > 0) {
+ var itemType = getSymbol(arg[0]);
+
+ if (itemType !== param.subtype.charAt(0)) {
+ // TODO recurse further
+ arrayOK = false;
+ } else {
+ // make sure every item in the array is this type
+ var differentItems = arg.filter(function (val) {
+ return getSymbol(val) !== itemType;
+ });
+ arrayOK = differentItems.length === 0;
+ }
+ }
+ }
+ }
- function isSequence(value) {
- return value.sequence === true && Array.isArray(value);
- }
- /**
- *
- * @param {Object} arg - expression to test
- * @returns {boolean} - true if it is a function (lambda or built-in)
- */
+ if (!arrayOK) {
+ throw {
+ code: 'T0412',
+ stack: new Error().stack,
+ value: arg,
+ index: argIndex + 1,
+ type: arraySignatureMapping[param.subtype],
+ };
+ } // the function expects an array. If it's not one, make it so
+
+ if (single !== 'a') {
+ arg = [arg];
+ }
+ }
+ validatedArgs.push(arg);
+ argIndex++;
+ } else {
+ validatedArgs.push(arg);
+ argIndex++;
+ }
+ });
+ }
+ });
+ return validatedArgs;
+ }
- function isFunction(arg) {
- return arg && (arg._jsonata_function === true || arg._jsonata_lambda === true) || typeof arg === 'function';
- }
- /**
- * Returns the arity (number of arguments) of the function
- * @param {*} func - the function
- * @returns {*} - the arity
- */
+ throwValidationError(args, suppliedSig);
+ },
+ };
+ }
+ return parseSignature;
+ })();
- function getFunctionArity(func) {
- var arity = typeof func.arity === 'number' ? func.arity : typeof func.implementation === 'function' ? func.implementation.length : typeof func.length === 'number' ? func.length : func.arguments.length;
- return arity;
- }
- /**
- * Tests whether arg is a lambda function
- * @param {*} arg - the value to test
- * @returns {boolean} - true if it is a lambda function
- */
+ module.exports = signature;
+ },
+ { './utils': 6 },
+ ],
+ 6: [
+ function (require, module, exports) {
+ 'use strict';
+ function _typeof(obj) {
+ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
+ _typeof = function _typeof(obj) {
+ return typeof obj;
+ };
+ } else {
+ _typeof = function _typeof(obj) {
+ return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
+ ? 'symbol'
+ : typeof obj;
+ };
+ }
+ return _typeof(obj);
+ }
- function isLambda(arg) {
- return arg && arg._jsonata_lambda === true;
- } // istanbul ignore next
+ /**
+ * © Copyright IBM Corp. 2016, 2018 All Rights Reserved
+ * Project name: JSONata
+ * This project is licensed under the MIT License, see LICENSE
+ */
+ var utils = (function () {
+ 'use strict';
+ /**
+ * Check if value is a finite number
+ * @param {float} n - number to evaluate
+ * @returns {boolean} True if n is a finite number
+ */
+
+ function isNumeric(n) {
+ var isNum = false;
+
+ if (typeof n === 'number') {
+ isNum = !isNaN(n);
+
+ if (isNum && !isFinite(n)) {
+ throw {
+ code: 'D1001',
+ value: n,
+ stack: new Error().stack,
+ };
+ }
+ }
+ return isNum;
+ }
+ /**
+ * Returns true if the arg is an array of strings
+ * @param {*} arg - the item to test
+ * @returns {boolean} True if arg is an array of strings
+ */
- var $Symbol = typeof Symbol === "function" ? Symbol : {}; // istanbul ignore next
+ function isArrayOfStrings(arg) {
+ var result = false;
+ /* istanbul ignore else */
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- /**
- * @param {Object} arg - expression to test
- * @returns {boolean} - true if it is iterable
- */
+ if (Array.isArray(arg)) {
+ result =
+ arg.filter(function (item) {
+ return typeof item !== 'string';
+ }).length === 0;
+ }
- function isIterable(arg) {
- return _typeof(arg) === 'object' && arg !== null && iteratorSymbol in arg && 'next' in arg && typeof arg.next === 'function';
- }
- /**
- * Compares two values for equality
- * @param {*} lhs first value
- * @param {*} rhs second value
- * @returns {boolean} true if they are deep equal
- */
+ return result;
+ }
+ /**
+ * Returns true if the arg is an array of numbers
+ * @param {*} arg - the item to test
+ * @returns {boolean} True if arg is an array of numbers
+ */
+ function isArrayOfNumbers(arg) {
+ var result = false;
- function isDeepEqual(lhs, rhs) {
- if (lhs === rhs) {
- return true;
- }
+ if (Array.isArray(arg)) {
+ result =
+ arg.filter(function (item) {
+ return !isNumeric(item);
+ }).length === 0;
+ }
- if (_typeof(lhs) === 'object' && _typeof(rhs) === 'object' && lhs !== null && rhs !== null) {
- if (Array.isArray(lhs) && Array.isArray(rhs)) {
- // both arrays (or sequences)
- // must be the same length
- if (lhs.length !== rhs.length) {
- return false;
- } // must contain same values in same order
+ return result;
+ }
+ /**
+ * Create an empty sequence to contain query results
+ * @returns {Array} - empty sequence
+ */
+ function createSequence() {
+ var sequence = [];
+ sequence.sequence = true;
- for (var ii = 0; ii < lhs.length; ii++) {
- if (!isDeepEqual(lhs[ii], rhs[ii])) {
- return false;
- }
- }
+ if (arguments.length === 1) {
+ sequence.push(arguments[0]);
+ }
- return true;
- } // both objects
- // must have the same set of keys (in any order)
+ return sequence;
+ }
+ /**
+ * Tests if a value is a sequence
+ * @param {*} value the value to test
+ * @returns {boolean} true if it's a sequence
+ */
+
+ function isSequence(value) {
+ return value.sequence === true && Array.isArray(value);
+ }
+ /**
+ *
+ * @param {Object} arg - expression to test
+ * @returns {boolean} - true if it is a function (lambda or built-in)
+ */
+
+ function isFunction(arg) {
+ return (
+ (arg && (arg._jsonata_function === true || arg._jsonata_lambda === true)) || typeof arg === 'function'
+ );
+ }
+ /**
+ * Returns the arity (number of arguments) of the function
+ * @param {*} func - the function
+ * @returns {*} - the arity
+ */
+
+ function getFunctionArity(func) {
+ var arity =
+ typeof func.arity === 'number'
+ ? func.arity
+ : typeof func.implementation === 'function'
+ ? func.implementation.length
+ : typeof func.length === 'number'
+ ? func.length
+ : func.arguments.length;
+ return arity;
+ }
+ /**
+ * Tests whether arg is a lambda function
+ * @param {*} arg - the value to test
+ * @returns {boolean} - true if it is a lambda function
+ */
+
+ function isLambda(arg) {
+ return arg && arg._jsonata_lambda === true;
+ } // istanbul ignore next
+
+ var $Symbol = typeof Symbol === 'function' ? Symbol : {}; // istanbul ignore next
+
+ var iteratorSymbol = $Symbol.iterator || '@@iterator';
+ /**
+ * @param {Object} arg - expression to test
+ * @returns {boolean} - true if it is iterable
+ */
+
+ function isIterable(arg) {
+ return (
+ _typeof(arg) === 'object' &&
+ arg !== null &&
+ iteratorSymbol in arg &&
+ 'next' in arg &&
+ typeof arg.next === 'function'
+ );
+ }
+ /**
+ * Compares two values for equality
+ * @param {*} lhs first value
+ * @param {*} rhs second value
+ * @returns {boolean} true if they are deep equal
+ */
+
+ function isDeepEqual(lhs, rhs) {
+ if (lhs === rhs) {
+ return true;
+ }
+ if (_typeof(lhs) === 'object' && _typeof(rhs) === 'object' && lhs !== null && rhs !== null) {
+ if (Array.isArray(lhs) && Array.isArray(rhs)) {
+ // both arrays (or sequences)
+ // must be the same length
+ if (lhs.length !== rhs.length) {
+ return false;
+ } // must contain same values in same order
+
+ for (var ii = 0; ii < lhs.length; ii++) {
+ if (!isDeepEqual(lhs[ii], rhs[ii])) {
+ return false;
+ }
+ }
- var lkeys = Object.getOwnPropertyNames(lhs);
- var rkeys = Object.getOwnPropertyNames(rhs);
+ return true;
+ } // both objects
+ // must have the same set of keys (in any order)
- if (lkeys.length !== rkeys.length) {
- return false;
- }
+ var lkeys = Object.getOwnPropertyNames(lhs);
+ var rkeys = Object.getOwnPropertyNames(rhs);
- lkeys = lkeys.sort();
- rkeys = rkeys.sort();
+ if (lkeys.length !== rkeys.length) {
+ return false;
+ }
- for (ii = 0; ii < lkeys.length; ii++) {
- if (lkeys[ii] !== rkeys[ii]) {
- return false;
- }
- } // must have the same values
+ lkeys = lkeys.sort();
+ rkeys = rkeys.sort();
+ for (ii = 0; ii < lkeys.length; ii++) {
+ if (lkeys[ii] !== rkeys[ii]) {
+ return false;
+ }
+ } // must have the same values
- for (ii = 0; ii < lkeys.length; ii++) {
- var key = lkeys[ii];
+ for (ii = 0; ii < lkeys.length; ii++) {
+ var key = lkeys[ii];
- if (!isDeepEqual(lhs[key], rhs[key])) {
- return false;
- }
- }
+ if (!isDeepEqual(lhs[key], rhs[key])) {
+ return false;
+ }
+ }
- return true;
- }
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- return {
- isNumeric: isNumeric,
- isArrayOfStrings: isArrayOfStrings,
- isArrayOfNumbers: isArrayOfNumbers,
- createSequence: createSequence,
- isSequence: isSequence,
- isFunction: isFunction,
- isLambda: isLambda,
- isIterable: isIterable,
- getFunctionArity: getFunctionArity,
- isDeepEqual: isDeepEqual
- };
-}();
+ return {
+ isNumeric: isNumeric,
+ isArrayOfStrings: isArrayOfStrings,
+ isArrayOfNumbers: isArrayOfNumbers,
+ createSequence: createSequence,
+ isSequence: isSequence,
+ isFunction: isFunction,
+ isLambda: isLambda,
+ isIterable: isIterable,
+ getFunctionArity: getFunctionArity,
+ isDeepEqual: isDeepEqual,
+ };
+ })();
-module.exports = utils;
-},{}]},{},[3])(3)
+ module.exports = utils;
+ },
+ {},
+ ],
+ },
+ {},
+ [3]
+ )(3);
});
diff --git a/shims/ramda.js b/shims/ramda.js
index 02918c6..51bc864 100644
--- a/shims/ramda.js
+++ b/shims/ramda.js
@@ -4,8644 +4,9016 @@
// Ramda may be freely distributed under the MIT license.
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (factory((global.R = {})));
-}(this, (function (exports) { 'use strict';
-
-/**
- * A function that always returns `false`. Any passed in parameters are ignored.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Function
- * @sig * -> Boolean
- * @param {*}
- * @return {Boolean}
- * @see R.T
- * @example
- *
- * R.F(); //=> false
- */
-var F = function() {return false;};
-
-/**
- * A function that always returns `true`. Any passed in parameters are ignored.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Function
- * @sig * -> Boolean
- * @param {*}
- * @return {Boolean}
- * @see R.F
- * @example
- *
- * R.T(); //=> true
- */
-var T = function() {return true;};
-
-/**
- * A special placeholder value used to specify "gaps" within curried functions,
- * allowing partial application of any combination of arguments, regardless of
- * their positions.
- *
- * If `g` is a curried ternary function and `_` is `R.__`, the following are
- * equivalent:
- *
- * - `g(1, 2, 3)`
- * - `g(_, 2, 3)(1)`
- * - `g(_, _, 3)(1)(2)`
- * - `g(_, _, 3)(1, 2)`
- * - `g(_, 2, _)(1, 3)`
- * - `g(_, 2)(1)(3)`
- * - `g(_, 2)(1, 3)`
- * - `g(_, 2)(_, 3)(1)`
- *
- * @name __
- * @constant
- * @memberOf R
- * @since v0.6.0
- * @category Function
- * @example
- *
- * const greet = R.replace('{name}', R.__, 'Hello, {name}!');
- * greet('Alice'); //=> 'Hello, Alice!'
- */
-var __ = {'@@functional/placeholder': true};
-
-function _isPlaceholder(a) {
- return a != null &&
- typeof a === 'object' &&
- a['@@functional/placeholder'] === true;
-}
+ typeof exports === 'object' && typeof module !== 'undefined'
+ ? factory(exports)
+ : typeof define === 'function' && define.amd
+ ? define(['exports'], factory)
+ : factory((global.R = {}));
+})(this, function (exports) {
+ 'use strict';
-/**
- * Optimized internal one-arity curry function.
- *
- * @private
- * @category Function
- * @param {Function} fn The function to curry.
- * @return {Function} The curried function.
- */
-function _curry1(fn) {
- return function f1(a) {
- if (arguments.length === 0 || _isPlaceholder(a)) {
- return f1;
- } else {
- return fn.apply(this, arguments);
- }
+ /**
+ * A function that always returns `false`. Any passed in parameters are ignored.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Function
+ * @sig * -> Boolean
+ * @param {*}
+ * @return {Boolean}
+ * @see R.T
+ * @example
+ *
+ * R.F(); //=> false
+ */
+ var F = function () {
+ return false;
};
-}
-/**
- * Optimized internal two-arity curry function.
- *
- * @private
- * @category Function
- * @param {Function} fn The function to curry.
- * @return {Function} The curried function.
- */
-function _curry2(fn) {
- return function f2(a, b) {
- switch (arguments.length) {
- case 0:
- return f2;
- case 1:
- return _isPlaceholder(a) ? f2
- : _curry1(function(_b) { return fn(a, _b); });
- default:
- return _isPlaceholder(a) && _isPlaceholder(b) ? f2
- : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); })
- : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); })
- : fn(a, b);
- }
+ /**
+ * A function that always returns `true`. Any passed in parameters are ignored.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Function
+ * @sig * -> Boolean
+ * @param {*}
+ * @return {Boolean}
+ * @see R.F
+ * @example
+ *
+ * R.T(); //=> true
+ */
+ var T = function () {
+ return true;
};
-}
-
-/**
- * Adds two values.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} a
- * @param {Number} b
- * @return {Number}
- * @see R.subtract
- * @example
- *
- * R.add(2, 3); //=> 5
- * R.add(7)(10); //=> 17
- */
-var add = _curry2(function add(a, b) {
- return Number(a) + Number(b);
-});
-
-/**
- * Private `concat` function to merge two array-like objects.
- *
- * @private
- * @param {Array|Arguments} [set1=[]] An array-like object.
- * @param {Array|Arguments} [set2=[]] An array-like object.
- * @return {Array} A new, merged array.
- * @example
- *
- * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
- */
-function _concat(set1, set2) {
- set1 = set1 || [];
- set2 = set2 || [];
- var idx;
- var len1 = set1.length;
- var len2 = set2.length;
- var result = [];
-
- idx = 0;
- while (idx < len1) {
- result[result.length] = set1[idx];
- idx += 1;
- }
- idx = 0;
- while (idx < len2) {
- result[result.length] = set2[idx];
- idx += 1;
- }
- return result;
-}
-
-function _arity(n, fn) {
- /* eslint-disable no-unused-vars */
- switch (n) {
- case 0: return function() { return fn.apply(this, arguments); };
- case 1: return function(a0) { return fn.apply(this, arguments); };
- case 2: return function(a0, a1) { return fn.apply(this, arguments); };
- case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); };
- case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); };
- case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); };
- case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); };
- case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); };
- case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); };
- case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); };
- case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); };
- default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
- }
-}
-/**
- * Internal curryN function.
- *
- * @private
- * @category Function
- * @param {Number} length The arity of the curried function.
- * @param {Array} received An array of arguments received thus far.
- * @param {Function} fn The function to curry.
- * @return {Function} The curried function.
- */
-function _curryN(length, received, fn) {
- return function() {
- var combined = [];
- var argsIdx = 0;
- var left = length;
- var combinedIdx = 0;
- while (combinedIdx < received.length || argsIdx < arguments.length) {
- var result;
- if (combinedIdx < received.length &&
- (!_isPlaceholder(received[combinedIdx]) ||
- argsIdx >= arguments.length)) {
- result = received[combinedIdx];
+ /**
+ * A special placeholder value used to specify "gaps" within curried functions,
+ * allowing partial application of any combination of arguments, regardless of
+ * their positions.
+ *
+ * If `g` is a curried ternary function and `_` is `R.__`, the following are
+ * equivalent:
+ *
+ * - `g(1, 2, 3)`
+ * - `g(_, 2, 3)(1)`
+ * - `g(_, _, 3)(1)(2)`
+ * - `g(_, _, 3)(1, 2)`
+ * - `g(_, 2, _)(1, 3)`
+ * - `g(_, 2)(1)(3)`
+ * - `g(_, 2)(1, 3)`
+ * - `g(_, 2)(_, 3)(1)`
+ *
+ * @name __
+ * @constant
+ * @memberOf R
+ * @since v0.6.0
+ * @category Function
+ * @example
+ *
+ * const greet = R.replace('{name}', R.__, 'Hello, {name}!');
+ * greet('Alice'); //=> 'Hello, Alice!'
+ */
+ var __ = { '@@functional/placeholder': true };
+
+ function _isPlaceholder(a) {
+ return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true;
+ }
+
+ /**
+ * Optimized internal one-arity curry function.
+ *
+ * @private
+ * @category Function
+ * @param {Function} fn The function to curry.
+ * @return {Function} The curried function.
+ */
+ function _curry1(fn) {
+ return function f1(a) {
+ if (arguments.length === 0 || _isPlaceholder(a)) {
+ return f1;
} else {
- result = arguments[argsIdx];
- argsIdx += 1;
- }
- combined[combinedIdx] = result;
- if (!_isPlaceholder(result)) {
- left -= 1;
+ return fn.apply(this, arguments);
}
- combinedIdx += 1;
- }
- return left <= 0 ? fn.apply(this, combined)
- : _arity(left, _curryN(length, combined, fn));
- };
-}
-
-/**
- * Returns a curried equivalent of the provided function, with the specified
- * arity. The curried function has two unusual capabilities. First, its
- * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the
- * following are equivalent:
- *
- * - `g(1)(2)(3)`
- * - `g(1)(2, 3)`
- * - `g(1, 2)(3)`
- * - `g(1, 2, 3)`
- *
- * Secondly, the special placeholder value [`R.__`](#__) may be used to specify
- * "gaps", allowing partial application of any combination of arguments,
- * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
- * the following are equivalent:
- *
- * - `g(1, 2, 3)`
- * - `g(_, 2, 3)(1)`
- * - `g(_, _, 3)(1)(2)`
- * - `g(_, _, 3)(1, 2)`
- * - `g(_, 2)(1)(3)`
- * - `g(_, 2)(1, 3)`
- * - `g(_, 2)(_, 3)(1)`
- *
- * @func
- * @memberOf R
- * @since v0.5.0
- * @category Function
- * @sig Number -> (* -> a) -> (* -> a)
- * @param {Number} length The arity for the returned function.
- * @param {Function} fn The function to curry.
- * @return {Function} A new, curried function.
- * @see R.curry
- * @example
- *
- * const sumArgs = (...args) => R.sum(args);
- *
- * const curriedAddFourNumbers = R.curryN(4, sumArgs);
- * const f = curriedAddFourNumbers(1, 2);
- * const g = f(3);
- * g(4); //=> 10
- */
-var curryN = _curry2(function curryN(length, fn) {
- if (length === 1) {
- return _curry1(fn);
+ };
}
- return _arity(length, _curryN(length, [], fn));
-});
-/**
- * Creates a new list iteration function from an existing one by adding two new
- * parameters to its callback function: the current index, and the entire list.
- *
- * This would turn, for instance, [`R.map`](#map) function into one that
- * more closely resembles `Array.prototype.map`. Note that this will only work
- * for functions in which the iteration callback function is the first
- * parameter, and where the list is the last parameter. (This latter might be
- * unimportant if the list parameter is not used.)
- *
- * @func
- * @memberOf R
- * @since v0.15.0
- * @category Function
- * @category List
- * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *)
- * @param {Function} fn A list iteration function that does not pass index or list to its callback
- * @return {Function} An altered list iteration function that passes (item, index, list) to its callback
- * @example
- *
- * const mapIndexed = R.addIndex(R.map);
- * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
- * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
- */
-var addIndex = _curry1(function addIndex(fn) {
- return curryN(fn.length, function() {
- var idx = 0;
- var origFn = arguments[0];
- var list = arguments[arguments.length - 1];
- var args = Array.prototype.slice.call(arguments, 0);
- args[0] = function() {
- var result = origFn.apply(this, _concat(arguments, [idx, list]));
- idx += 1;
- return result;
+ /**
+ * Optimized internal two-arity curry function.
+ *
+ * @private
+ * @category Function
+ * @param {Function} fn The function to curry.
+ * @return {Function} The curried function.
+ */
+ function _curry2(fn) {
+ return function f2(a, b) {
+ switch (arguments.length) {
+ case 0:
+ return f2;
+ case 1:
+ return _isPlaceholder(a)
+ ? f2
+ : _curry1(function (_b) {
+ return fn(a, _b);
+ });
+ default:
+ return _isPlaceholder(a) && _isPlaceholder(b)
+ ? f2
+ : _isPlaceholder(a)
+ ? _curry1(function (_a) {
+ return fn(_a, b);
+ })
+ : _isPlaceholder(b)
+ ? _curry1(function (_b) {
+ return fn(a, _b);
+ })
+ : fn(a, b);
+ }
};
- return fn.apply(this, args);
+ }
+
+ /**
+ * Adds two values.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} a
+ * @param {Number} b
+ * @return {Number}
+ * @see R.subtract
+ * @example
+ *
+ * R.add(2, 3); //=> 5
+ * R.add(7)(10); //=> 17
+ */
+ var add = _curry2(function add(a, b) {
+ return Number(a) + Number(b);
});
-});
-/**
- * Optimized internal three-arity curry function.
- *
- * @private
- * @category Function
- * @param {Function} fn The function to curry.
- * @return {Function} The curried function.
- */
-function _curry3(fn) {
- return function f3(a, b, c) {
- switch (arguments.length) {
+ /**
+ * Private `concat` function to merge two array-like objects.
+ *
+ * @private
+ * @param {Array|Arguments} [set1=[]] An array-like object.
+ * @param {Array|Arguments} [set2=[]] An array-like object.
+ * @return {Array} A new, merged array.
+ * @example
+ *
+ * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
+ */
+ function _concat(set1, set2) {
+ set1 = set1 || [];
+ set2 = set2 || [];
+ var idx;
+ var len1 = set1.length;
+ var len2 = set2.length;
+ var result = [];
+
+ idx = 0;
+ while (idx < len1) {
+ result[result.length] = set1[idx];
+ idx += 1;
+ }
+ idx = 0;
+ while (idx < len2) {
+ result[result.length] = set2[idx];
+ idx += 1;
+ }
+ return result;
+ }
+
+ function _arity(n, fn) {
+ /* eslint-disable no-unused-vars */
+ switch (n) {
case 0:
- return f3;
+ return function () {
+ return fn.apply(this, arguments);
+ };
case 1:
- return _isPlaceholder(a) ? f3
- : _curry2(function(_b, _c) { return fn(a, _b, _c); });
+ return function (a0) {
+ return fn.apply(this, arguments);
+ };
case 2:
- return _isPlaceholder(a) && _isPlaceholder(b) ? f3
- : _isPlaceholder(a) ? _curry2(function(_a, _c) { return fn(_a, b, _c); })
- : _isPlaceholder(b) ? _curry2(function(_b, _c) { return fn(a, _b, _c); })
- : _curry1(function(_c) { return fn(a, b, _c); });
+ return function (a0, a1) {
+ return fn.apply(this, arguments);
+ };
+ case 3:
+ return function (a0, a1, a2) {
+ return fn.apply(this, arguments);
+ };
+ case 4:
+ return function (a0, a1, a2, a3) {
+ return fn.apply(this, arguments);
+ };
+ case 5:
+ return function (a0, a1, a2, a3, a4) {
+ return fn.apply(this, arguments);
+ };
+ case 6:
+ return function (a0, a1, a2, a3, a4, a5) {
+ return fn.apply(this, arguments);
+ };
+ case 7:
+ return function (a0, a1, a2, a3, a4, a5, a6) {
+ return fn.apply(this, arguments);
+ };
+ case 8:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7) {
+ return fn.apply(this, arguments);
+ };
+ case 9:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
+ return fn.apply(this, arguments);
+ };
+ case 10:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
+ return fn.apply(this, arguments);
+ };
default:
- return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3
- : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) { return fn(_a, _b, c); })
- : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) { return fn(_a, b, _c); })
- : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) { return fn(a, _b, _c); })
- : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b, c); })
- : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b, c); })
- : _isPlaceholder(c) ? _curry1(function(_c) { return fn(a, b, _c); })
- : fn(a, b, c);
+ throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
}
- };
-}
+ }
-/**
- * Applies a function to the value at the given index of an array, returning a
- * new copy of the array with the element at the given index replaced with the
- * result of the function application.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category List
- * @sig Number -> (a -> a) -> [a] -> [a]
- * @param {Number} idx The index.
- * @param {Function} fn The function to apply.
- * @param {Array|Arguments} list An array-like object whose value
- * at the supplied index will be replaced.
- * @return {Array} A copy of the supplied array-like object with
- * the element at index `idx` replaced with the value
- * returned by applying `fn` to the existing element.
- * @see R.update
- * @example
- *
- * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd']
- * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D']
- * @symb R.adjust(-1, f, [a, b]) = [a, f(b)]
- * @symb R.adjust(0, f, [a, b]) = [f(a), b]
- */
-var adjust = _curry3(function adjust(idx, fn, list) {
- if (idx >= list.length || idx < -list.length) {
- return list;
+ /**
+ * Internal curryN function.
+ *
+ * @private
+ * @category Function
+ * @param {Number} length The arity of the curried function.
+ * @param {Array} received An array of arguments received thus far.
+ * @param {Function} fn The function to curry.
+ * @return {Function} The curried function.
+ */
+ function _curryN(length, received, fn) {
+ return function () {
+ var combined = [];
+ var argsIdx = 0;
+ var left = length;
+ var combinedIdx = 0;
+ while (combinedIdx < received.length || argsIdx < arguments.length) {
+ var result;
+ if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
+ result = received[combinedIdx];
+ } else {
+ result = arguments[argsIdx];
+ argsIdx += 1;
+ }
+ combined[combinedIdx] = result;
+ if (!_isPlaceholder(result)) {
+ left -= 1;
+ }
+ combinedIdx += 1;
+ }
+ return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn));
+ };
}
- var start = idx < 0 ? list.length : 0;
- var _idx = start + idx;
- var _list = _concat(list);
- _list[_idx] = fn(list[_idx]);
- return _list;
-});
-/**
- * Tests whether or not an object is an array.
- *
- * @private
- * @param {*} val The object to test.
- * @return {Boolean} `true` if `val` is an array, `false` otherwise.
- * @example
- *
- * _isArray([]); //=> true
- * _isArray(null); //=> false
- * _isArray({}); //=> false
- */
-var _isArray = Array.isArray || function _isArray(val) {
- return (val != null &&
- val.length >= 0 &&
- Object.prototype.toString.call(val) === '[object Array]');
-};
-
-function _isTransformer(obj) {
- return obj != null && typeof obj['@@transducer/step'] === 'function';
-}
-
-/**
- * Returns a function that dispatches with different strategies based on the
- * object in list position (last argument). If it is an array, executes [fn].
- * Otherwise, if it has a function with one of the given method names, it will
- * execute that function (functor case). Otherwise, if it is a transformer,
- * uses transducer [xf] to return a new transformer (transducer case).
- * Otherwise, it will default to executing [fn].
- *
- * @private
- * @param {Array} methodNames properties to check for a custom implementation
- * @param {Function} xf transducer to initialize if object is transformer
- * @param {Function} fn default ramda implementation
- * @return {Function} A function that dispatches on object in list position
- */
-function _dispatchable(methodNames, xf, fn) {
- return function() {
- if (arguments.length === 0) {
- return fn();
+ /**
+ * Returns a curried equivalent of the provided function, with the specified
+ * arity. The curried function has two unusual capabilities. First, its
+ * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the
+ * following are equivalent:
+ *
+ * - `g(1)(2)(3)`
+ * - `g(1)(2, 3)`
+ * - `g(1, 2)(3)`
+ * - `g(1, 2, 3)`
+ *
+ * Secondly, the special placeholder value [`R.__`](#__) may be used to specify
+ * "gaps", allowing partial application of any combination of arguments,
+ * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
+ * the following are equivalent:
+ *
+ * - `g(1, 2, 3)`
+ * - `g(_, 2, 3)(1)`
+ * - `g(_, _, 3)(1)(2)`
+ * - `g(_, _, 3)(1, 2)`
+ * - `g(_, 2)(1)(3)`
+ * - `g(_, 2)(1, 3)`
+ * - `g(_, 2)(_, 3)(1)`
+ *
+ * @func
+ * @memberOf R
+ * @since v0.5.0
+ * @category Function
+ * @sig Number -> (* -> a) -> (* -> a)
+ * @param {Number} length The arity for the returned function.
+ * @param {Function} fn The function to curry.
+ * @return {Function} A new, curried function.
+ * @see R.curry
+ * @example
+ *
+ * const sumArgs = (...args) => R.sum(args);
+ *
+ * const curriedAddFourNumbers = R.curryN(4, sumArgs);
+ * const f = curriedAddFourNumbers(1, 2);
+ * const g = f(3);
+ * g(4); //=> 10
+ */
+ var curryN = _curry2(function curryN(length, fn) {
+ if (length === 1) {
+ return _curry1(fn);
}
- var args = Array.prototype.slice.call(arguments, 0);
- var obj = args.pop();
- if (!_isArray(obj)) {
+ return _arity(length, _curryN(length, [], fn));
+ });
+
+ /**
+ * Creates a new list iteration function from an existing one by adding two new
+ * parameters to its callback function: the current index, and the entire list.
+ *
+ * This would turn, for instance, [`R.map`](#map) function into one that
+ * more closely resembles `Array.prototype.map`. Note that this will only work
+ * for functions in which the iteration callback function is the first
+ * parameter, and where the list is the last parameter. (This latter might be
+ * unimportant if the list parameter is not used.)
+ *
+ * @func
+ * @memberOf R
+ * @since v0.15.0
+ * @category Function
+ * @category List
+ * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *)
+ * @param {Function} fn A list iteration function that does not pass index or list to its callback
+ * @return {Function} An altered list iteration function that passes (item, index, list) to its callback
+ * @example
+ *
+ * const mapIndexed = R.addIndex(R.map);
+ * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
+ * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
+ */
+ var addIndex = _curry1(function addIndex(fn) {
+ return curryN(fn.length, function () {
var idx = 0;
- while (idx < methodNames.length) {
- if (typeof obj[methodNames[idx]] === 'function') {
- return obj[methodNames[idx]].apply(obj, args);
- }
+ var origFn = arguments[0];
+ var list = arguments[arguments.length - 1];
+ var args = Array.prototype.slice.call(arguments, 0);
+ args[0] = function () {
+ var result = origFn.apply(this, _concat(arguments, [idx, list]));
idx += 1;
+ return result;
+ };
+ return fn.apply(this, args);
+ });
+ });
+
+ /**
+ * Optimized internal three-arity curry function.
+ *
+ * @private
+ * @category Function
+ * @param {Function} fn The function to curry.
+ * @return {Function} The curried function.
+ */
+ function _curry3(fn) {
+ return function f3(a, b, c) {
+ switch (arguments.length) {
+ case 0:
+ return f3;
+ case 1:
+ return _isPlaceholder(a)
+ ? f3
+ : _curry2(function (_b, _c) {
+ return fn(a, _b, _c);
+ });
+ case 2:
+ return _isPlaceholder(a) && _isPlaceholder(b)
+ ? f3
+ : _isPlaceholder(a)
+ ? _curry2(function (_a, _c) {
+ return fn(_a, b, _c);
+ })
+ : _isPlaceholder(b)
+ ? _curry2(function (_b, _c) {
+ return fn(a, _b, _c);
+ })
+ : _curry1(function (_c) {
+ return fn(a, b, _c);
+ });
+ default:
+ return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c)
+ ? f3
+ : _isPlaceholder(a) && _isPlaceholder(b)
+ ? _curry2(function (_a, _b) {
+ return fn(_a, _b, c);
+ })
+ : _isPlaceholder(a) && _isPlaceholder(c)
+ ? _curry2(function (_a, _c) {
+ return fn(_a, b, _c);
+ })
+ : _isPlaceholder(b) && _isPlaceholder(c)
+ ? _curry2(function (_b, _c) {
+ return fn(a, _b, _c);
+ })
+ : _isPlaceholder(a)
+ ? _curry1(function (_a) {
+ return fn(_a, b, c);
+ })
+ : _isPlaceholder(b)
+ ? _curry1(function (_b) {
+ return fn(a, _b, c);
+ })
+ : _isPlaceholder(c)
+ ? _curry1(function (_c) {
+ return fn(a, b, _c);
+ })
+ : fn(a, b, c);
}
- if (_isTransformer(obj)) {
- var transducer = xf.apply(null, args);
- return transducer(obj);
- }
+ };
+ }
+
+ /**
+ * Applies a function to the value at the given index of an array, returning a
+ * new copy of the array with the element at the given index replaced with the
+ * result of the function application.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category List
+ * @sig Number -> (a -> a) -> [a] -> [a]
+ * @param {Number} idx The index.
+ * @param {Function} fn The function to apply.
+ * @param {Array|Arguments} list An array-like object whose value
+ * at the supplied index will be replaced.
+ * @return {Array} A copy of the supplied array-like object with
+ * the element at index `idx` replaced with the value
+ * returned by applying `fn` to the existing element.
+ * @see R.update
+ * @example
+ *
+ * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd']
+ * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D']
+ * @symb R.adjust(-1, f, [a, b]) = [a, f(b)]
+ * @symb R.adjust(0, f, [a, b]) = [f(a), b]
+ */
+ var adjust = _curry3(function adjust(idx, fn, list) {
+ if (idx >= list.length || idx < -list.length) {
+ return list;
}
- return fn.apply(this, arguments);
- };
-}
+ var start = idx < 0 ? list.length : 0;
+ var _idx = start + idx;
+ var _list = _concat(list);
+ _list[_idx] = fn(list[_idx]);
+ return _list;
+ });
-function _reduced(x) {
- return x && x['@@transducer/reduced'] ? x :
- {
- '@@transducer/value': x,
- '@@transducer/reduced': true
+ /**
+ * Tests whether or not an object is an array.
+ *
+ * @private
+ * @param {*} val The object to test.
+ * @return {Boolean} `true` if `val` is an array, `false` otherwise.
+ * @example
+ *
+ * _isArray([]); //=> true
+ * _isArray(null); //=> false
+ * _isArray({}); //=> false
+ */
+ var _isArray =
+ Array.isArray ||
+ function _isArray(val) {
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
};
-}
-var _xfBase = {
- init: function() {
- return this.xf['@@transducer/init']();
- },
- result: function(result) {
- return this.xf['@@transducer/result'](result);
- }
-};
-
-function XAll(f, xf) {
- this.xf = xf;
- this.f = f;
- this.all = true;
-}
-XAll.prototype['@@transducer/init'] = _xfBase.init;
-XAll.prototype['@@transducer/result'] = function(result) {
- if (this.all) {
- result = this.xf['@@transducer/step'](result, true);
+ function _isTransformer(obj) {
+ return obj != null && typeof obj['@@transducer/step'] === 'function';
+ }
+
+ /**
+ * Returns a function that dispatches with different strategies based on the
+ * object in list position (last argument). If it is an array, executes [fn].
+ * Otherwise, if it has a function with one of the given method names, it will
+ * execute that function (functor case). Otherwise, if it is a transformer,
+ * uses transducer [xf] to return a new transformer (transducer case).
+ * Otherwise, it will default to executing [fn].
+ *
+ * @private
+ * @param {Array} methodNames properties to check for a custom implementation
+ * @param {Function} xf transducer to initialize if object is transformer
+ * @param {Function} fn default ramda implementation
+ * @return {Function} A function that dispatches on object in list position
+ */
+ function _dispatchable(methodNames, xf, fn) {
+ return function () {
+ if (arguments.length === 0) {
+ return fn();
+ }
+ var args = Array.prototype.slice.call(arguments, 0);
+ var obj = args.pop();
+ if (!_isArray(obj)) {
+ var idx = 0;
+ while (idx < methodNames.length) {
+ if (typeof obj[methodNames[idx]] === 'function') {
+ return obj[methodNames[idx]].apply(obj, args);
+ }
+ idx += 1;
+ }
+ if (_isTransformer(obj)) {
+ var transducer = xf.apply(null, args);
+ return transducer(obj);
+ }
+ }
+ return fn.apply(this, arguments);
+ };
}
- return this.xf['@@transducer/result'](result);
-};
-XAll.prototype['@@transducer/step'] = function(result, input) {
- if (!this.f(input)) {
- this.all = false;
- result = _reduced(this.xf['@@transducer/step'](result, false));
+
+ function _reduced(x) {
+ return x && x['@@transducer/reduced']
+ ? x
+ : {
+ '@@transducer/value': x,
+ '@@transducer/reduced': true,
+ };
}
- return result;
-};
-var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); });
+ var _xfBase = {
+ init: function () {
+ return this.xf['@@transducer/init']();
+ },
+ result: function (result) {
+ return this.xf['@@transducer/result'](result);
+ },
+ };
-/**
- * Returns `true` if all elements of the list match the predicate, `false` if
- * there are any that don't.
- *
- * Dispatches to the `all` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> Boolean
- * @param {Function} fn The predicate function.
- * @param {Array} list The array to consider.
- * @return {Boolean} `true` if the predicate is satisfied by every element, `false`
- * otherwise.
- * @see R.any, R.none, R.transduce
- * @example
- *
- * const equals3 = R.equals(3);
- * R.all(equals3)([3, 3, 3, 3]); //=> true
- * R.all(equals3)([3, 3, 1, 3]); //=> false
- */
-var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) {
- var idx = 0;
- while (idx < list.length) {
- if (!fn(list[idx])) {
- return false;
- }
- idx += 1;
+ function XAll(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ this.all = true;
}
- return true;
-}));
+ XAll.prototype['@@transducer/init'] = _xfBase.init;
+ XAll.prototype['@@transducer/result'] = function (result) {
+ if (this.all) {
+ result = this.xf['@@transducer/step'](result, true);
+ }
+ return this.xf['@@transducer/result'](result);
+ };
+ XAll.prototype['@@transducer/step'] = function (result, input) {
+ if (!this.f(input)) {
+ this.all = false;
+ result = _reduced(this.xf['@@transducer/step'](result, false));
+ }
+ return result;
+ };
-/**
- * Returns the larger of its two arguments.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> a
- * @param {*} a
- * @param {*} b
- * @return {*}
- * @see R.maxBy, R.min
- * @example
- *
- * R.max(789, 123); //=> 789
- * R.max('a', 'b'); //=> 'b'
- */
-var max = _curry2(function max(a, b) { return b > a ? b : a; });
-
-function _map(fn, functor) {
- var idx = 0;
- var len = functor.length;
- var result = Array(len);
- while (idx < len) {
- result[idx] = fn(functor[idx]);
- idx += 1;
+ var _xall = _curry2(function _xall(f, xf) {
+ return new XAll(f, xf);
+ });
+
+ /**
+ * Returns `true` if all elements of the list match the predicate, `false` if
+ * there are any that don't.
+ *
+ * Dispatches to the `all` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> Boolean
+ * @param {Function} fn The predicate function.
+ * @param {Array} list The array to consider.
+ * @return {Boolean} `true` if the predicate is satisfied by every element, `false`
+ * otherwise.
+ * @see R.any, R.none, R.transduce
+ * @example
+ *
+ * const equals3 = R.equals(3);
+ * R.all(equals3)([3, 3, 3, 3]); //=> true
+ * R.all(equals3)([3, 3, 1, 3]); //=> false
+ */
+ var all = _curry2(
+ _dispatchable(['all'], _xall, function all(fn, list) {
+ var idx = 0;
+ while (idx < list.length) {
+ if (!fn(list[idx])) {
+ return false;
+ }
+ idx += 1;
+ }
+ return true;
+ })
+ );
+
+ /**
+ * Returns the larger of its two arguments.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> a
+ * @param {*} a
+ * @param {*} b
+ * @return {*}
+ * @see R.maxBy, R.min
+ * @example
+ *
+ * R.max(789, 123); //=> 789
+ * R.max('a', 'b'); //=> 'b'
+ */
+ var max = _curry2(function max(a, b) {
+ return b > a ? b : a;
+ });
+
+ function _map(fn, functor) {
+ var idx = 0;
+ var len = functor.length;
+ var result = Array(len);
+ while (idx < len) {
+ result[idx] = fn(functor[idx]);
+ idx += 1;
+ }
+ return result;
}
- return result;
-}
-function _isString(x) {
- return Object.prototype.toString.call(x) === '[object String]';
-}
+ function _isString(x) {
+ return Object.prototype.toString.call(x) === '[object String]';
+ }
+
+ /**
+ * Tests whether or not an object is similar to an array.
+ *
+ * @private
+ * @category Type
+ * @category List
+ * @sig * -> Boolean
+ * @param {*} x The object to test.
+ * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
+ * @example
+ *
+ * _isArrayLike([]); //=> true
+ * _isArrayLike(true); //=> false
+ * _isArrayLike({}); //=> false
+ * _isArrayLike({length: 10}); //=> false
+ * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
+ */
+ var _isArrayLike = _curry1(function isArrayLike(x) {
+ if (_isArray(x)) {
+ return true;
+ }
+ if (!x) {
+ return false;
+ }
+ if (typeof x !== 'object') {
+ return false;
+ }
+ if (_isString(x)) {
+ return false;
+ }
+ if (x.nodeType === 1) {
+ return !!x.length;
+ }
+ if (x.length === 0) {
+ return true;
+ }
+ if (x.length > 0) {
+ return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
+ }
+ return false;
+ });
-/**
- * Tests whether or not an object is similar to an array.
- *
- * @private
- * @category Type
- * @category List
- * @sig * -> Boolean
- * @param {*} x The object to test.
- * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
- * @example
- *
- * _isArrayLike([]); //=> true
- * _isArrayLike(true); //=> false
- * _isArrayLike({}); //=> false
- * _isArrayLike({length: 10}); //=> false
- * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
- */
-var _isArrayLike = _curry1(function isArrayLike(x) {
- if (_isArray(x)) { return true; }
- if (!x) { return false; }
- if (typeof x !== 'object') { return false; }
- if (_isString(x)) { return false; }
- if (x.nodeType === 1) { return !!x.length; }
- if (x.length === 0) { return true; }
- if (x.length > 0) {
- return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
+ function XWrap(fn) {
+ this.f = fn;
}
- return false;
-});
+ XWrap.prototype['@@transducer/init'] = function () {
+ throw new Error('init not implemented on XWrap');
+ };
+ XWrap.prototype['@@transducer/result'] = function (acc) {
+ return acc;
+ };
+ XWrap.prototype['@@transducer/step'] = function (acc, x) {
+ return this.f(acc, x);
+ };
-function XWrap(fn) {
- this.f = fn;
-}
-XWrap.prototype['@@transducer/init'] = function() {
- throw new Error('init not implemented on XWrap');
-};
-XWrap.prototype['@@transducer/result'] = function(acc) { return acc; };
-XWrap.prototype['@@transducer/step'] = function(acc, x) {
- return this.f(acc, x);
-};
-
-function _xwrap(fn) { return new XWrap(fn); }
-
-/**
- * Creates a function that is bound to a context.
- * Note: `R.bind` does not provide the additional argument-binding capabilities of
- * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
- *
- * @func
- * @memberOf R
- * @since v0.6.0
- * @category Function
- * @category Object
- * @sig (* -> *) -> {*} -> (* -> *)
- * @param {Function} fn The function to bind to context
- * @param {Object} thisObj The context to bind `fn` to
- * @return {Function} A function that will execute in the context of `thisObj`.
- * @see R.partial
- * @example
- *
- * const log = R.bind(console.log, console);
- * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
- * // logs {a: 2}
- * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
- */
-var bind = _curry2(function bind(fn, thisObj) {
- return _arity(fn.length, function() {
- return fn.apply(thisObj, arguments);
+ function _xwrap(fn) {
+ return new XWrap(fn);
+ }
+
+ /**
+ * Creates a function that is bound to a context.
+ * Note: `R.bind` does not provide the additional argument-binding capabilities of
+ * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.6.0
+ * @category Function
+ * @category Object
+ * @sig (* -> *) -> {*} -> (* -> *)
+ * @param {Function} fn The function to bind to context
+ * @param {Object} thisObj The context to bind `fn` to
+ * @return {Function} A function that will execute in the context of `thisObj`.
+ * @see R.partial
+ * @example
+ *
+ * const log = R.bind(console.log, console);
+ * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
+ * // logs {a: 2}
+ * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
+ */
+ var bind = _curry2(function bind(fn, thisObj) {
+ return _arity(fn.length, function () {
+ return fn.apply(thisObj, arguments);
+ });
});
-});
-function _arrayReduce(xf, acc, list) {
- var idx = 0;
- var len = list.length;
- while (idx < len) {
- acc = xf['@@transducer/step'](acc, list[idx]);
- if (acc && acc['@@transducer/reduced']) {
- acc = acc['@@transducer/value'];
- break;
+ function _arrayReduce(xf, acc, list) {
+ var idx = 0;
+ var len = list.length;
+ while (idx < len) {
+ acc = xf['@@transducer/step'](acc, list[idx]);
+ if (acc && acc['@@transducer/reduced']) {
+ acc = acc['@@transducer/value'];
+ break;
+ }
+ idx += 1;
}
- idx += 1;
+ return xf['@@transducer/result'](acc);
}
- return xf['@@transducer/result'](acc);
-}
-
-function _iterableReduce(xf, acc, iter) {
- var step = iter.next();
- while (!step.done) {
- acc = xf['@@transducer/step'](acc, step.value);
- if (acc && acc['@@transducer/reduced']) {
- acc = acc['@@transducer/value'];
- break;
- }
- step = iter.next();
+
+ function _iterableReduce(xf, acc, iter) {
+ var step = iter.next();
+ while (!step.done) {
+ acc = xf['@@transducer/step'](acc, step.value);
+ if (acc && acc['@@transducer/reduced']) {
+ acc = acc['@@transducer/value'];
+ break;
+ }
+ step = iter.next();
+ }
+ return xf['@@transducer/result'](acc);
}
- return xf['@@transducer/result'](acc);
-}
-function _methodReduce(xf, acc, obj, methodName) {
- return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
-}
+ function _methodReduce(xf, acc, obj, methodName) {
+ return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
+ }
-var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator';
+ var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
-function _reduce(fn, acc, list) {
- if (typeof fn === 'function') {
- fn = _xwrap(fn);
- }
- if (_isArrayLike(list)) {
- return _arrayReduce(fn, acc, list);
- }
- if (typeof list['fantasy-land/reduce'] === 'function') {
- return _methodReduce(fn, acc, list, 'fantasy-land/reduce');
- }
- if (list[symIterator] != null) {
- return _iterableReduce(fn, acc, list[symIterator]());
- }
- if (typeof list.next === 'function') {
- return _iterableReduce(fn, acc, list);
+ function _reduce(fn, acc, list) {
+ if (typeof fn === 'function') {
+ fn = _xwrap(fn);
+ }
+ if (_isArrayLike(list)) {
+ return _arrayReduce(fn, acc, list);
+ }
+ if (typeof list['fantasy-land/reduce'] === 'function') {
+ return _methodReduce(fn, acc, list, 'fantasy-land/reduce');
+ }
+ if (list[symIterator] != null) {
+ return _iterableReduce(fn, acc, list[symIterator]());
+ }
+ if (typeof list.next === 'function') {
+ return _iterableReduce(fn, acc, list);
+ }
+ if (typeof list.reduce === 'function') {
+ return _methodReduce(fn, acc, list, 'reduce');
+ }
+
+ throw new TypeError('reduce: list must be array or iterable');
}
- if (typeof list.reduce === 'function') {
- return _methodReduce(fn, acc, list, 'reduce');
+
+ function XMap(f, xf) {
+ this.xf = xf;
+ this.f = f;
}
+ XMap.prototype['@@transducer/init'] = _xfBase.init;
+ XMap.prototype['@@transducer/result'] = _xfBase.result;
+ XMap.prototype['@@transducer/step'] = function (result, input) {
+ return this.xf['@@transducer/step'](result, this.f(input));
+ };
- throw new TypeError('reduce: list must be array or iterable');
-}
-
-function XMap(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XMap.prototype['@@transducer/init'] = _xfBase.init;
-XMap.prototype['@@transducer/result'] = _xfBase.result;
-XMap.prototype['@@transducer/step'] = function(result, input) {
- return this.xf['@@transducer/step'](result, this.f(input));
-};
-
-var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); });
-
-function _has(prop, obj) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-
-var toString = Object.prototype.toString;
-var _isArguments = (function() {
- return toString.call(arguments) === '[object Arguments]' ?
- function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } :
- function _isArguments(x) { return _has('callee', x); };
-}());
-
-// cover IE < 9 keys issues
-var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString');
-var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
- 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
-// Safari bug
-var hasArgsEnumBug = (function() {
- 'use strict';
- return arguments.propertyIsEnumerable('length');
-}());
+ var _xmap = _curry2(function _xmap(f, xf) {
+ return new XMap(f, xf);
+ });
-var contains = function contains(list, item) {
- var idx = 0;
- while (idx < list.length) {
- if (list[idx] === item) {
- return true;
- }
- idx += 1;
+ function _has(prop, obj) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
}
- return false;
-};
-
-/**
- * Returns a list containing the names of all the enumerable own properties of
- * the supplied object.
- * Note that the order of the output array is not guaranteed to be consistent
- * across different JS platforms.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig {k: v} -> [k]
- * @param {Object} obj The object to extract properties from
- * @return {Array} An array of the object's own properties.
- * @see R.keysIn, R.values
- * @example
- *
- * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
- */
-var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?
- _curry1(function keys(obj) {
- return Object(obj) !== obj ? [] : Object.keys(obj);
- }) :
- _curry1(function keys(obj) {
- if (Object(obj) !== obj) {
- return [];
- }
- var prop, nIdx;
- var ks = [];
- var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
- for (prop in obj) {
- if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
- ks[ks.length] = prop;
+
+ var toString = Object.prototype.toString;
+ var _isArguments = (function () {
+ return toString.call(arguments) === '[object Arguments]'
+ ? function _isArguments(x) {
+ return toString.call(x) === '[object Arguments]';
+ }
+ : function _isArguments(x) {
+ return _has('callee', x);
+ };
+ })();
+
+ // cover IE < 9 keys issues
+ var hasEnumBug = !{ toString: null }.propertyIsEnumerable('toString');
+ var nonEnumerableProps = [
+ 'constructor',
+ 'valueOf',
+ 'isPrototypeOf',
+ 'toString',
+ 'propertyIsEnumerable',
+ 'hasOwnProperty',
+ 'toLocaleString',
+ ];
+ // Safari bug
+ var hasArgsEnumBug = (function () {
+ 'use strict';
+ return arguments.propertyIsEnumerable('length');
+ })();
+
+ var contains = function contains(list, item) {
+ var idx = 0;
+ while (idx < list.length) {
+ if (list[idx] === item) {
+ return true;
}
+ idx += 1;
}
- if (hasEnumBug) {
- nIdx = nonEnumerableProps.length - 1;
- while (nIdx >= 0) {
- prop = nonEnumerableProps[nIdx];
- if (_has(prop, obj) && !contains(ks, prop)) {
- ks[ks.length] = prop;
- }
- nIdx -= 1;
+ return false;
+ };
+
+ /**
+ * Returns a list containing the names of all the enumerable own properties of
+ * the supplied object.
+ * Note that the order of the output array is not guaranteed to be consistent
+ * across different JS platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig {k: v} -> [k]
+ * @param {Object} obj The object to extract properties from
+ * @return {Array} An array of the object's own properties.
+ * @see R.keysIn, R.values
+ * @example
+ *
+ * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
+ */
+ var keys =
+ typeof Object.keys === 'function' && !hasArgsEnumBug
+ ? _curry1(function keys(obj) {
+ return Object(obj) !== obj ? [] : Object.keys(obj);
+ })
+ : _curry1(function keys(obj) {
+ if (Object(obj) !== obj) {
+ return [];
+ }
+ var prop, nIdx;
+ var ks = [];
+ var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
+ for (prop in obj) {
+ if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
+ ks[ks.length] = prop;
+ }
+ }
+ if (hasEnumBug) {
+ nIdx = nonEnumerableProps.length - 1;
+ while (nIdx >= 0) {
+ prop = nonEnumerableProps[nIdx];
+ if (_has(prop, obj) && !contains(ks, prop)) {
+ ks[ks.length] = prop;
+ }
+ nIdx -= 1;
+ }
+ }
+ return ks;
+ });
+
+ /**
+ * Takes a function and
+ * a [functor](https://github.com/fantasyland/fantasy-land#functor),
+ * applies the function to each of the functor's values, and returns
+ * a functor of the same shape.
+ *
+ * Ramda provides suitable `map` implementations for `Array` and `Object`,
+ * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
+ *
+ * Dispatches to the `map` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * Also treats functions as functors and will compose them together.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Functor f => (a -> b) -> f a -> f b
+ * @param {Function} fn The function to be called on every element of the input `list`.
+ * @param {Array} list The list to be iterated over.
+ * @return {Array} The new list.
+ * @see R.transduce, R.addIndex
+ * @example
+ *
+ * const double = x => x * 2;
+ *
+ * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
+ *
+ * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
+ * @symb R.map(f, [a, b]) = [f(a), f(b)]
+ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
+ * @symb R.map(f, functor_o) = functor_o.map(f)
+ */
+ var map = _curry2(
+ _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
+ switch (Object.prototype.toString.call(functor)) {
+ case '[object Function]':
+ return curryN(functor.length, function () {
+ return fn.call(this, functor.apply(this, arguments));
+ });
+ case '[object Object]':
+ return _reduce(
+ function (acc, key) {
+ acc[key] = fn(functor[key]);
+ return acc;
+ },
+ {},
+ keys(functor)
+ );
+ default:
+ return _map(fn, functor);
+ }
+ })
+ );
+
+ /**
+ * Retrieve the value at a given path.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @sig [Idx] -> {a} -> a | Undefined
+ * @param {Array} path The path to use.
+ * @param {Object} obj The object to retrieve the nested property from.
+ * @return {*} The data at `path`.
+ * @see R.prop
+ * @example
+ *
+ * R.path(['a', 'b'], {a: {b: 2}}); //=> 2
+ * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
+ */
+ var path = _curry2(function path(paths, obj) {
+ var val = obj;
+ var idx = 0;
+ while (idx < paths.length) {
+ if (val == null) {
+ return;
}
+ val = val[paths[idx]];
+ idx += 1;
}
- return ks;
+ return val;
});
-/**
- * Takes a function and
- * a [functor](https://github.com/fantasyland/fantasy-land#functor),
- * applies the function to each of the functor's values, and returns
- * a functor of the same shape.
- *
- * Ramda provides suitable `map` implementations for `Array` and `Object`,
- * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
- *
- * Dispatches to the `map` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * Also treats functions as functors and will compose them together.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Functor f => (a -> b) -> f a -> f b
- * @param {Function} fn The function to be called on every element of the input `list`.
- * @param {Array} list The list to be iterated over.
- * @return {Array} The new list.
- * @see R.transduce, R.addIndex
- * @example
- *
- * const double = x => x * 2;
- *
- * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
- *
- * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
- * @symb R.map(f, [a, b]) = [f(a), f(b)]
- * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
- * @symb R.map(f, functor_o) = functor_o.map(f)
- */
-var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
- switch (Object.prototype.toString.call(functor)) {
- case '[object Function]':
- return curryN(functor.length, function() {
- return fn.call(this, functor.apply(this, arguments));
- });
- case '[object Object]':
- return _reduce(function(acc, key) {
- acc[key] = fn(functor[key]);
- return acc;
- }, {}, keys(functor));
- default:
- return _map(fn, functor);
- }
-}));
+ /**
+ * Returns a function that when supplied an object returns the indicated
+ * property of that object, if it exists.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig s -> {s: a} -> a | Undefined
+ * @param {String} p The property name
+ * @param {Object} obj The object to query
+ * @return {*} The value at `obj.p`.
+ * @see R.path
+ * @example
+ *
+ * R.prop('x', {x: 100}); //=> 100
+ * R.prop('x', {}); //=> undefined
+ * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4
+ */
+
+ var prop = _curry2(function prop(p, obj) {
+ return path([p], obj);
+ });
-/**
- * Retrieve the value at a given path.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category Object
- * @typedefn Idx = String | Int
- * @sig [Idx] -> {a} -> a | Undefined
- * @param {Array} path The path to use.
- * @param {Object} obj The object to retrieve the nested property from.
- * @return {*} The data at `path`.
- * @see R.prop
- * @example
- *
- * R.path(['a', 'b'], {a: {b: 2}}); //=> 2
- * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
- */
-var path = _curry2(function path(paths, obj) {
- var val = obj;
- var idx = 0;
- while (idx < paths.length) {
- if (val == null) {
- return;
- }
- val = val[paths[idx]];
- idx += 1;
+ /**
+ * Returns a new list by plucking the same named property off all objects in
+ * the list supplied.
+ *
+ * `pluck` will work on
+ * any [functor](https://github.com/fantasyland/fantasy-land#functor) in
+ * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Functor f => k -> f {k: v} -> f v
+ * @param {Number|String} key The key name to pluck off of each object.
+ * @param {Array} f The array or functor to consider.
+ * @return {Array} The list of values for the given key.
+ * @see R.props
+ * @example
+ *
+ * var getAges = R.pluck('age');
+ * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27]
+ *
+ * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
+ * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
+ * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5]
+ * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5]
+ */
+ var pluck = _curry2(function pluck(p, list) {
+ return map(prop(p), list);
+ });
+
+ /**
+ * Returns a single item by iterating through the list, successively calling
+ * the iterator function and passing it an accumulator value and the current
+ * value from the array, and then passing the result to the next call.
+ *
+ * The iterator function receives two values: *(acc, value)*. It may use
+ * [`R.reduced`](#reduced) to shortcut the iteration.
+ *
+ * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
+ * is *(value, acc)*.
+ *
+ * Note: `R.reduce` does not skip deleted or unassigned indices (sparse
+ * arrays), unlike the native `Array.prototype.reduce` method. For more details
+ * on this behavior, see:
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
+ *
+ * Dispatches to the `reduce` method of the third argument, if present. When
+ * doing so, it is up to the user to handle the [`R.reduced`](#reduced)
+ * shortcuting, as this is not implemented by `reduce`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig ((a, b) -> a) -> a -> [b] -> a
+ * @param {Function} fn The iterator function. Receives two values, the accumulator and the
+ * current element from the array.
+ * @param {*} acc The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.reduced, R.addIndex, R.reduceRight
+ * @example
+ *
+ * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
+ * // - -10
+ * // / \ / \
+ * // - 4 -6 4
+ * // / \ / \
+ * // - 3 ==> -3 3
+ * // / \ / \
+ * // - 2 -1 2
+ * // / \ / \
+ * // 0 1 0 1
+ *
+ * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
+ */
+ var reduce = _curry3(_reduce);
+
+ /**
+ * Takes a list of predicates and returns a predicate that returns true for a
+ * given list of arguments if every one of the provided predicates is satisfied
+ * by those arguments.
+ *
+ * The function returned is a curried function whose arity matches that of the
+ * highest-arity predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Logic
+ * @sig [(*... -> Boolean)] -> (*... -> Boolean)
+ * @param {Array} predicates An array of predicates to check
+ * @return {Function} The combined predicate
+ * @see R.anyPass
+ * @example
+ *
+ * const isQueen = R.propEq('rank', 'Q');
+ * const isSpade = R.propEq('suit', '♠︎');
+ * const isQueenOfSpades = R.allPass([isQueen, isSpade]);
+ *
+ * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
+ * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
+ */
+ var allPass = _curry1(function allPass(preds) {
+ return curryN(reduce(max, 0, pluck('length', preds)), function () {
+ var idx = 0;
+ var len = preds.length;
+ while (idx < len) {
+ if (!preds[idx].apply(this, arguments)) {
+ return false;
+ }
+ idx += 1;
+ }
+ return true;
+ });
+ });
+
+ /**
+ * Returns a function that always returns the given value. Note that for
+ * non-primitives the value returned is a reference to the original value.
+ *
+ * This function is known as `const`, `constant`, or `K` (for K combinator) in
+ * other languages and libraries.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig a -> (* -> a)
+ * @param {*} val The value to wrap in a function
+ * @return {Function} A Function :: * -> val.
+ * @example
+ *
+ * const t = R.always('Tee');
+ * t(); //=> 'Tee'
+ */
+ var always = _curry1(function always(val) {
+ return function () {
+ return val;
+ };
+ });
+
+ /**
+ * Returns `true` if both arguments are `true`; `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Logic
+ * @sig a -> b -> a | b
+ * @param {Any} a
+ * @param {Any} b
+ * @return {Any} the first argument if it is falsy, otherwise the second argument.
+ * @see R.both
+ * @example
+ *
+ * R.and(true, true); //=> true
+ * R.and(true, false); //=> false
+ * R.and(false, true); //=> false
+ * R.and(false, false); //=> false
+ */
+ var and = _curry2(function and(a, b) {
+ return a && b;
+ });
+
+ function XAny(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ this.any = false;
}
- return val;
-});
+ XAny.prototype['@@transducer/init'] = _xfBase.init;
+ XAny.prototype['@@transducer/result'] = function (result) {
+ if (!this.any) {
+ result = this.xf['@@transducer/step'](result, false);
+ }
+ return this.xf['@@transducer/result'](result);
+ };
+ XAny.prototype['@@transducer/step'] = function (result, input) {
+ if (this.f(input)) {
+ this.any = true;
+ result = _reduced(this.xf['@@transducer/step'](result, true));
+ }
+ return result;
+ };
-/**
- * Returns a function that when supplied an object returns the indicated
- * property of that object, if it exists.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig s -> {s: a} -> a | Undefined
- * @param {String} p The property name
- * @param {Object} obj The object to query
- * @return {*} The value at `obj.p`.
- * @see R.path
- * @example
- *
- * R.prop('x', {x: 100}); //=> 100
- * R.prop('x', {}); //=> undefined
- * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4
- */
+ var _xany = _curry2(function _xany(f, xf) {
+ return new XAny(f, xf);
+ });
-var prop = _curry2(function prop(p, obj) { return path([p], obj); });
+ /**
+ * Returns `true` if at least one of the elements of the list match the predicate,
+ * `false` otherwise.
+ *
+ * Dispatches to the `any` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> Boolean
+ * @param {Function} fn The predicate function.
+ * @param {Array} list The array to consider.
+ * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
+ * otherwise.
+ * @see R.all, R.none, R.transduce
+ * @example
+ *
+ * const lessThan0 = R.flip(R.lt)(0);
+ * const lessThan2 = R.flip(R.lt)(2);
+ * R.any(lessThan0)([1, 2]); //=> false
+ * R.any(lessThan2)([1, 2]); //=> true
+ */
+ var any = _curry2(
+ _dispatchable(['any'], _xany, function any(fn, list) {
+ var idx = 0;
+ while (idx < list.length) {
+ if (fn(list[idx])) {
+ return true;
+ }
+ idx += 1;
+ }
+ return false;
+ })
+ );
-/**
- * Returns a new list by plucking the same named property off all objects in
- * the list supplied.
- *
- * `pluck` will work on
- * any [functor](https://github.com/fantasyland/fantasy-land#functor) in
- * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Functor f => k -> f {k: v} -> f v
- * @param {Number|String} key The key name to pluck off of each object.
- * @param {Array} f The array or functor to consider.
- * @return {Array} The list of values for the given key.
- * @see R.props
- * @example
- *
- * var getAges = R.pluck('age');
- * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27]
- *
- * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
- * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
- * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5]
- * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5]
- */
-var pluck = _curry2(function pluck(p, list) {
- return map(prop(p), list);
-});
+ /**
+ * Takes a list of predicates and returns a predicate that returns true for a
+ * given list of arguments if at least one of the provided predicates is
+ * satisfied by those arguments.
+ *
+ * The function returned is a curried function whose arity matches that of the
+ * highest-arity predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Logic
+ * @sig [(*... -> Boolean)] -> (*... -> Boolean)
+ * @param {Array} predicates An array of predicates to check
+ * @return {Function} The combined predicate
+ * @see R.allPass
+ * @example
+ *
+ * const isClub = R.propEq('suit', '♣');
+ * const isSpade = R.propEq('suit', '♠');
+ * const isBlackCard = R.anyPass([isClub, isSpade]);
+ *
+ * isBlackCard({rank: '10', suit: '♣'}); //=> true
+ * isBlackCard({rank: 'Q', suit: '♠'}); //=> true
+ * isBlackCard({rank: 'Q', suit: '♦'}); //=> false
+ */
+ var anyPass = _curry1(function anyPass(preds) {
+ return curryN(reduce(max, 0, pluck('length', preds)), function () {
+ var idx = 0;
+ var len = preds.length;
+ while (idx < len) {
+ if (preds[idx].apply(this, arguments)) {
+ return true;
+ }
+ idx += 1;
+ }
+ return false;
+ });
+ });
-/**
- * Returns a single item by iterating through the list, successively calling
- * the iterator function and passing it an accumulator value and the current
- * value from the array, and then passing the result to the next call.
- *
- * The iterator function receives two values: *(acc, value)*. It may use
- * [`R.reduced`](#reduced) to shortcut the iteration.
- *
- * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
- * is *(value, acc)*.
- *
- * Note: `R.reduce` does not skip deleted or unassigned indices (sparse
- * arrays), unlike the native `Array.prototype.reduce` method. For more details
- * on this behavior, see:
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
- *
- * Dispatches to the `reduce` method of the third argument, if present. When
- * doing so, it is up to the user to handle the [`R.reduced`](#reduced)
- * shortcuting, as this is not implemented by `reduce`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig ((a, b) -> a) -> a -> [b] -> a
- * @param {Function} fn The iterator function. Receives two values, the accumulator and the
- * current element from the array.
- * @param {*} acc The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.reduced, R.addIndex, R.reduceRight
- * @example
- *
- * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
- * // - -10
- * // / \ / \
- * // - 4 -6 4
- * // / \ / \
- * // - 3 ==> -3 3
- * // / \ / \
- * // - 2 -1 2
- * // / \ / \
- * // 0 1 0 1
- *
- * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
- */
-var reduce = _curry3(_reduce);
+ /**
+ * ap applies a list of functions to a list of values.
+ *
+ * Dispatches to the `ap` method of the second argument, if present. Also
+ * treats curried functions as applicatives.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category Function
+ * @sig [a -> b] -> [a] -> [b]
+ * @sig Apply f => f (a -> b) -> f a -> f b
+ * @sig (r -> a -> b) -> (r -> a) -> (r -> b)
+ * @param {*} applyF
+ * @param {*} applyX
+ * @return {*}
+ * @example
+ *
+ * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
+ * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]
+ *
+ * // R.ap can also be used as S combinator
+ * // when only two functions are passed
+ * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA'
+ * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)]
+ */
+ var ap = _curry2(function ap(applyF, applyX) {
+ return typeof applyX['fantasy-land/ap'] === 'function'
+ ? applyX['fantasy-land/ap'](applyF)
+ : typeof applyF.ap === 'function'
+ ? applyF.ap(applyX)
+ : typeof applyF === 'function'
+ ? function (x) {
+ return applyF(x)(applyX(x));
+ }
+ : // else
+ _reduce(
+ function (acc, f) {
+ return _concat(acc, map(f, applyX));
+ },
+ [],
+ applyF
+ );
+ });
-/**
- * Takes a list of predicates and returns a predicate that returns true for a
- * given list of arguments if every one of the provided predicates is satisfied
- * by those arguments.
- *
- * The function returned is a curried function whose arity matches that of the
- * highest-arity predicate.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Logic
- * @sig [(*... -> Boolean)] -> (*... -> Boolean)
- * @param {Array} predicates An array of predicates to check
- * @return {Function} The combined predicate
- * @see R.anyPass
- * @example
- *
- * const isQueen = R.propEq('rank', 'Q');
- * const isSpade = R.propEq('suit', '♠︎');
- * const isQueenOfSpades = R.allPass([isQueen, isSpade]);
- *
- * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
- * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
- */
-var allPass = _curry1(function allPass(preds) {
- return curryN(reduce(max, 0, pluck('length', preds)), function() {
+ function _aperture(n, list) {
var idx = 0;
- var len = preds.length;
- while (idx < len) {
- if (!preds[idx].apply(this, arguments)) {
- return false;
- }
+ var limit = list.length - (n - 1);
+ var acc = new Array(limit >= 0 ? limit : 0);
+ while (idx < limit) {
+ acc[idx] = Array.prototype.slice.call(list, idx, idx + n);
idx += 1;
}
- return true;
- });
-});
+ return acc;
+ }
-/**
- * Returns a function that always returns the given value. Note that for
- * non-primitives the value returned is a reference to the original value.
- *
- * This function is known as `const`, `constant`, or `K` (for K combinator) in
- * other languages and libraries.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig a -> (* -> a)
- * @param {*} val The value to wrap in a function
- * @return {Function} A Function :: * -> val.
- * @example
- *
- * const t = R.always('Tee');
- * t(); //=> 'Tee'
- */
-var always = _curry1(function always(val) {
- return function() {
- return val;
+ function XAperture(n, xf) {
+ this.xf = xf;
+ this.pos = 0;
+ this.full = false;
+ this.acc = new Array(n);
+ }
+ XAperture.prototype['@@transducer/init'] = _xfBase.init;
+ XAperture.prototype['@@transducer/result'] = function (result) {
+ this.acc = null;
+ return this.xf['@@transducer/result'](result);
+ };
+ XAperture.prototype['@@transducer/step'] = function (result, input) {
+ this.store(input);
+ return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
+ };
+ XAperture.prototype.store = function (input) {
+ this.acc[this.pos] = input;
+ this.pos += 1;
+ if (this.pos === this.acc.length) {
+ this.pos = 0;
+ this.full = true;
+ }
+ };
+ XAperture.prototype.getCopy = function () {
+ return _concat(Array.prototype.slice.call(this.acc, this.pos), Array.prototype.slice.call(this.acc, 0, this.pos));
};
-});
-
-/**
- * Returns `true` if both arguments are `true`; `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Logic
- * @sig a -> b -> a | b
- * @param {Any} a
- * @param {Any} b
- * @return {Any} the first argument if it is falsy, otherwise the second argument.
- * @see R.both
- * @example
- *
- * R.and(true, true); //=> true
- * R.and(true, false); //=> false
- * R.and(false, true); //=> false
- * R.and(false, false); //=> false
- */
-var and = _curry2(function and(a, b) {
- return a && b;
-});
-function XAny(f, xf) {
- this.xf = xf;
- this.f = f;
- this.any = false;
-}
-XAny.prototype['@@transducer/init'] = _xfBase.init;
-XAny.prototype['@@transducer/result'] = function(result) {
- if (!this.any) {
- result = this.xf['@@transducer/step'](result, false);
- }
- return this.xf['@@transducer/result'](result);
-};
-XAny.prototype['@@transducer/step'] = function(result, input) {
- if (this.f(input)) {
- this.any = true;
- result = _reduced(this.xf['@@transducer/step'](result, true));
- }
- return result;
-};
+ var _xaperture = _curry2(function _xaperture(n, xf) {
+ return new XAperture(n, xf);
+ });
-var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); });
+ /**
+ * Returns a new list, composed of n-tuples of consecutive elements. If `n` is
+ * greater than the length of the list, an empty list is returned.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category List
+ * @sig Number -> [a] -> [[a]]
+ * @param {Number} n The size of the tuples to create
+ * @param {Array} list The list to split into `n`-length tuples
+ * @return {Array} The resulting list of `n`-length tuples
+ * @see R.transduce
+ * @example
+ *
+ * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
+ * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
+ * R.aperture(7, [1, 2, 3, 4, 5]); //=> []
+ */
+ var aperture = _curry2(_dispatchable([], _xaperture, _aperture));
+
+ /**
+ * Returns a new list containing the contents of the given list, followed by
+ * the given element.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> [a]
+ * @param {*} el The element to add to the end of the new list.
+ * @param {Array} list The list of elements to add a new item to.
+ * list.
+ * @return {Array} A new list containing the elements of the old list followed by `el`.
+ * @see R.prepend
+ * @example
+ *
+ * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
+ * R.append('tests', []); //=> ['tests']
+ * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
+ */
+ var append = _curry2(function append(el, list) {
+ return _concat(list, [el]);
+ });
-/**
- * Returns `true` if at least one of the elements of the list match the predicate,
- * `false` otherwise.
- *
- * Dispatches to the `any` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> Boolean
- * @param {Function} fn The predicate function.
- * @param {Array} list The array to consider.
- * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
- * otherwise.
- * @see R.all, R.none, R.transduce
- * @example
- *
- * const lessThan0 = R.flip(R.lt)(0);
- * const lessThan2 = R.flip(R.lt)(2);
- * R.any(lessThan0)([1, 2]); //=> false
- * R.any(lessThan2)([1, 2]); //=> true
- */
-var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) {
- var idx = 0;
- while (idx < list.length) {
- if (fn(list[idx])) {
- return true;
- }
- idx += 1;
- }
- return false;
-}));
+ /**
+ * Applies function `fn` to the argument list `args`. This is useful for
+ * creating a fixed-arity function from a variadic function. `fn` should be a
+ * bound function if context is significant.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Function
+ * @sig (*... -> a) -> [*] -> a
+ * @param {Function} fn The function which will be called with `args`
+ * @param {Array} args The arguments to call `fn` with
+ * @return {*} result The result, equivalent to `fn(...args)`
+ * @see R.call, R.unapply
+ * @example
+ *
+ * const nums = [1, 2, 3, -99, 42, 6, 7];
+ * R.apply(Math.max, nums); //=> 42
+ * @symb R.apply(f, [a, b, c]) = f(a, b, c)
+ */
+ var apply = _curry2(function apply(fn, args) {
+ return fn.apply(this, args);
+ });
-/**
- * Takes a list of predicates and returns a predicate that returns true for a
- * given list of arguments if at least one of the provided predicates is
- * satisfied by those arguments.
- *
- * The function returned is a curried function whose arity matches that of the
- * highest-arity predicate.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Logic
- * @sig [(*... -> Boolean)] -> (*... -> Boolean)
- * @param {Array} predicates An array of predicates to check
- * @return {Function} The combined predicate
- * @see R.allPass
- * @example
- *
- * const isClub = R.propEq('suit', '♣');
- * const isSpade = R.propEq('suit', '♠');
- * const isBlackCard = R.anyPass([isClub, isSpade]);
- *
- * isBlackCard({rank: '10', suit: '♣'}); //=> true
- * isBlackCard({rank: 'Q', suit: '♠'}); //=> true
- * isBlackCard({rank: 'Q', suit: '♦'}); //=> false
- */
-var anyPass = _curry1(function anyPass(preds) {
- return curryN(reduce(max, 0, pluck('length', preds)), function() {
+ /**
+ * Returns a list of all the enumerable own properties of the supplied object.
+ * Note that the order of the output array is not guaranteed across different
+ * JS platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig {k: v} -> [v]
+ * @param {Object} obj The object to extract values from
+ * @return {Array} An array of the values of the object's own properties.
+ * @see R.valuesIn, R.keys
+ * @example
+ *
+ * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]
+ */
+ var values = _curry1(function values(obj) {
+ var props = keys(obj);
+ var len = props.length;
+ var vals = [];
var idx = 0;
- var len = preds.length;
while (idx < len) {
- if (preds[idx].apply(this, arguments)) {
- return true;
- }
+ vals[idx] = obj[props[idx]];
idx += 1;
}
- return false;
+ return vals;
});
-});
-
-/**
- * ap applies a list of functions to a list of values.
- *
- * Dispatches to the `ap` method of the second argument, if present. Also
- * treats curried functions as applicatives.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category Function
- * @sig [a -> b] -> [a] -> [b]
- * @sig Apply f => f (a -> b) -> f a -> f b
- * @sig (r -> a -> b) -> (r -> a) -> (r -> b)
- * @param {*} applyF
- * @param {*} applyX
- * @return {*}
- * @example
- *
- * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
- * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]
- *
- * // R.ap can also be used as S combinator
- * // when only two functions are passed
- * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA'
- * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)]
- */
-var ap = _curry2(function ap(applyF, applyX) {
- return (
- typeof applyX['fantasy-land/ap'] === 'function' ?
- applyX['fantasy-land/ap'](applyF) :
- typeof applyF.ap === 'function' ?
- applyF.ap(applyX) :
- typeof applyF === 'function' ?
- function(x) { return applyF(x)(applyX(x)); } :
- // else
- _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF)
- );
-});
-
-function _aperture(n, list) {
- var idx = 0;
- var limit = list.length - (n - 1);
- var acc = new Array(limit >= 0 ? limit : 0);
- while (idx < limit) {
- acc[idx] = Array.prototype.slice.call(list, idx, idx + n);
- idx += 1;
- }
- return acc;
-}
-
-function XAperture(n, xf) {
- this.xf = xf;
- this.pos = 0;
- this.full = false;
- this.acc = new Array(n);
-}
-XAperture.prototype['@@transducer/init'] = _xfBase.init;
-XAperture.prototype['@@transducer/result'] = function(result) {
- this.acc = null;
- return this.xf['@@transducer/result'](result);
-};
-XAperture.prototype['@@transducer/step'] = function(result, input) {
- this.store(input);
- return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
-};
-XAperture.prototype.store = function(input) {
- this.acc[this.pos] = input;
- this.pos += 1;
- if (this.pos === this.acc.length) {
- this.pos = 0;
- this.full = true;
- }
-};
-XAperture.prototype.getCopy = function() {
- return _concat(Array.prototype.slice.call(this.acc, this.pos),
- Array.prototype.slice.call(this.acc, 0, this.pos));
-};
-var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); });
+ // Use custom mapValues function to avoid issues with specs that include a "map" key and R.map
+ // delegating calls to .map
+ function mapValues(fn, obj) {
+ return keys(obj).reduce(function (acc, key) {
+ acc[key] = fn(obj[key]);
+ return acc;
+ }, {});
+ }
+
+ /**
+ * Given a spec object recursively mapping properties to functions, creates a
+ * function producing an object of the same structure, by mapping each property
+ * to the result of calling its associated function with the supplied arguments.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.20.0
+ * @category Function
+ * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v})
+ * @param {Object} spec an object recursively mapping properties to functions for
+ * producing the values for these properties.
+ * @return {Function} A function that returns an object of the same structure
+ * as `spec', with each property set to the value returned by calling its
+ * associated function with the supplied arguments.
+ * @see R.converge, R.juxt
+ * @example
+ *
+ * const getMetrics = R.applySpec({
+ * sum: R.add,
+ * nested: { mul: R.multiply }
+ * });
+ * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
+ * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } }
+ */
+ var applySpec = _curry1(function applySpec(spec) {
+ spec = mapValues(function (v) {
+ return typeof v == 'function' ? v : applySpec(v);
+ }, spec);
+
+ return curryN(reduce(max, 0, pluck('length', values(spec))), function () {
+ var args = arguments;
+ return mapValues(function (f) {
+ return apply(f, args);
+ }, spec);
+ });
+ });
-/**
- * Returns a new list, composed of n-tuples of consecutive elements. If `n` is
- * greater than the length of the list, an empty list is returned.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category List
- * @sig Number -> [a] -> [[a]]
- * @param {Number} n The size of the tuples to create
- * @param {Array} list The list to split into `n`-length tuples
- * @return {Array} The resulting list of `n`-length tuples
- * @see R.transduce
- * @example
- *
- * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
- * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
- * R.aperture(7, [1, 2, 3, 4, 5]); //=> []
- */
-var aperture = _curry2(_dispatchable([], _xaperture, _aperture));
+ /**
+ * Takes a value and applies a function to it.
+ *
+ * This function is also known as the `thrush` combinator.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.25.0
+ * @category Function
+ * @sig a -> (a -> b) -> b
+ * @param {*} x The value
+ * @param {Function} f The function to apply
+ * @return {*} The result of applying `f` to `x`
+ * @example
+ *
+ * const t42 = R.applyTo(42);
+ * t42(R.identity); //=> 42
+ * t42(R.add(1)); //=> 43
+ */
+ var applyTo = _curry2(function applyTo(x, f) {
+ return f(x);
+ });
-/**
- * Returns a new list containing the contents of the given list, followed by
- * the given element.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> [a]
- * @param {*} el The element to add to the end of the new list.
- * @param {Array} list The list of elements to add a new item to.
- * list.
- * @return {Array} A new list containing the elements of the old list followed by `el`.
- * @see R.prepend
- * @example
- *
- * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
- * R.append('tests', []); //=> ['tests']
- * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
- */
-var append = _curry2(function append(el, list) {
- return _concat(list, [el]);
-});
+ /**
+ * Makes an ascending comparator function out of a function that returns a value
+ * that can be compared with `<` and `>`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.23.0
+ * @category Function
+ * @sig Ord b => (a -> b) -> a -> a -> Number
+ * @param {Function} fn A function of arity one that returns a value that can be compared
+ * @param {*} a The first item to be compared.
+ * @param {*} b The second item to be compared.
+ * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
+ * @see R.descend
+ * @example
+ *
+ * const byAge = R.ascend(R.prop('age'));
+ * const people = [
+ * { name: 'Emma', age: 70 },
+ * { name: 'Peter', age: 78 },
+ * { name: 'Mikhail', age: 62 },
+ * ];
+ * const peopleByYoungestFirst = R.sort(byAge, people);
+ * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
+ */
+ var ascend = _curry3(function ascend(fn, a, b) {
+ var aa = fn(a);
+ var bb = fn(b);
+ return aa < bb ? -1 : aa > bb ? 1 : 0;
+ });
-/**
- * Applies function `fn` to the argument list `args`. This is useful for
- * creating a fixed-arity function from a variadic function. `fn` should be a
- * bound function if context is significant.
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Function
- * @sig (*... -> a) -> [*] -> a
- * @param {Function} fn The function which will be called with `args`
- * @param {Array} args The arguments to call `fn` with
- * @return {*} result The result, equivalent to `fn(...args)`
- * @see R.call, R.unapply
- * @example
- *
- * const nums = [1, 2, 3, -99, 42, 6, 7];
- * R.apply(Math.max, nums); //=> 42
- * @symb R.apply(f, [a, b, c]) = f(a, b, c)
- */
-var apply = _curry2(function apply(fn, args) {
- return fn.apply(this, args);
-});
+ /**
+ * Makes a shallow clone of an object, setting or overriding the specified
+ * property with the given value. Note that this copies and flattens prototype
+ * properties onto the new object as well. All non-primitive properties are
+ * copied by reference.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Object
+ * @sig String -> a -> {k: v} -> {k: v}
+ * @param {String} prop The property name to set
+ * @param {*} val The new value
+ * @param {Object} obj The object to clone
+ * @return {Object} A new object equivalent to the original except for the changed property.
+ * @see R.dissoc, R.pick
+ * @example
+ *
+ * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
+ */
+ var assoc = _curry3(function assoc(prop, val, obj) {
+ var result = {};
+ for (var p in obj) {
+ result[p] = obj[p];
+ }
+ result[prop] = val;
+ return result;
+ });
-/**
- * Returns a list of all the enumerable own properties of the supplied object.
- * Note that the order of the output array is not guaranteed across different
- * JS platforms.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig {k: v} -> [v]
- * @param {Object} obj The object to extract values from
- * @return {Array} An array of the values of the object's own properties.
- * @see R.valuesIn, R.keys
- * @example
- *
- * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]
- */
-var values = _curry1(function values(obj) {
- var props = keys(obj);
- var len = props.length;
- var vals = [];
- var idx = 0;
- while (idx < len) {
- vals[idx] = obj[props[idx]];
- idx += 1;
- }
- return vals;
-});
+ /**
+ * Determine if the passed argument is an integer.
+ *
+ * @private
+ * @param {*} n
+ * @category Type
+ * @return {Boolean}
+ */
+ var _isInteger =
+ Number.isInteger ||
+ function _isInteger(n) {
+ return n << 0 === n;
+ };
-// Use custom mapValues function to avoid issues with specs that include a "map" key and R.map
-// delegating calls to .map
-function mapValues(fn, obj) {
- return keys(obj).reduce(function(acc, key) {
- acc[key] = fn(obj[key]);
- return acc;
- }, {});
-}
+ /**
+ * Checks if the input value is `null` or `undefined`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Type
+ * @sig * -> Boolean
+ * @param {*} x The value to test.
+ * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`.
+ * @example
+ *
+ * R.isNil(null); //=> true
+ * R.isNil(undefined); //=> true
+ * R.isNil(0); //=> false
+ * R.isNil([]); //=> false
+ */
+ var isNil = _curry1(function isNil(x) {
+ return x == null;
+ });
-/**
- * Given a spec object recursively mapping properties to functions, creates a
- * function producing an object of the same structure, by mapping each property
- * to the result of calling its associated function with the supplied arguments.
- *
- * @func
- * @memberOf R
- * @since v0.20.0
- * @category Function
- * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v})
- * @param {Object} spec an object recursively mapping properties to functions for
- * producing the values for these properties.
- * @return {Function} A function that returns an object of the same structure
- * as `spec', with each property set to the value returned by calling its
- * associated function with the supplied arguments.
- * @see R.converge, R.juxt
- * @example
- *
- * const getMetrics = R.applySpec({
- * sum: R.add,
- * nested: { mul: R.multiply }
- * });
- * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
- * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } }
- */
-var applySpec = _curry1(function applySpec(spec) {
- spec = mapValues(
- function(v) { return typeof v == 'function' ? v : applySpec(v); },
- spec
- );
+ /**
+ * Makes a shallow clone of an object, setting or overriding the nodes required
+ * to create the given path, and placing the specific value at the tail end of
+ * that path. Note that this copies and flattens prototype properties onto the
+ * new object as well. All non-primitive properties are copied by reference.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @sig [Idx] -> a -> {a} -> {a}
+ * @param {Array} path the path to set
+ * @param {*} val The new value
+ * @param {Object} obj The object to clone
+ * @return {Object} A new object equivalent to the original except along the specified path.
+ * @see R.dissocPath
+ * @example
+ *
+ * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}
+ *
+ * // Any missing or non-object keys in path will be overridden
+ * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
+ */
+ var assocPath = _curry3(function assocPath(path, val, obj) {
+ if (path.length === 0) {
+ return val;
+ }
+ var idx = path[0];
+ if (path.length > 1) {
+ var nextObj = !isNil(obj) && _has(idx, obj) ? obj[idx] : _isInteger(path[1]) ? [] : {};
+ val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj);
+ }
+ if (_isInteger(idx) && _isArray(obj)) {
+ var arr = [].concat(obj);
+ arr[idx] = val;
+ return arr;
+ } else {
+ return assoc(idx, val, obj);
+ }
+ });
- return curryN(
- reduce(max, 0, pluck('length', values(spec))),
- function() {
- var args = arguments;
- return mapValues(function(f) { return apply(f, args); }, spec);
- });
-});
+ /**
+ * Wraps a function of any arity (including nullary) in a function that accepts
+ * exactly `n` parameters. Any extraneous parameters will not be passed to the
+ * supplied function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig Number -> (* -> a) -> (* -> a)
+ * @param {Number} n The desired arity of the new function.
+ * @param {Function} fn The function to wrap.
+ * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
+ * arity `n`.
+ * @see R.binary, R.unary
+ * @example
+ *
+ * const takesTwoArgs = (a, b) => [a, b];
+ *
+ * takesTwoArgs.length; //=> 2
+ * takesTwoArgs(1, 2); //=> [1, 2]
+ *
+ * const takesOneArg = R.nAry(1, takesTwoArgs);
+ * takesOneArg.length; //=> 1
+ * // Only `n` arguments are passed to the wrapped function
+ * takesOneArg(1, 2); //=> [1, undefined]
+ * @symb R.nAry(0, f)(a, b) = f()
+ * @symb R.nAry(1, f)(a, b) = f(a)
+ * @symb R.nAry(2, f)(a, b) = f(a, b)
+ */
+ var nAry = _curry2(function nAry(n, fn) {
+ switch (n) {
+ case 0:
+ return function () {
+ return fn.call(this);
+ };
+ case 1:
+ return function (a0) {
+ return fn.call(this, a0);
+ };
+ case 2:
+ return function (a0, a1) {
+ return fn.call(this, a0, a1);
+ };
+ case 3:
+ return function (a0, a1, a2) {
+ return fn.call(this, a0, a1, a2);
+ };
+ case 4:
+ return function (a0, a1, a2, a3) {
+ return fn.call(this, a0, a1, a2, a3);
+ };
+ case 5:
+ return function (a0, a1, a2, a3, a4) {
+ return fn.call(this, a0, a1, a2, a3, a4);
+ };
+ case 6:
+ return function (a0, a1, a2, a3, a4, a5) {
+ return fn.call(this, a0, a1, a2, a3, a4, a5);
+ };
+ case 7:
+ return function (a0, a1, a2, a3, a4, a5, a6) {
+ return fn.call(this, a0, a1, a2, a3, a4, a5, a6);
+ };
+ case 8:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7) {
+ return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);
+ };
+ case 9:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
+ return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);
+ };
+ case 10:
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
+ return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+ };
+ default:
+ throw new Error('First argument to nAry must be a non-negative integer no greater than ten');
+ }
+ });
-/**
- * Takes a value and applies a function to it.
- *
- * This function is also known as the `thrush` combinator.
- *
- * @func
- * @memberOf R
- * @since v0.25.0
- * @category Function
- * @sig a -> (a -> b) -> b
- * @param {*} x The value
- * @param {Function} f The function to apply
- * @return {*} The result of applying `f` to `x`
- * @example
- *
- * const t42 = R.applyTo(42);
- * t42(R.identity); //=> 42
- * t42(R.add(1)); //=> 43
- */
-var applyTo = _curry2(function applyTo(x, f) { return f(x); });
+ /**
+ * Wraps a function of any arity (including nullary) in a function that accepts
+ * exactly 2 parameters. Any extraneous parameters will not be passed to the
+ * supplied function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category Function
+ * @sig (* -> c) -> (a, b -> c)
+ * @param {Function} fn The function to wrap.
+ * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
+ * arity 2.
+ * @see R.nAry, R.unary
+ * @example
+ *
+ * const takesThreeArgs = function(a, b, c) {
+ * return [a, b, c];
+ * };
+ * takesThreeArgs.length; //=> 3
+ * takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
+ *
+ * const takesTwoArgs = R.binary(takesThreeArgs);
+ * takesTwoArgs.length; //=> 2
+ * // Only 2 arguments are passed to the wrapped function
+ * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
+ * @symb R.binary(f)(a, b, c) = f(a, b)
+ */
+ var binary = _curry1(function binary(fn) {
+ return nAry(2, fn);
+ });
-/**
- * Makes an ascending comparator function out of a function that returns a value
- * that can be compared with `<` and `>`.
- *
- * @func
- * @memberOf R
- * @since v0.23.0
- * @category Function
- * @sig Ord b => (a -> b) -> a -> a -> Number
- * @param {Function} fn A function of arity one that returns a value that can be compared
- * @param {*} a The first item to be compared.
- * @param {*} b The second item to be compared.
- * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
- * @see R.descend
- * @example
- *
- * const byAge = R.ascend(R.prop('age'));
- * const people = [
- * { name: 'Emma', age: 70 },
- * { name: 'Peter', age: 78 },
- * { name: 'Mikhail', age: 62 },
- * ];
- * const peopleByYoungestFirst = R.sort(byAge, people);
- * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
- */
-var ascend = _curry3(function ascend(fn, a, b) {
- var aa = fn(a);
- var bb = fn(b);
- return aa < bb ? -1 : aa > bb ? 1 : 0;
-});
+ function _isFunction(x) {
+ return Object.prototype.toString.call(x) === '[object Function]';
+ }
+
+ /**
+ * "lifts" a function to be the specified arity, so that it may "map over" that
+ * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Function
+ * @sig Number -> (*... -> *) -> ([*]... -> [*])
+ * @param {Function} fn The function to lift into higher context
+ * @return {Function} The lifted function.
+ * @see R.lift, R.ap
+ * @example
+ *
+ * const madd3 = R.liftN(3, (...args) => R.sum(args));
+ * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
+ */
+ var liftN = _curry2(function liftN(arity, fn) {
+ var lifted = curryN(arity, fn);
+ return curryN(arity, function () {
+ return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
+ });
+ });
-/**
- * Makes a shallow clone of an object, setting or overriding the specified
- * property with the given value. Note that this copies and flattens prototype
- * properties onto the new object as well. All non-primitive properties are
- * copied by reference.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Object
- * @sig String -> a -> {k: v} -> {k: v}
- * @param {String} prop The property name to set
- * @param {*} val The new value
- * @param {Object} obj The object to clone
- * @return {Object} A new object equivalent to the original except for the changed property.
- * @see R.dissoc, R.pick
- * @example
- *
- * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
- */
-var assoc = _curry3(function assoc(prop, val, obj) {
- var result = {};
- for (var p in obj) {
- result[p] = obj[p];
- }
- result[prop] = val;
- return result;
-});
+ /**
+ * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other
+ * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Function
+ * @sig (*... -> *) -> ([*]... -> [*])
+ * @param {Function} fn The function to lift into higher context
+ * @return {Function} The lifted function.
+ * @see R.liftN
+ * @example
+ *
+ * const madd3 = R.lift((a, b, c) => a + b + c);
+ *
+ * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
+ *
+ * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e);
+ *
+ * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24]
+ */
+ var lift = _curry1(function lift(fn) {
+ return liftN(fn.length, fn);
+ });
-/**
- * Determine if the passed argument is an integer.
- *
- * @private
- * @param {*} n
- * @category Type
- * @return {Boolean}
- */
-var _isInteger = Number.isInteger || function _isInteger(n) {
- return (n << 0) === n;
-};
+ /**
+ * A function which calls the two provided functions and returns the `&&`
+ * of the results.
+ * It returns the result of the first function if it is false-y and the result
+ * of the second function otherwise. Note that this is short-circuited,
+ * meaning that the second function will not be invoked if the first returns a
+ * false-y value.
+ *
+ * In addition to functions, `R.both` also accepts any fantasy-land compatible
+ * applicative functor.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category Logic
+ * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
+ * @param {Function} f A predicate
+ * @param {Function} g Another predicate
+ * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together.
+ * @see R.and
+ * @example
+ *
+ * const gt10 = R.gt(R.__, 10)
+ * const lt20 = R.lt(R.__, 20)
+ * const f = R.both(gt10, lt20);
+ * f(15); //=> true
+ * f(30); //=> false
+ *
+ * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false)
+ * R.both([false, false, 'a'], [11]); //=> [false, false, 11]
+ */
+ var both = _curry2(function both(f, g) {
+ return _isFunction(f)
+ ? function _both() {
+ return f.apply(this, arguments) && g.apply(this, arguments);
+ }
+ : lift(and)(f, g);
+ });
-/**
- * Checks if the input value is `null` or `undefined`.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Type
- * @sig * -> Boolean
- * @param {*} x The value to test.
- * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`.
- * @example
- *
- * R.isNil(null); //=> true
- * R.isNil(undefined); //=> true
- * R.isNil(0); //=> false
- * R.isNil([]); //=> false
- */
-var isNil = _curry1(function isNil(x) { return x == null; });
+ /**
+ * Returns a curried equivalent of the provided function. The curried function
+ * has two unusual capabilities. First, its arguments needn't be provided one
+ * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the
+ * following are equivalent:
+ *
+ * - `g(1)(2)(3)`
+ * - `g(1)(2, 3)`
+ * - `g(1, 2)(3)`
+ * - `g(1, 2, 3)`
+ *
+ * Secondly, the special placeholder value [`R.__`](#__) may be used to specify
+ * "gaps", allowing partial application of any combination of arguments,
+ * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
+ * the following are equivalent:
+ *
+ * - `g(1, 2, 3)`
+ * - `g(_, 2, 3)(1)`
+ * - `g(_, _, 3)(1)(2)`
+ * - `g(_, _, 3)(1, 2)`
+ * - `g(_, 2)(1)(3)`
+ * - `g(_, 2)(1, 3)`
+ * - `g(_, 2)(_, 3)(1)`
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig (* -> a) -> (* -> a)
+ * @param {Function} fn The function to curry.
+ * @return {Function} A new, curried function.
+ * @see R.curryN, R.partial
+ * @example
+ *
+ * const addFourNumbers = (a, b, c, d) => a + b + c + d;
+ *
+ * const curriedAddFourNumbers = R.curry(addFourNumbers);
+ * const f = curriedAddFourNumbers(1, 2);
+ * const g = f(3);
+ * g(4); //=> 10
+ */
+ var curry = _curry1(function curry(fn) {
+ return curryN(fn.length, fn);
+ });
-/**
- * Makes a shallow clone of an object, setting or overriding the nodes required
- * to create the given path, and placing the specific value at the tail end of
- * that path. Note that this copies and flattens prototype properties onto the
- * new object as well. All non-primitive properties are copied by reference.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Object
- * @typedefn Idx = String | Int
- * @sig [Idx] -> a -> {a} -> {a}
- * @param {Array} path the path to set
- * @param {*} val The new value
- * @param {Object} obj The object to clone
- * @return {Object} A new object equivalent to the original except along the specified path.
- * @see R.dissocPath
- * @example
- *
- * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}
- *
- * // Any missing or non-object keys in path will be overridden
- * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
- */
-var assocPath = _curry3(function assocPath(path, val, obj) {
- if (path.length === 0) {
- return val;
- }
- var idx = path[0];
- if (path.length > 1) {
- var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {};
- val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj);
- }
- if (_isInteger(idx) && _isArray(obj)) {
- var arr = [].concat(obj);
- arr[idx] = val;
- return arr;
- } else {
- return assoc(idx, val, obj);
+ /**
+ * Returns the result of calling its first argument with the remaining
+ * arguments. This is occasionally useful as a converging function for
+ * [`R.converge`](#converge): the first branch can produce a function while the
+ * remaining branches produce values to be passed to that function as its
+ * arguments.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Function
+ * @sig (*... -> a),*... -> a
+ * @param {Function} fn The function to apply to the remaining arguments.
+ * @param {...*} args Any number of positional arguments.
+ * @return {*}
+ * @see R.apply
+ * @example
+ *
+ * R.call(R.add, 1, 2); //=> 3
+ *
+ * const indentN = R.pipe(R.repeat(' '),
+ * R.join(''),
+ * R.replace(/^(?!$)/gm));
+ *
+ * const format = R.converge(R.call, [
+ * R.pipe(R.prop('indent'), indentN),
+ * R.prop('value')
+ * ]);
+ *
+ * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n'
+ * @symb R.call(f, a, b) = f(a, b)
+ */
+ var call = curry(function call(fn) {
+ return fn.apply(this, Array.prototype.slice.call(arguments, 1));
+ });
+
+ /**
+ * `_makeFlat` is a helper function that returns a one-level or fully recursive
+ * function based on the flag passed in.
+ *
+ * @private
+ */
+ function _makeFlat(recursive) {
+ return function flatt(list) {
+ var value, jlen, j;
+ var result = [];
+ var idx = 0;
+ var ilen = list.length;
+
+ while (idx < ilen) {
+ if (_isArrayLike(list[idx])) {
+ value = recursive ? flatt(list[idx]) : list[idx];
+ j = 0;
+ jlen = value.length;
+ while (j < jlen) {
+ result[result.length] = value[j];
+ j += 1;
+ }
+ } else {
+ result[result.length] = list[idx];
+ }
+ idx += 1;
+ }
+ return result;
+ };
}
-});
-/**
- * Wraps a function of any arity (including nullary) in a function that accepts
- * exactly `n` parameters. Any extraneous parameters will not be passed to the
- * supplied function.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig Number -> (* -> a) -> (* -> a)
- * @param {Number} n The desired arity of the new function.
- * @param {Function} fn The function to wrap.
- * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
- * arity `n`.
- * @see R.binary, R.unary
- * @example
- *
- * const takesTwoArgs = (a, b) => [a, b];
- *
- * takesTwoArgs.length; //=> 2
- * takesTwoArgs(1, 2); //=> [1, 2]
- *
- * const takesOneArg = R.nAry(1, takesTwoArgs);
- * takesOneArg.length; //=> 1
- * // Only `n` arguments are passed to the wrapped function
- * takesOneArg(1, 2); //=> [1, undefined]
- * @symb R.nAry(0, f)(a, b) = f()
- * @symb R.nAry(1, f)(a, b) = f(a)
- * @symb R.nAry(2, f)(a, b) = f(a, b)
- */
-var nAry = _curry2(function nAry(n, fn) {
- switch (n) {
- case 0: return function() {return fn.call(this);};
- case 1: return function(a0) {return fn.call(this, a0);};
- case 2: return function(a0, a1) {return fn.call(this, a0, a1);};
- case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);};
- case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);};
- case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);};
- case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);};
- case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);};
- case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);};
- case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);};
- case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);};
- default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten');
+ function _forceReduced(x) {
+ return {
+ '@@transducer/value': x,
+ '@@transducer/reduced': true,
+ };
}
-});
-/**
- * Wraps a function of any arity (including nullary) in a function that accepts
- * exactly 2 parameters. Any extraneous parameters will not be passed to the
- * supplied function.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category Function
- * @sig (* -> c) -> (a, b -> c)
- * @param {Function} fn The function to wrap.
- * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
- * arity 2.
- * @see R.nAry, R.unary
- * @example
- *
- * const takesThreeArgs = function(a, b, c) {
- * return [a, b, c];
- * };
- * takesThreeArgs.length; //=> 3
- * takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
- *
- * const takesTwoArgs = R.binary(takesThreeArgs);
- * takesTwoArgs.length; //=> 2
- * // Only 2 arguments are passed to the wrapped function
- * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
- * @symb R.binary(f)(a, b, c) = f(a, b)
- */
-var binary = _curry1(function binary(fn) {
- return nAry(2, fn);
-});
+ var preservingReduced = function (xf) {
+ return {
+ '@@transducer/init': _xfBase.init,
+ '@@transducer/result': function (result) {
+ return xf['@@transducer/result'](result);
+ },
+ '@@transducer/step': function (result, input) {
+ var ret = xf['@@transducer/step'](result, input);
+ return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret;
+ },
+ };
+ };
-function _isFunction(x) {
- return Object.prototype.toString.call(x) === '[object Function]';
-}
+ var _flatCat = function _xcat(xf) {
+ var rxf = preservingReduced(xf);
+ return {
+ '@@transducer/init': _xfBase.init,
+ '@@transducer/result': function (result) {
+ return rxf['@@transducer/result'](result);
+ },
+ '@@transducer/step': function (result, input) {
+ return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input);
+ },
+ };
+ };
-/**
- * "lifts" a function to be the specified arity, so that it may "map over" that
- * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Function
- * @sig Number -> (*... -> *) -> ([*]... -> [*])
- * @param {Function} fn The function to lift into higher context
- * @return {Function} The lifted function.
- * @see R.lift, R.ap
- * @example
- *
- * const madd3 = R.liftN(3, (...args) => R.sum(args));
- * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
- */
-var liftN = _curry2(function liftN(arity, fn) {
- var lifted = curryN(arity, fn);
- return curryN(arity, function() {
- return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
+ var _xchain = _curry2(function _xchain(f, xf) {
+ return map(f, _flatCat(xf));
});
-});
-
-/**
- * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other
- * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Function
- * @sig (*... -> *) -> ([*]... -> [*])
- * @param {Function} fn The function to lift into higher context
- * @return {Function} The lifted function.
- * @see R.liftN
- * @example
- *
- * const madd3 = R.lift((a, b, c) => a + b + c);
- *
- * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
- *
- * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e);
- *
- * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24]
- */
-var lift = _curry1(function lift(fn) {
- return liftN(fn.length, fn);
-});
-/**
- * A function which calls the two provided functions and returns the `&&`
- * of the results.
- * It returns the result of the first function if it is false-y and the result
- * of the second function otherwise. Note that this is short-circuited,
- * meaning that the second function will not be invoked if the first returns a
- * false-y value.
- *
- * In addition to functions, `R.both` also accepts any fantasy-land compatible
- * applicative functor.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category Logic
- * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
- * @param {Function} f A predicate
- * @param {Function} g Another predicate
- * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together.
- * @see R.and
- * @example
- *
- * const gt10 = R.gt(R.__, 10)
- * const lt20 = R.lt(R.__, 20)
- * const f = R.both(gt10, lt20);
- * f(15); //=> true
- * f(30); //=> false
- *
- * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false)
- * R.both([false, false, 'a'], [11]); //=> [false, false, 11]
- */
-var both = _curry2(function both(f, g) {
- return _isFunction(f) ?
- function _both() {
- return f.apply(this, arguments) && g.apply(this, arguments);
- } :
- lift(and)(f, g);
-});
+ /**
+ * `chain` maps a function over a list and concatenates the results. `chain`
+ * is also known as `flatMap` in some libraries.
+ *
+ * Dispatches to the `chain` method of the second argument, if present,
+ * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain).
+ *
+ * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category List
+ * @sig Chain m => (a -> m b) -> m a -> m b
+ * @param {Function} fn The function to map with
+ * @param {Array} list The list to map over
+ * @return {Array} The result of flat-mapping `list` with `fn`
+ * @example
+ *
+ * const duplicate = n => [n, n];
+ * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]
+ *
+ * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
+ */
+ var chain = _curry2(
+ _dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) {
+ if (typeof monad === 'function') {
+ return function (x) {
+ return fn(monad(x))(x);
+ };
+ }
+ return _makeFlat(false)(map(fn, monad));
+ })
+ );
-/**
- * Returns a curried equivalent of the provided function. The curried function
- * has two unusual capabilities. First, its arguments needn't be provided one
- * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the
- * following are equivalent:
- *
- * - `g(1)(2)(3)`
- * - `g(1)(2, 3)`
- * - `g(1, 2)(3)`
- * - `g(1, 2, 3)`
- *
- * Secondly, the special placeholder value [`R.__`](#__) may be used to specify
- * "gaps", allowing partial application of any combination of arguments,
- * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
- * the following are equivalent:
- *
- * - `g(1, 2, 3)`
- * - `g(_, 2, 3)(1)`
- * - `g(_, _, 3)(1)(2)`
- * - `g(_, _, 3)(1, 2)`
- * - `g(_, 2)(1)(3)`
- * - `g(_, 2)(1, 3)`
- * - `g(_, 2)(_, 3)(1)`
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig (* -> a) -> (* -> a)
- * @param {Function} fn The function to curry.
- * @return {Function} A new, curried function.
- * @see R.curryN, R.partial
- * @example
- *
- * const addFourNumbers = (a, b, c, d) => a + b + c + d;
- *
- * const curriedAddFourNumbers = R.curry(addFourNumbers);
- * const f = curriedAddFourNumbers(1, 2);
- * const g = f(3);
- * g(4); //=> 10
- */
-var curry = _curry1(function curry(fn) {
- return curryN(fn.length, fn);
-});
+ /**
+ * Restricts a number to be within a range.
+ *
+ * Also works for other ordered types such as Strings and Dates.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.20.0
+ * @category Relation
+ * @sig Ord a => a -> a -> a -> a
+ * @param {Number} minimum The lower limit of the clamp (inclusive)
+ * @param {Number} maximum The upper limit of the clamp (inclusive)
+ * @param {Number} value Value to be clamped
+ * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise
+ * @example
+ *
+ * R.clamp(1, 10, -5) // => 1
+ * R.clamp(1, 10, 15) // => 10
+ * R.clamp(1, 10, 4) // => 4
+ */
+ var clamp = _curry3(function clamp(min, max, value) {
+ if (min > max) {
+ throw new Error('min must not be greater than max in clamp(min, max, value)');
+ }
+ return value < min ? min : value > max ? max : value;
+ });
-/**
- * Returns the result of calling its first argument with the remaining
- * arguments. This is occasionally useful as a converging function for
- * [`R.converge`](#converge): the first branch can produce a function while the
- * remaining branches produce values to be passed to that function as its
- * arguments.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Function
- * @sig (*... -> a),*... -> a
- * @param {Function} fn The function to apply to the remaining arguments.
- * @param {...*} args Any number of positional arguments.
- * @return {*}
- * @see R.apply
- * @example
- *
- * R.call(R.add, 1, 2); //=> 3
- *
- * const indentN = R.pipe(R.repeat(' '),
- * R.join(''),
- * R.replace(/^(?!$)/gm));
- *
- * const format = R.converge(R.call, [
- * R.pipe(R.prop('indent'), indentN),
- * R.prop('value')
- * ]);
- *
- * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n'
- * @symb R.call(f, a, b) = f(a, b)
- */
-var call = curry(function call(fn) {
- return fn.apply(this, Array.prototype.slice.call(arguments, 1));
-});
+ function _cloneRegExp(pattern) {
+ return new RegExp(
+ pattern.source,
+ (pattern.global ? 'g' : '') +
+ (pattern.ignoreCase ? 'i' : '') +
+ (pattern.multiline ? 'm' : '') +
+ (pattern.sticky ? 'y' : '') +
+ (pattern.unicode ? 'u' : '')
+ );
+ }
-/**
- * `_makeFlat` is a helper function that returns a one-level or fully recursive
- * function based on the flag passed in.
- *
- * @private
- */
-function _makeFlat(recursive) {
- return function flatt(list) {
- var value, jlen, j;
- var result = [];
- var idx = 0;
- var ilen = list.length;
+ /**
+ * Gives a single-word string description of the (native) type of a value,
+ * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
+ * attempt to distinguish user Object types any further, reporting them all as
+ * 'Object'.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Type
+ * @sig (* -> {*}) -> String
+ * @param {*} val The value to test
+ * @return {String}
+ * @example
+ *
+ * R.type({}); //=> "Object"
+ * R.type(1); //=> "Number"
+ * R.type(false); //=> "Boolean"
+ * R.type('s'); //=> "String"
+ * R.type(null); //=> "Null"
+ * R.type([]); //=> "Array"
+ * R.type(/[A-z]/); //=> "RegExp"
+ * R.type(() => {}); //=> "Function"
+ * R.type(undefined); //=> "Undefined"
+ */
+ var type = _curry1(function type(val) {
+ return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
+ });
- while (idx < ilen) {
- if (_isArrayLike(list[idx])) {
- value = recursive ? flatt(list[idx]) : list[idx];
- j = 0;
- jlen = value.length;
- while (j < jlen) {
- result[result.length] = value[j];
- j += 1;
+ /**
+ * Copies an object.
+ *
+ * @private
+ * @param {*} value The value to be copied
+ * @param {Array} refFrom Array containing the source references
+ * @param {Array} refTo Array containing the copied source references
+ * @param {Boolean} deep Whether or not to perform deep cloning.
+ * @return {*} The copied value.
+ */
+ function _clone(value, refFrom, refTo, deep) {
+ var copy = function copy(copiedValue) {
+ var len = refFrom.length;
+ var idx = 0;
+ while (idx < len) {
+ if (value === refFrom[idx]) {
+ return refTo[idx];
}
- } else {
- result[result.length] = list[idx];
+ idx += 1;
}
- idx += 1;
+ refFrom[idx + 1] = value;
+ refTo[idx + 1] = copiedValue;
+ for (var key in value) {
+ copiedValue[key] = deep ? _clone(value[key], refFrom, refTo, true) : value[key];
+ }
+ return copiedValue;
+ };
+ switch (type(value)) {
+ case 'Object':
+ return copy({});
+ case 'Array':
+ return copy([]);
+ case 'Date':
+ return new Date(value.valueOf());
+ case 'RegExp':
+ return _cloneRegExp(value);
+ default:
+ return value;
}
- return result;
- };
-}
+ }
-function _forceReduced(x) {
- return {
- '@@transducer/value': x,
- '@@transducer/reduced': true
- };
-}
+ /**
+ * Creates a deep copy of the value which may contain (nested) `Array`s and
+ * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are
+ * assigned by reference rather than copied
+ *
+ * Dispatches to a `clone` method if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig {*} -> {*}
+ * @param {*} value The object or array to clone
+ * @return {*} A deeply cloned copy of `val`
+ * @example
+ *
+ * const objects = [{}, {}, {}];
+ * const objectsClone = R.clone(objects);
+ * objects === objectsClone; //=> false
+ * objects[0] === objectsClone[0]; //=> false
+ */
+ var clone = _curry1(function clone(value) {
+ return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, [], [], true);
+ });
-var preservingReduced = function(xf) {
- return {
- '@@transducer/init': _xfBase.init,
- '@@transducer/result': function(result) {
- return xf['@@transducer/result'](result);
- },
- '@@transducer/step': function(result, input) {
- var ret = xf['@@transducer/step'](result, input);
- return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret;
- }
- };
-};
-
-var _flatCat = function _xcat(xf) {
- var rxf = preservingReduced(xf);
- return {
- '@@transducer/init': _xfBase.init,
- '@@transducer/result': function(result) {
- return rxf['@@transducer/result'](result);
- },
- '@@transducer/step': function(result, input) {
- return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input);
- }
- };
-};
+ /**
+ * Makes a comparator function out of a function that reports whether the first
+ * element is less than the second.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig ((a, b) -> Boolean) -> ((a, b) -> Number)
+ * @param {Function} pred A predicate function of arity two which will return `true` if the first argument
+ * is less than the second, `false` otherwise
+ * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`
+ * @example
+ *
+ * const byAge = R.comparator((a, b) => a.age < b.age);
+ * const people = [
+ * { name: 'Emma', age: 70 },
+ * { name: 'Peter', age: 78 },
+ * { name: 'Mikhail', age: 62 },
+ * ];
+ * const peopleByIncreasingAge = R.sort(byAge, people);
+ * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
+ */
+ var comparator = _curry1(function comparator(pred) {
+ return function (a, b) {
+ return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
+ };
+ });
-var _xchain = _curry2(function _xchain(f, xf) {
- return map(f, _flatCat(xf));
-});
+ /**
+ * A function that returns the `!` of its argument. It will return `true` when
+ * passed false-y value, and `false` when passed a truth-y one.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Logic
+ * @sig * -> Boolean
+ * @param {*} a any value
+ * @return {Boolean} the logical inverse of passed argument.
+ * @see R.complement
+ * @example
+ *
+ * R.not(true); //=> false
+ * R.not(false); //=> true
+ * R.not(0); //=> true
+ * R.not(1); //=> false
+ */
+ var not = _curry1(function not(a) {
+ return !a;
+ });
-/**
- * `chain` maps a function over a list and concatenates the results. `chain`
- * is also known as `flatMap` in some libraries.
- *
- * Dispatches to the `chain` method of the second argument, if present,
- * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain).
- *
- * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category List
- * @sig Chain m => (a -> m b) -> m a -> m b
- * @param {Function} fn The function to map with
- * @param {Array} list The list to map over
- * @return {Array} The result of flat-mapping `list` with `fn`
- * @example
- *
- * const duplicate = n => [n, n];
- * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]
- *
- * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
- */
-var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) {
- if (typeof monad === 'function') {
- return function(x) { return fn(monad(x))(x); };
+ /**
+ * Takes a function `f` and returns a function `g` such that if called with the same arguments
+ * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`.
+ *
+ * `R.complement` may be applied to any functor
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category Logic
+ * @sig (*... -> *) -> (*... -> Boolean)
+ * @param {Function} f
+ * @return {Function}
+ * @see R.not
+ * @example
+ *
+ * const isNotNil = R.complement(R.isNil);
+ * isNil(null); //=> true
+ * isNotNil(null); //=> false
+ * isNil(7); //=> false
+ * isNotNil(7); //=> true
+ */
+ var complement = lift(not);
+
+ function _pipe(f, g) {
+ return function () {
+ return g.call(this, f.apply(this, arguments));
+ };
}
- return _makeFlat(false)(map(fn, monad));
-}));
-/**
- * Restricts a number to be within a range.
- *
- * Also works for other ordered types such as Strings and Dates.
- *
- * @func
- * @memberOf R
- * @since v0.20.0
- * @category Relation
- * @sig Ord a => a -> a -> a -> a
- * @param {Number} minimum The lower limit of the clamp (inclusive)
- * @param {Number} maximum The upper limit of the clamp (inclusive)
- * @param {Number} value Value to be clamped
- * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise
- * @example
- *
- * R.clamp(1, 10, -5) // => 1
- * R.clamp(1, 10, 15) // => 10
- * R.clamp(1, 10, 4) // => 4
- */
-var clamp = _curry3(function clamp(min, max, value) {
- if (min > max) {
- throw new Error('min must not be greater than max in clamp(min, max, value)');
+ /**
+ * This checks whether a function has a [methodname] function. If it isn't an
+ * array it will execute that function otherwise it will default to the ramda
+ * implementation.
+ *
+ * @private
+ * @param {Function} fn ramda implemtation
+ * @param {String} methodname property to check for a custom implementation
+ * @return {Object} Whatever the return value of the method is.
+ */
+ function _checkForMethod(methodname, fn) {
+ return function () {
+ var length = arguments.length;
+ if (length === 0) {
+ return fn();
+ }
+ var obj = arguments[length - 1];
+ return _isArray(obj) || typeof obj[methodname] !== 'function'
+ ? fn.apply(this, arguments)
+ : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
+ };
}
- return value < min ? min :
- value > max ? max :
- value;
-});
-function _cloneRegExp(pattern) {
- return new RegExp(pattern.source, (pattern.global ? 'g' : '') +
- (pattern.ignoreCase ? 'i' : '') +
- (pattern.multiline ? 'm' : '') +
- (pattern.sticky ? 'y' : '') +
- (pattern.unicode ? 'u' : ''));
-}
-
-/**
- * Gives a single-word string description of the (native) type of a value,
- * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
- * attempt to distinguish user Object types any further, reporting them all as
- * 'Object'.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Type
- * @sig (* -> {*}) -> String
- * @param {*} val The value to test
- * @return {String}
- * @example
- *
- * R.type({}); //=> "Object"
- * R.type(1); //=> "Number"
- * R.type(false); //=> "Boolean"
- * R.type('s'); //=> "String"
- * R.type(null); //=> "Null"
- * R.type([]); //=> "Array"
- * R.type(/[A-z]/); //=> "RegExp"
- * R.type(() => {}); //=> "Function"
- * R.type(undefined); //=> "Undefined"
- */
-var type = _curry1(function type(val) {
- return val === null ? 'Null' :
- val === undefined ? 'Undefined' :
- Object.prototype.toString.call(val).slice(8, -1);
-});
+ /**
+ * Returns the elements of the given list or string (or object with a `slice`
+ * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
+ *
+ * Dispatches to the `slice` method of the third argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.4
+ * @category List
+ * @sig Number -> Number -> [a] -> [a]
+ * @sig Number -> Number -> String -> String
+ * @param {Number} fromIndex The start index (inclusive).
+ * @param {Number} toIndex The end index (exclusive).
+ * @param {*} list
+ * @return {*}
+ * @example
+ *
+ * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
+ * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
+ * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
+ * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
+ * R.slice(0, 3, 'ramda'); //=> 'ram'
+ */
+ var slice = _curry3(
+ _checkForMethod('slice', function slice(fromIndex, toIndex, list) {
+ return Array.prototype.slice.call(list, fromIndex, toIndex);
+ })
+ );
-/**
- * Copies an object.
- *
- * @private
- * @param {*} value The value to be copied
- * @param {Array} refFrom Array containing the source references
- * @param {Array} refTo Array containing the copied source references
- * @param {Boolean} deep Whether or not to perform deep cloning.
- * @return {*} The copied value.
- */
-function _clone(value, refFrom, refTo, deep) {
- var copy = function copy(copiedValue) {
- var len = refFrom.length;
- var idx = 0;
- while (idx < len) {
- if (value === refFrom[idx]) {
- return refTo[idx];
- }
- idx += 1;
+ /**
+ * Returns all but the first element of the given list or string (or object
+ * with a `tail` method).
+ *
+ * Dispatches to the `slice` method of the first argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [a]
+ * @sig String -> String
+ * @param {*} list
+ * @return {*}
+ * @see R.head, R.init, R.last
+ * @example
+ *
+ * R.tail([1, 2, 3]); //=> [2, 3]
+ * R.tail([1, 2]); //=> [2]
+ * R.tail([1]); //=> []
+ * R.tail([]); //=> []
+ *
+ * R.tail('abc'); //=> 'bc'
+ * R.tail('ab'); //=> 'b'
+ * R.tail('a'); //=> ''
+ * R.tail(''); //=> ''
+ */
+ var tail = _curry1(_checkForMethod('tail', slice(1, Infinity)));
+
+ /**
+ * Performs left-to-right function composition. The leftmost function may have
+ * any arity; the remaining functions must be unary.
+ *
+ * In some libraries this function is named `sequence`.
+ *
+ * **Note:** The result of pipe is not automatically curried.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
+ * @param {...Function} functions
+ * @return {Function}
+ * @see R.compose
+ * @example
+ *
+ * const f = R.pipe(Math.pow, R.negate, R.inc);
+ *
+ * f(3, 4); // -(3^4) + 1
+ * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
+ */
+ function pipe() {
+ if (arguments.length === 0) {
+ throw new Error('pipe requires at least one argument');
+ }
+ return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments)));
+ }
+
+ /**
+ * Returns a new list or string with the elements or characters in reverse
+ * order.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [a]
+ * @sig String -> String
+ * @param {Array|String} list
+ * @return {Array|String}
+ * @example
+ *
+ * R.reverse([1, 2, 3]); //=> [3, 2, 1]
+ * R.reverse([1, 2]); //=> [2, 1]
+ * R.reverse([1]); //=> [1]
+ * R.reverse([]); //=> []
+ *
+ * R.reverse('abc'); //=> 'cba'
+ * R.reverse('ab'); //=> 'ba'
+ * R.reverse('a'); //=> 'a'
+ * R.reverse(''); //=> ''
+ */
+ var reverse = _curry1(function reverse(list) {
+ return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse();
+ });
+
+ /**
+ * Performs right-to-left function composition. The rightmost function may have
+ * any arity; the remaining functions must be unary.
+ *
+ * **Note:** The result of compose is not automatically curried.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z)
+ * @param {...Function} ...functions The functions to compose
+ * @return {Function}
+ * @see R.pipe
+ * @example
+ *
+ * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName
+ * const yellGreeting = R.compose(R.toUpper, classyGreeting);
+ * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"
+ *
+ * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7
+ *
+ * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b)))
+ */
+ function compose() {
+ if (arguments.length === 0) {
+ throw new Error('compose requires at least one argument');
}
- refFrom[idx + 1] = value;
- refTo[idx + 1] = copiedValue;
- for (var key in value) {
- copiedValue[key] = deep ?
- _clone(value[key], refFrom, refTo, true) : value[key];
+ return pipe.apply(this, reverse(arguments));
+ }
+
+ /**
+ * Returns the right-to-left Kleisli composition of the provided functions,
+ * each of which must return a value of a type supported by [`chain`](#chain).
+ *
+ * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Function
+ * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z)
+ * @param {...Function} ...functions The functions to compose
+ * @return {Function}
+ * @see R.pipeK
+ * @example
+ *
+ * // get :: String -> Object -> Maybe *
+ * const get = R.curry((propName, obj) => Maybe(obj[propName]))
+ *
+ * // getStateCode :: Maybe String -> Maybe String
+ * const getStateCode = R.composeK(
+ * R.compose(Maybe.of, R.toUpper),
+ * get('state'),
+ * get('address'),
+ * get('user'),
+ * );
+ * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY")
+ * getStateCode({}); //=> Maybe.Nothing()
+ * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a)))
+ */
+ function composeK() {
+ if (arguments.length === 0) {
+ throw new Error('composeK requires at least one argument');
}
- return copiedValue;
- };
- switch (type(value)) {
- case 'Object': return copy({});
- case 'Array': return copy([]);
- case 'Date': return new Date(value.valueOf());
- case 'RegExp': return _cloneRegExp(value);
- default: return value;
+ var init = Array.prototype.slice.call(arguments);
+ var last = init.pop();
+ return compose(compose.apply(this, map(chain, init)), last);
}
-}
-/**
- * Creates a deep copy of the value which may contain (nested) `Array`s and
- * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are
- * assigned by reference rather than copied
- *
- * Dispatches to a `clone` method if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig {*} -> {*}
- * @param {*} value The object or array to clone
- * @return {*} A deeply cloned copy of `val`
- * @example
- *
- * const objects = [{}, {}, {}];
- * const objectsClone = R.clone(objects);
- * objects === objectsClone; //=> false
- * objects[0] === objectsClone[0]; //=> false
- */
-var clone = _curry1(function clone(value) {
- return value != null && typeof value.clone === 'function' ?
- value.clone() :
- _clone(value, [], [], true);
-});
+ function _pipeP(f, g) {
+ return function () {
+ var ctx = this;
+ return f.apply(ctx, arguments).then(function (x) {
+ return g.call(ctx, x);
+ });
+ };
+ }
-/**
- * Makes a comparator function out of a function that reports whether the first
- * element is less than the second.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig ((a, b) -> Boolean) -> ((a, b) -> Number)
- * @param {Function} pred A predicate function of arity two which will return `true` if the first argument
- * is less than the second, `false` otherwise
- * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`
- * @example
- *
- * const byAge = R.comparator((a, b) => a.age < b.age);
- * const people = [
- * { name: 'Emma', age: 70 },
- * { name: 'Peter', age: 78 },
- * { name: 'Mikhail', age: 62 },
- * ];
- * const peopleByIncreasingAge = R.sort(byAge, people);
- * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
- */
-var comparator = _curry1(function comparator(pred) {
- return function(a, b) {
- return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
- };
-});
-
-/**
- * A function that returns the `!` of its argument. It will return `true` when
- * passed false-y value, and `false` when passed a truth-y one.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Logic
- * @sig * -> Boolean
- * @param {*} a any value
- * @return {Boolean} the logical inverse of passed argument.
- * @see R.complement
- * @example
- *
- * R.not(true); //=> false
- * R.not(false); //=> true
- * R.not(0); //=> true
- * R.not(1); //=> false
- */
-var not = _curry1(function not(a) {
- return !a;
-});
-
-/**
- * Takes a function `f` and returns a function `g` such that if called with the same arguments
- * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`.
- *
- * `R.complement` may be applied to any functor
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category Logic
- * @sig (*... -> *) -> (*... -> Boolean)
- * @param {Function} f
- * @return {Function}
- * @see R.not
- * @example
- *
- * const isNotNil = R.complement(R.isNil);
- * isNil(null); //=> true
- * isNotNil(null); //=> false
- * isNil(7); //=> false
- * isNotNil(7); //=> true
- */
-var complement = lift(not);
-
-function _pipe(f, g) {
- return function() {
- return g.call(this, f.apply(this, arguments));
- };
-}
+ /**
+ * Performs left-to-right composition of one or more Promise-returning
+ * functions. The leftmost function may have any arity; the remaining functions
+ * must be unary.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Function
+ * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z)
+ * @param {...Function} functions
+ * @return {Function}
+ * @see R.composeP
+ * @example
+ *
+ * // followersForUser :: String -> Promise [User]
+ * const followersForUser = R.pipeP(db.getUserById, db.getFollowers);
+ */
+ function pipeP() {
+ if (arguments.length === 0) {
+ throw new Error('pipeP requires at least one argument');
+ }
+ return _arity(arguments[0].length, reduce(_pipeP, arguments[0], tail(arguments)));
+ }
+
+ /**
+ * Performs right-to-left composition of one or more Promise-returning
+ * functions. The rightmost function may have any arity; the remaining
+ * functions must be unary.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Function
+ * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z)
+ * @param {...Function} functions The functions to compose
+ * @return {Function}
+ * @see R.pipeP
+ * @example
+ *
+ * const db = {
+ * users: {
+ * JOE: {
+ * name: 'Joe',
+ * followers: ['STEVE', 'SUZY']
+ * }
+ * }
+ * }
+ *
+ * // We'll pretend to do a db lookup which returns a promise
+ * const lookupUser = (userId) => Promise.resolve(db.users[userId])
+ * const lookupFollowers = (user) => Promise.resolve(user.followers)
+ * lookupUser('JOE').then(lookupFollowers)
+ *
+ * // followersForUser :: String -> Promise [UserId]
+ * const followersForUser = R.composeP(lookupFollowers, lookupUser);
+ * followersForUser('JOE').then(followers => console.log('Followers:', followers))
+ * // Followers: ["STEVE","SUZY"]
+ */
+ function composeP() {
+ if (arguments.length === 0) {
+ throw new Error('composeP requires at least one argument');
+ }
+ return pipeP.apply(this, reverse(arguments));
+ }
+
+ /**
+ * Returns the nth element of the given list or string. If n is negative the
+ * element at index length + n is returned.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Number -> [a] -> a | Undefined
+ * @sig Number -> String -> String
+ * @param {Number} offset
+ * @param {*} list
+ * @return {*}
+ * @example
+ *
+ * const list = ['foo', 'bar', 'baz', 'quux'];
+ * R.nth(1, list); //=> 'bar'
+ * R.nth(-1, list); //=> 'quux'
+ * R.nth(-99, list); //=> undefined
+ *
+ * R.nth(2, 'abc'); //=> 'c'
+ * R.nth(3, 'abc'); //=> ''
+ * @symb R.nth(-1, [a, b, c]) = c
+ * @symb R.nth(0, [a, b, c]) = a
+ * @symb R.nth(1, [a, b, c]) = b
+ */
+ var nth = _curry2(function nth(offset, list) {
+ var idx = offset < 0 ? list.length + offset : offset;
+ return _isString(list) ? list.charAt(idx) : list[idx];
+ });
-/**
- * This checks whether a function has a [methodname] function. If it isn't an
- * array it will execute that function otherwise it will default to the ramda
- * implementation.
- *
- * @private
- * @param {Function} fn ramda implemtation
- * @param {String} methodname property to check for a custom implementation
- * @return {Object} Whatever the return value of the method is.
- */
-function _checkForMethod(methodname, fn) {
- return function() {
- var length = arguments.length;
- if (length === 0) {
- return fn();
+ /**
+ * Returns the first element of the given list or string. In some libraries
+ * this function is named `first`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> a | Undefined
+ * @sig String -> String
+ * @param {Array|String} list
+ * @return {*}
+ * @see R.tail, R.init, R.last
+ * @example
+ *
+ * R.head(['fi', 'fo', 'fum']); //=> 'fi'
+ * R.head([]); //=> undefined
+ *
+ * R.head('abc'); //=> 'a'
+ * R.head(''); //=> ''
+ */
+ var head = nth(0);
+
+ function _identity(x) {
+ return x;
+ }
+
+ /**
+ * A function that does nothing but return the parameter supplied to it. Good
+ * as a default or placeholder function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig a -> a
+ * @param {*} x The value to return.
+ * @return {*} The input value, `x`.
+ * @example
+ *
+ * R.identity(1); //=> 1
+ *
+ * const obj = {};
+ * R.identity(obj) === obj; //=> true
+ * @symb R.identity(a) = a
+ */
+ var identity = _curry1(_identity);
+
+ /**
+ * Performs left-to-right function composition using transforming function. The leftmost function may have
+ * any arity; the remaining functions must be unary.
+ *
+ * **Note:** The result of pipeWith is not automatically curried.
+ *
+ * @func
+ * @memberOf R
+ * @category Function
+ * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z)
+ * @param {...Function} functions
+ * @return {Function}
+ * @see R.composeWith, R.pipe
+ * @example
+ *
+ * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
+ * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])
+ *
+ * f(3, 4); // -(3^4) + 1
+ * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, f(g, ...args)))
+ */
+ var pipeWith = _curry2(function pipeWith(xf, list) {
+ if (list.length <= 0) {
+ return identity;
}
- var obj = arguments[length - 1];
- return (_isArray(obj) || typeof obj[methodname] !== 'function') ?
- fn.apply(this, arguments) :
- obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
- };
-}
-/**
- * Returns the elements of the given list or string (or object with a `slice`
- * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
- *
- * Dispatches to the `slice` method of the third argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.4
- * @category List
- * @sig Number -> Number -> [a] -> [a]
- * @sig Number -> Number -> String -> String
- * @param {Number} fromIndex The start index (inclusive).
- * @param {Number} toIndex The end index (exclusive).
- * @param {*} list
- * @return {*}
- * @example
- *
- * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
- * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
- * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
- * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
- * R.slice(0, 3, 'ramda'); //=> 'ram'
- */
-var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) {
- return Array.prototype.slice.call(list, fromIndex, toIndex);
-}));
+ const headList = head(list);
+ const tailList = tail(list);
-/**
- * Returns all but the first element of the given list or string (or object
- * with a `tail` method).
- *
- * Dispatches to the `slice` method of the first argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [a]
- * @sig String -> String
- * @param {*} list
- * @return {*}
- * @see R.head, R.init, R.last
- * @example
- *
- * R.tail([1, 2, 3]); //=> [2, 3]
- * R.tail([1, 2]); //=> [2]
- * R.tail([1]); //=> []
- * R.tail([]); //=> []
- *
- * R.tail('abc'); //=> 'bc'
- * R.tail('ab'); //=> 'b'
- * R.tail('a'); //=> ''
- * R.tail(''); //=> ''
- */
-var tail = _curry1(_checkForMethod('tail', slice(1, Infinity)));
+ return _arity(headList.length, function () {
+ return _reduce(
+ function (result, f) {
+ return xf.call(this, f, result);
+ },
+ headList.apply(this, arguments),
+ tailList
+ );
+ });
+ });
-/**
- * Performs left-to-right function composition. The leftmost function may have
- * any arity; the remaining functions must be unary.
- *
- * In some libraries this function is named `sequence`.
- *
- * **Note:** The result of pipe is not automatically curried.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
- * @param {...Function} functions
- * @return {Function}
- * @see R.compose
- * @example
- *
- * const f = R.pipe(Math.pow, R.negate, R.inc);
- *
- * f(3, 4); // -(3^4) + 1
- * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
- */
-function pipe() {
- if (arguments.length === 0) {
- throw new Error('pipe requires at least one argument');
+ /**
+ * Performs right-to-left function composition using transforming function. The rightmost function may have
+ * any arity; the remaining functions must be unary.
+ *
+ * **Note:** The result of compose is not automatically curried.
+ *
+ * @func
+ * @memberOf R
+ * @category Function
+ * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z)
+ * @param {...Function} ...functions The functions to compose
+ * @return {Function}
+ * @see R.compose, R.pipeWith
+ * @example
+ *
+ * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));
+ *
+ * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2
+ * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> null
+ *
+ * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, f(i, ...args)))
+ */
+ var composeWith = _curry2(function composeWith(xf, list) {
+ return pipeWith.apply(this, [xf, reverse(list)]);
+ });
+
+ function _arrayFromIterator(iter) {
+ var list = [];
+ var next;
+ while (!(next = iter.next()).done) {
+ list.push(next.value);
+ }
+ return list;
}
- return _arity(arguments[0].length,
- reduce(_pipe, arguments[0], tail(arguments)));
-}
-/**
- * Returns a new list or string with the elements or characters in reverse
- * order.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [a]
- * @sig String -> String
- * @param {Array|String} list
- * @return {Array|String}
- * @example
- *
- * R.reverse([1, 2, 3]); //=> [3, 2, 1]
- * R.reverse([1, 2]); //=> [2, 1]
- * R.reverse([1]); //=> [1]
- * R.reverse([]); //=> []
- *
- * R.reverse('abc'); //=> 'cba'
- * R.reverse('ab'); //=> 'ba'
- * R.reverse('a'); //=> 'a'
- * R.reverse(''); //=> ''
- */
-var reverse = _curry1(function reverse(list) {
- return _isString(list) ? list.split('').reverse().join('') :
- Array.prototype.slice.call(list, 0).reverse();
-});
+ function _includesWith(pred, x, list) {
+ var idx = 0;
+ var len = list.length;
-/**
- * Performs right-to-left function composition. The rightmost function may have
- * any arity; the remaining functions must be unary.
- *
- * **Note:** The result of compose is not automatically curried.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z)
- * @param {...Function} ...functions The functions to compose
- * @return {Function}
- * @see R.pipe
- * @example
- *
- * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName
- * const yellGreeting = R.compose(R.toUpper, classyGreeting);
- * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"
- *
- * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7
- *
- * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b)))
- */
-function compose() {
- if (arguments.length === 0) {
- throw new Error('compose requires at least one argument');
+ while (idx < len) {
+ if (pred(x, list[idx])) {
+ return true;
+ }
+ idx += 1;
+ }
+ return false;
}
- return pipe.apply(this, reverse(arguments));
-}
-/**
- * Returns the right-to-left Kleisli composition of the provided functions,
- * each of which must return a value of a type supported by [`chain`](#chain).
- *
- * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Function
- * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z)
- * @param {...Function} ...functions The functions to compose
- * @return {Function}
- * @see R.pipeK
- * @example
- *
- * // get :: String -> Object -> Maybe *
- * const get = R.curry((propName, obj) => Maybe(obj[propName]))
- *
- * // getStateCode :: Maybe String -> Maybe String
- * const getStateCode = R.composeK(
- * R.compose(Maybe.of, R.toUpper),
- * get('state'),
- * get('address'),
- * get('user'),
- * );
- * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY")
- * getStateCode({}); //=> Maybe.Nothing()
- * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a)))
- */
-function composeK() {
- if (arguments.length === 0) {
- throw new Error('composeK requires at least one argument');
+ function _functionName(f) {
+ // String(x => x) evaluates to "x => x", so the pattern may not match.
+ var match = String(f).match(/^function (\w*)/);
+ return match == null ? '' : match[1];
}
- var init = Array.prototype.slice.call(arguments);
- var last = init.pop();
- return compose(compose.apply(this, map(chain, init)), last);
-}
-
-function _pipeP(f, g) {
- return function() {
- var ctx = this;
- return f.apply(ctx, arguments).then(function(x) {
- return g.call(ctx, x);
- });
- };
-}
-/**
- * Performs left-to-right composition of one or more Promise-returning
- * functions. The leftmost function may have any arity; the remaining functions
- * must be unary.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Function
- * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z)
- * @param {...Function} functions
- * @return {Function}
- * @see R.composeP
- * @example
- *
- * // followersForUser :: String -> Promise [User]
- * const followersForUser = R.pipeP(db.getUserById, db.getFollowers);
- */
-function pipeP() {
- if (arguments.length === 0) {
- throw new Error('pipeP requires at least one argument');
- }
- return _arity(arguments[0].length,
- reduce(_pipeP, arguments[0], tail(arguments)));
-}
-
-/**
- * Performs right-to-left composition of one or more Promise-returning
- * functions. The rightmost function may have any arity; the remaining
- * functions must be unary.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Function
- * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z)
- * @param {...Function} functions The functions to compose
- * @return {Function}
- * @see R.pipeP
- * @example
- *
- * const db = {
- * users: {
- * JOE: {
- * name: 'Joe',
- * followers: ['STEVE', 'SUZY']
- * }
- * }
- * }
- *
- * // We'll pretend to do a db lookup which returns a promise
- * const lookupUser = (userId) => Promise.resolve(db.users[userId])
- * const lookupFollowers = (user) => Promise.resolve(user.followers)
- * lookupUser('JOE').then(lookupFollowers)
- *
- * // followersForUser :: String -> Promise [UserId]
- * const followersForUser = R.composeP(lookupFollowers, lookupUser);
- * followersForUser('JOE').then(followers => console.log('Followers:', followers))
- * // Followers: ["STEVE","SUZY"]
- */
-function composeP() {
- if (arguments.length === 0) {
- throw new Error('composeP requires at least one argument');
+ // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
+ function _objectIs(a, b) {
+ // SameValue algorithm
+ if (a === b) {
+ // Steps 1-5, 7-10
+ // Steps 6.b-6.e: +0 != -0
+ return a !== 0 || 1 / a === 1 / b;
+ } else {
+ // Step 6.a: NaN == NaN
+ return a !== a && b !== b;
+ }
}
- return pipeP.apply(this, reverse(arguments));
-}
-/**
- * Returns the nth element of the given list or string. If n is negative the
- * element at index length + n is returned.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Number -> [a] -> a | Undefined
- * @sig Number -> String -> String
- * @param {Number} offset
- * @param {*} list
- * @return {*}
- * @example
- *
- * const list = ['foo', 'bar', 'baz', 'quux'];
- * R.nth(1, list); //=> 'bar'
- * R.nth(-1, list); //=> 'quux'
- * R.nth(-99, list); //=> undefined
- *
- * R.nth(2, 'abc'); //=> 'c'
- * R.nth(3, 'abc'); //=> ''
- * @symb R.nth(-1, [a, b, c]) = c
- * @symb R.nth(0, [a, b, c]) = a
- * @symb R.nth(1, [a, b, c]) = b
- */
-var nth = _curry2(function nth(offset, list) {
- var idx = offset < 0 ? list.length + offset : offset;
- return _isString(list) ? list.charAt(idx) : list[idx];
-});
+ var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
-/**
- * Returns the first element of the given list or string. In some libraries
- * this function is named `first`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> a | Undefined
- * @sig String -> String
- * @param {Array|String} list
- * @return {*}
- * @see R.tail, R.init, R.last
- * @example
- *
- * R.head(['fi', 'fo', 'fum']); //=> 'fi'
- * R.head([]); //=> undefined
- *
- * R.head('abc'); //=> 'a'
- * R.head(''); //=> ''
- */
-var head = nth(0);
+ /**
+ * private _uniqContentEquals function.
+ * That function is checking equality of 2 iterator contents with 2 assumptions
+ * - iterators lengths are the same
+ * - iterators values are unique
+ *
+ * false-positive result will be returned for comparision of, e.g.
+ * - [1,2,3] and [1,2,3,4]
+ * - [1,1,1] and [1,2,3]
+ * */
-function _identity(x) { return x; }
+ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
+ var a = _arrayFromIterator(aIterator);
+ var b = _arrayFromIterator(bIterator);
-/**
- * A function that does nothing but return the parameter supplied to it. Good
- * as a default or placeholder function.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig a -> a
- * @param {*} x The value to return.
- * @return {*} The input value, `x`.
- * @example
- *
- * R.identity(1); //=> 1
- *
- * const obj = {};
- * R.identity(obj) === obj; //=> true
- * @symb R.identity(a) = a
- */
-var identity = _curry1(_identity);
+ function eq(_a, _b) {
+ return _equals(_a, _b, stackA.slice(), stackB.slice());
+ }
-/**
- * Performs left-to-right function composition using transforming function. The leftmost function may have
- * any arity; the remaining functions must be unary.
- *
- * **Note:** The result of pipeWith is not automatically curried.
- *
- * @func
- * @memberOf R
- * @category Function
- * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z)
- * @param {...Function} functions
- * @return {Function}
- * @see R.composeWith, R.pipe
- * @example
- *
- * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
- * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])
- *
- * f(3, 4); // -(3^4) + 1
- * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, f(g, ...args)))
- */
-var pipeWith = _curry2(function pipeWith(xf, list) {
- if (list.length <= 0) {
- return identity;
+ // if *a* array contains any element that is not included in *b*
+ return !_includesWith(
+ function (b, aItem) {
+ return !_includesWith(eq, aItem, b);
+ },
+ b,
+ a
+ );
}
- const headList = head(list);
- const tailList = tail(list);
+ function _equals(a, b, stackA, stackB) {
+ if (_objectIs$1(a, b)) {
+ return true;
+ }
- return _arity(headList.length, function() {
- return _reduce(
- function(result, f) {
- return xf.call(this, f, result);
- },
- headList.apply(this, arguments),
- tailList
- );
- });
-});
+ var typeA = type(a);
-/**
- * Performs right-to-left function composition using transforming function. The rightmost function may have
- * any arity; the remaining functions must be unary.
- *
- * **Note:** The result of compose is not automatically curried.
- *
- * @func
- * @memberOf R
- * @category Function
- * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z)
- * @param {...Function} ...functions The functions to compose
- * @return {Function}
- * @see R.compose, R.pipeWith
- * @example
- *
- * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));
- *
- * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2
- * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> null
- *
- * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, f(i, ...args)))
- */
-var composeWith = _curry2(function composeWith(xf, list) {
- return pipeWith.apply(this, [xf, reverse(list)]);
-});
+ if (typeA !== type(b)) {
+ return false;
+ }
-function _arrayFromIterator(iter) {
- var list = [];
- var next;
- while (!(next = iter.next()).done) {
- list.push(next.value);
- }
- return list;
-}
+ if (a == null || b == null) {
+ return false;
+ }
-function _includesWith(pred, x, list) {
- var idx = 0;
- var len = list.length;
+ if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
+ return (
+ typeof a['fantasy-land/equals'] === 'function' &&
+ a['fantasy-land/equals'](b) &&
+ typeof b['fantasy-land/equals'] === 'function' &&
+ b['fantasy-land/equals'](a)
+ );
+ }
- while (idx < len) {
- if (pred(x, list[idx])) {
- return true;
+ if (typeof a.equals === 'function' || typeof b.equals === 'function') {
+ return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
}
- idx += 1;
- }
- return false;
-}
-
-function _functionName(f) {
- // String(x => x) evaluates to "x => x", so the pattern may not match.
- var match = String(f).match(/^function (\w*)/);
- return match == null ? '' : match[1];
-}
-
-// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
-function _objectIs(a, b) {
- // SameValue algorithm
- if (a === b) { // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return a !== 0 || 1 / a === 1 / b;
- } else {
- // Step 6.a: NaN == NaN
- return a !== a && b !== b;
- }
-}
-var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
+ switch (typeA) {
+ case 'Arguments':
+ case 'Array':
+ case 'Object':
+ if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
+ return a === b;
+ }
+ break;
+ case 'Boolean':
+ case 'Number':
+ case 'String':
+ if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
+ return false;
+ }
+ break;
+ case 'Date':
+ if (!_objectIs$1(a.valueOf(), b.valueOf())) {
+ return false;
+ }
+ break;
+ case 'Error':
+ return a.name === b.name && a.message === b.message;
+ case 'RegExp':
+ if (
+ !(
+ a.source === b.source &&
+ a.global === b.global &&
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline &&
+ a.sticky === b.sticky &&
+ a.unicode === b.unicode
+ )
+ ) {
+ return false;
+ }
+ break;
+ }
-/**
- * private _uniqContentEquals function.
- * That function is checking equality of 2 iterator contents with 2 assumptions
- * - iterators lengths are the same
- * - iterators values are unique
- *
- * false-positive result will be returned for comparision of, e.g.
- * - [1,2,3] and [1,2,3,4]
- * - [1,1,1] and [1,2,3]
- * */
+ var idx = stackA.length - 1;
+ while (idx >= 0) {
+ if (stackA[idx] === a) {
+ return stackB[idx] === b;
+ }
+ idx -= 1;
+ }
-function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
- var a = _arrayFromIterator(aIterator);
- var b = _arrayFromIterator(bIterator);
+ switch (typeA) {
+ case 'Map':
+ if (a.size !== b.size) {
+ return false;
+ }
- function eq(_a, _b) {
- return _equals(_a, _b, stackA.slice(), stackB.slice());
- }
+ return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
+ case 'Set':
+ if (a.size !== b.size) {
+ return false;
+ }
- // if *a* array contains any element that is not included in *b*
- return !_includesWith(function(b, aItem) {
- return !_includesWith(eq, aItem, b);
- }, b, a);
-}
+ return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
+ case 'Arguments':
+ case 'Array':
+ case 'Object':
+ case 'Boolean':
+ case 'Number':
+ case 'String':
+ case 'Date':
+ case 'Error':
+ case 'RegExp':
+ case 'Int8Array':
+ case 'Uint8Array':
+ case 'Uint8ClampedArray':
+ case 'Int16Array':
+ case 'Uint16Array':
+ case 'Int32Array':
+ case 'Uint32Array':
+ case 'Float32Array':
+ case 'Float64Array':
+ case 'ArrayBuffer':
+ break;
+ default:
+ // Values of other types are only equal if identical.
+ return false;
+ }
-function _equals(a, b, stackA, stackB) {
- if (_objectIs$1(a, b)) {
- return true;
- }
+ var keysA = keys(a);
+ if (keysA.length !== keys(b).length) {
+ return false;
+ }
- var typeA = type(a);
+ var extendedStackA = stackA.concat([a]);
+ var extendedStackB = stackB.concat([b]);
- if (typeA !== type(b)) {
- return false;
+ idx = keysA.length - 1;
+ while (idx >= 0) {
+ var key = keysA[idx];
+ if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
+ return false;
+ }
+ idx -= 1;
+ }
+ return true;
}
- if (a == null || b == null) {
- return false;
- }
+ /**
+ * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
+ * cyclical data structures.
+ *
+ * Dispatches symmetrically to the `equals` methods of both arguments, if
+ * present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.15.0
+ * @category Relation
+ * @sig a -> b -> Boolean
+ * @param {*} a
+ * @param {*} b
+ * @return {Boolean}
+ * @example
+ *
+ * R.equals(1, 1); //=> true
+ * R.equals(1, '1'); //=> false
+ * R.equals([1, 2, 3], [1, 2, 3]); //=> true
+ *
+ * const a = {}; a.v = a;
+ * const b = {}; b.v = b;
+ * R.equals(a, b); //=> true
+ */
+ var equals = _curry2(function equals(a, b) {
+ return _equals(a, b, [], []);
+ });
- if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
- return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) &&
- typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
- }
+ function _indexOf(list, a, idx) {
+ var inf, item;
+ // Array.prototype.indexOf doesn't exist below IE9
+ if (typeof list.indexOf === 'function') {
+ switch (typeof a) {
+ case 'number':
+ if (a === 0) {
+ // manually crawl the list to distinguish between +0 and -0
+ inf = 1 / a;
+ while (idx < list.length) {
+ item = list[idx];
+ if (item === 0 && 1 / item === inf) {
+ return idx;
+ }
+ idx += 1;
+ }
+ return -1;
+ } else if (a !== a) {
+ // NaN
+ while (idx < list.length) {
+ item = list[idx];
+ if (typeof item === 'number' && item !== item) {
+ return idx;
+ }
+ idx += 1;
+ }
+ return -1;
+ }
+ // non-zero numbers can utilise Set
+ return list.indexOf(a, idx);
- if (typeof a.equals === 'function' || typeof b.equals === 'function') {
- return typeof a.equals === 'function' && a.equals(b) &&
- typeof b.equals === 'function' && b.equals(a);
- }
+ // all these types can utilise Set
+ case 'string':
+ case 'boolean':
+ case 'function':
+ case 'undefined':
+ return list.indexOf(a, idx);
- switch (typeA) {
- case 'Arguments':
- case 'Array':
- case 'Object':
- if (typeof a.constructor === 'function' &&
- _functionName(a.constructor) === 'Promise') {
- return a === b;
- }
- break;
- case 'Boolean':
- case 'Number':
- case 'String':
- if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
- return false;
- }
- break;
- case 'Date':
- if (!_objectIs$1(a.valueOf(), b.valueOf())) {
- return false;
+ case 'object':
+ if (a === null) {
+ // null can utilise Set
+ return list.indexOf(a, idx);
+ }
}
- break;
- case 'Error':
- return a.name === b.name && a.message === b.message;
- case 'RegExp':
- if (!(a.source === b.source &&
- a.global === b.global &&
- a.ignoreCase === b.ignoreCase &&
- a.multiline === b.multiline &&
- a.sticky === b.sticky &&
- a.unicode === b.unicode)) {
- return false;
+ }
+ // anything else not covered above, defer to R.equals
+ while (idx < list.length) {
+ if (equals(list[idx], a)) {
+ return idx;
}
- break;
- }
-
- var idx = stackA.length - 1;
- while (idx >= 0) {
- if (stackA[idx] === a) {
- return stackB[idx] === b;
+ idx += 1;
}
- idx -= 1;
+ return -1;
}
- switch (typeA) {
- case 'Map':
- if (a.size !== b.size) {
- return false;
- }
+ function _includes(a, list) {
+ return _indexOf(list, a, 0) >= 0;
+ }
- return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
- case 'Set':
- if (a.size !== b.size) {
- return false;
- }
+ function _quote(s) {
+ var escaped = s
+ .replace(/\\/g, '\\\\')
+ .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace
+ .replace(/\f/g, '\\f')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/\t/g, '\\t')
+ .replace(/\v/g, '\\v')
+ .replace(/\0/g, '\\0');
- return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
- case 'Arguments':
- case 'Array':
- case 'Object':
- case 'Boolean':
- case 'Number':
- case 'String':
- case 'Date':
- case 'Error':
- case 'RegExp':
- case 'Int8Array':
- case 'Uint8Array':
- case 'Uint8ClampedArray':
- case 'Int16Array':
- case 'Uint16Array':
- case 'Int32Array':
- case 'Uint32Array':
- case 'Float32Array':
- case 'Float64Array':
- case 'ArrayBuffer':
- break;
- default:
- // Values of other types are only equal if identical.
- return false;
+ return '"' + escaped.replace(/"/g, '\\"') + '"';
}
- var keysA = keys(a);
- if (keysA.length !== keys(b).length) {
- return false;
+ /**
+ * Polyfill from .
+ */
+ var pad = function pad(n) {
+ return (n < 10 ? '0' : '') + n;
+ };
+
+ var _toISOString =
+ typeof Date.prototype.toISOString === 'function'
+ ? function _toISOString(d) {
+ return d.toISOString();
+ }
+ : function _toISOString(d) {
+ return (
+ d.getUTCFullYear() +
+ '-' +
+ pad(d.getUTCMonth() + 1) +
+ '-' +
+ pad(d.getUTCDate()) +
+ 'T' +
+ pad(d.getUTCHours()) +
+ ':' +
+ pad(d.getUTCMinutes()) +
+ ':' +
+ pad(d.getUTCSeconds()) +
+ '.' +
+ (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
+ 'Z'
+ );
+ };
+
+ function _complement(f) {
+ return function () {
+ return !f.apply(this, arguments);
+ };
}
- var extendedStackA = stackA.concat([a]);
- var extendedStackB = stackB.concat([b]);
+ function _filter(fn, list) {
+ var idx = 0;
+ var len = list.length;
+ var result = [];
- idx = keysA.length - 1;
- while (idx >= 0) {
- var key = keysA[idx];
- if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
- return false;
+ while (idx < len) {
+ if (fn(list[idx])) {
+ result[result.length] = list[idx];
+ }
+ idx += 1;
}
- idx -= 1;
+ return result;
}
- return true;
-}
-/**
- * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
- * cyclical data structures.
- *
- * Dispatches symmetrically to the `equals` methods of both arguments, if
- * present.
- *
- * @func
- * @memberOf R
- * @since v0.15.0
- * @category Relation
- * @sig a -> b -> Boolean
- * @param {*} a
- * @param {*} b
- * @return {Boolean}
- * @example
- *
- * R.equals(1, 1); //=> true
- * R.equals(1, '1'); //=> false
- * R.equals([1, 2, 3], [1, 2, 3]); //=> true
- *
- * const a = {}; a.v = a;
- * const b = {}; b.v = b;
- * R.equals(a, b); //=> true
- */
-var equals = _curry2(function equals(a, b) {
- return _equals(a, b, [], []);
-});
+ function _isObject(x) {
+ return Object.prototype.toString.call(x) === '[object Object]';
+ }
-function _indexOf(list, a, idx) {
- var inf, item;
- // Array.prototype.indexOf doesn't exist below IE9
- if (typeof list.indexOf === 'function') {
- switch (typeof a) {
- case 'number':
- if (a === 0) {
- // manually crawl the list to distinguish between +0 and -0
- inf = 1 / a;
- while (idx < list.length) {
- item = list[idx];
- if (item === 0 && 1 / item === inf) {
- return idx;
- }
- idx += 1;
- }
- return -1;
- } else if (a !== a) {
- // NaN
- while (idx < list.length) {
- item = list[idx];
- if (typeof item === 'number' && item !== item) {
- return idx;
- }
- idx += 1;
+ function XFilter(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ }
+ XFilter.prototype['@@transducer/init'] = _xfBase.init;
+ XFilter.prototype['@@transducer/result'] = _xfBase.result;
+ XFilter.prototype['@@transducer/step'] = function (result, input) {
+ return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
+ };
+
+ var _xfilter = _curry2(function _xfilter(f, xf) {
+ return new XFilter(f, xf);
+ });
+
+ /**
+ * Takes a predicate and a `Filterable`, and returns a new filterable of the
+ * same type containing the members of the given filterable which satisfy the
+ * given predicate. Filterable objects include plain objects or any object
+ * that has a filter method such as `Array`.
+ *
+ * Dispatches to the `filter` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Filterable f => (a -> Boolean) -> f a -> f a
+ * @param {Function} pred
+ * @param {Array} filterable
+ * @return {Array} Filterable
+ * @see R.reject, R.transduce, R.addIndex
+ * @example
+ *
+ * const isEven = n => n % 2 === 0;
+ *
+ * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
+ *
+ * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
+ */
+ var filter = _curry2(
+ _dispatchable(['filter'], _xfilter, function (pred, filterable) {
+ return _isObject(filterable)
+ ? _reduce(
+ function (acc, key) {
+ if (pred(filterable[key])) {
+ acc[key] = filterable[key];
+ }
+ return acc;
+ },
+ {},
+ keys(filterable)
+ )
+ : // else
+ _filter(pred, filterable);
+ })
+ );
+
+ /**
+ * The complement of [`filter`](#filter).
+ *
+ * Acts as a transducer if a transformer is given in list position. Filterable
+ * objects include plain objects or any object that has a filter method such
+ * as `Array`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Filterable f => (a -> Boolean) -> f a -> f a
+ * @param {Function} pred
+ * @param {Array} filterable
+ * @return {Array}
+ * @see R.filter, R.transduce, R.addIndex
+ * @example
+ *
+ * const isOdd = (n) => n % 2 === 1;
+ *
+ * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
+ *
+ * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
+ */
+ var reject = _curry2(function reject(pred, filterable) {
+ return filter(_complement(pred), filterable);
+ });
+
+ function _toString(x, seen) {
+ var recur = function recur(y) {
+ var xs = seen.concat([x]);
+ return _includes(y, xs) ? '' : _toString(y, xs);
+ };
+
+ // mapPairs :: (Object, [String]) -> [String]
+ var mapPairs = function (obj, keys$$1) {
+ return _map(function (k) {
+ return _quote(k) + ': ' + recur(obj[k]);
+ }, keys$$1.slice().sort());
+ };
+
+ switch (Object.prototype.toString.call(x)) {
+ case '[object Arguments]':
+ return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))';
+ case '[object Array]':
+ return (
+ '[' +
+ _map(recur, x)
+ .concat(
+ mapPairs(
+ x,
+ reject(function (k) {
+ return /^\d+$/.test(k);
+ }, keys(x))
+ )
+ )
+ .join(', ') +
+ ']'
+ );
+ case '[object Boolean]':
+ return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
+ case '[object Date]':
+ return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')';
+ case '[object Null]':
+ return 'null';
+ case '[object Number]':
+ return typeof x === 'object'
+ ? 'new Number(' + recur(x.valueOf()) + ')'
+ : 1 / x === -Infinity
+ ? '-0'
+ : x.toString(10);
+ case '[object String]':
+ return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x);
+ case '[object Undefined]':
+ return 'undefined';
+ default:
+ if (typeof x.toString === 'function') {
+ var repr = x.toString();
+ if (repr !== '[object Object]') {
+ return repr;
}
- return -1;
}
- // non-zero numbers can utilise Set
- return list.indexOf(a, idx);
+ return '{' + mapPairs(x, keys(x)).join(', ') + '}';
+ }
+ }
- // all these types can utilise Set
- case 'string':
- case 'boolean':
- case 'function':
- case 'undefined':
- return list.indexOf(a, idx);
+ /**
+ * Returns the string representation of the given value. `eval`'ing the output
+ * should result in a value equivalent to the input value. Many of the built-in
+ * `toString` methods do not satisfy this requirement.
+ *
+ * If the given value is an `[object Object]` with a `toString` method other
+ * than `Object.prototype.toString`, this method is invoked with no arguments
+ * to produce the return value. This means user-defined constructor functions
+ * can provide a suitable `toString` method. For example:
+ *
+ * function Point(x, y) {
+ * this.x = x;
+ * this.y = y;
+ * }
+ *
+ * Point.prototype.toString = function() {
+ * return 'new Point(' + this.x + ', ' + this.y + ')';
+ * };
+ *
+ * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category String
+ * @sig * -> String
+ * @param {*} val
+ * @return {String}
+ * @example
+ *
+ * R.toString(42); //=> '42'
+ * R.toString('abc'); //=> '"abc"'
+ * R.toString([1, 2, 3]); //=> '[1, 2, 3]'
+ * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
+ * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'
+ */
+ var toString$1 = _curry1(function toString(val) {
+ return _toString(val, []);
+ });
- case 'object':
- if (a === null) {
- // null can utilise Set
- return list.indexOf(a, idx);
+ /**
+ * Returns the result of concatenating the given lists or strings.
+ *
+ * Note: `R.concat` expects both arguments to be of the same type,
+ * unlike the native `Array.prototype.concat` method. It will throw
+ * an error if you `concat` an Array with a non-Array value.
+ *
+ * Dispatches to the `concat` method of the first argument, if present.
+ * Can also concatenate two members of a [fantasy-land
+ * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [a] -> [a]
+ * @sig String -> String -> String
+ * @param {Array|String} firstList The first list
+ * @param {Array|String} secondList The second list
+ * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of
+ * `secondList`.
+ *
+ * @example
+ *
+ * R.concat('ABC', 'DEF'); // 'ABCDEF'
+ * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
+ * R.concat([], []); //=> []
+ */
+ var concat = _curry2(function concat(a, b) {
+ if (_isArray(a)) {
+ if (_isArray(b)) {
+ return a.concat(b);
+ }
+ throw new TypeError(toString$1(b) + ' is not an array');
+ }
+ if (_isString(a)) {
+ if (_isString(b)) {
+ return a + b;
+ }
+ throw new TypeError(toString$1(b) + ' is not a string');
+ }
+ if (a != null && _isFunction(a['fantasy-land/concat'])) {
+ return a['fantasy-land/concat'](b);
+ }
+ if (a != null && _isFunction(a.concat)) {
+ return a.concat(b);
+ }
+ throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"');
+ });
+
+ /**
+ * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
+ * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
+ * to `fn` are applied to each of the predicates in turn until one returns a
+ * "truthy" value, at which point `fn` returns the result of applying its
+ * arguments to the corresponding transformer. If none of the predicates
+ * matches, `fn` returns undefined.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.6.0
+ * @category Logic
+ * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *)
+ * @param {Array} pairs A list of [predicate, transformer]
+ * @return {Function}
+ * @see R.ifElse, R.unless, R.when
+ * @example
+ *
+ * const fn = R.cond([
+ * [R.equals(0), R.always('water freezes at 0°C')],
+ * [R.equals(100), R.always('water boils at 100°C')],
+ * [R.T, temp => 'nothing special happens at ' + temp + '°C']
+ * ]);
+ * fn(0); //=> 'water freezes at 0°C'
+ * fn(50); //=> 'nothing special happens at 50°C'
+ * fn(100); //=> 'water boils at 100°C'
+ */
+ var cond = _curry1(function cond(pairs) {
+ var arity = reduce(
+ max,
+ 0,
+ map(function (pair) {
+ return pair[0].length;
+ }, pairs)
+ );
+ return _arity(arity, function () {
+ var idx = 0;
+ while (idx < pairs.length) {
+ if (pairs[idx][0].apply(this, arguments)) {
+ return pairs[idx][1].apply(this, arguments);
}
+ idx += 1;
+ }
+ });
+ });
+
+ /**
+ * Wraps a constructor function inside a curried function that can be called
+ * with the same arguments and returns the same type. The arity of the function
+ * returned is specified to allow using variadic constructor functions.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.4.0
+ * @category Function
+ * @sig Number -> (* -> {*}) -> (* -> {*})
+ * @param {Number} n The arity of the constructor function.
+ * @param {Function} Fn The constructor function to wrap.
+ * @return {Function} A wrapped, curried constructor function.
+ * @example
+ *
+ * // Variadic Constructor function
+ * function Salad() {
+ * this.ingredients = arguments;
+ * }
+ *
+ * Salad.prototype.recipe = function() {
+ * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients);
+ * return R.join('\n', instructions);
+ * };
+ *
+ * const ThreeLayerSalad = R.constructN(3, Salad);
+ *
+ * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments.
+ * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup');
+ *
+ * console.log(salad.recipe());
+ * // Add a dollop of Mayonnaise
+ * // Add a dollop of Potato Chips
+ * // Add a dollop of Ketchup
+ */
+ var constructN = _curry2(function constructN(n, Fn) {
+ if (n > 10) {
+ throw new Error('Constructor with greater than ten arguments');
}
- }
- // anything else not covered above, defer to R.equals
- while (idx < list.length) {
- if (equals(list[idx], a)) {
- return idx;
+ if (n === 0) {
+ return function () {
+ return new Fn();
+ };
}
- idx += 1;
- }
- return -1;
-}
-
-function _includes(a, list) {
- return _indexOf(list, a, 0) >= 0;
-}
-
-function _quote(s) {
- var escaped = s
- .replace(/\\/g, '\\\\')
- .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace
- .replace(/\f/g, '\\f')
- .replace(/\n/g, '\\n')
- .replace(/\r/g, '\\r')
- .replace(/\t/g, '\\t')
- .replace(/\v/g, '\\v')
- .replace(/\0/g, '\\0');
-
- return '"' + escaped.replace(/"/g, '\\"') + '"';
-}
-
-/**
- * Polyfill from .
- */
-var pad = function pad(n) { return (n < 10 ? '0' : '') + n; };
-
-var _toISOString = typeof Date.prototype.toISOString === 'function' ?
- function _toISOString(d) {
- return d.toISOString();
- } :
- function _toISOString(d) {
- return (
- d.getUTCFullYear() + '-' +
- pad(d.getUTCMonth() + 1) + '-' +
- pad(d.getUTCDate()) + 'T' +
- pad(d.getUTCHours()) + ':' +
- pad(d.getUTCMinutes()) + ':' +
- pad(d.getUTCSeconds()) + '.' +
- (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z'
+ return curry(
+ nAry(n, function ($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
+ switch (arguments.length) {
+ case 1:
+ return new Fn($0);
+ case 2:
+ return new Fn($0, $1);
+ case 3:
+ return new Fn($0, $1, $2);
+ case 4:
+ return new Fn($0, $1, $2, $3);
+ case 5:
+ return new Fn($0, $1, $2, $3, $4);
+ case 6:
+ return new Fn($0, $1, $2, $3, $4, $5);
+ case 7:
+ return new Fn($0, $1, $2, $3, $4, $5, $6);
+ case 8:
+ return new Fn($0, $1, $2, $3, $4, $5, $6, $7);
+ case 9:
+ return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8);
+ case 10:
+ return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
+ }
+ })
);
- };
+ });
-function _complement(f) {
- return function() {
- return !f.apply(this, arguments);
- };
-}
+ /**
+ * Wraps a constructor function inside a curried function that can be called
+ * with the same arguments and returns the same type.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig (* -> {*}) -> (* -> {*})
+ * @param {Function} fn The constructor function to wrap.
+ * @return {Function} A wrapped, curried constructor function.
+ * @see R.invoker
+ * @example
+ *
+ * // Constructor function
+ * function Animal(kind) {
+ * this.kind = kind;
+ * };
+ * Animal.prototype.sighting = function() {
+ * return "It's a " + this.kind + "!";
+ * }
+ *
+ * const AnimalConstructor = R.construct(Animal)
+ *
+ * // Notice we no longer need the 'new' keyword:
+ * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};
+ *
+ * const animalTypes = ["Lion", "Tiger", "Bear"];
+ * const animalSighting = R.invoker(0, 'sighting');
+ * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
+ * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]
+ */
+ var construct = _curry1(function construct(Fn) {
+ return constructN(Fn.length, Fn);
+ });
-function _filter(fn, list) {
- var idx = 0;
- var len = list.length;
- var result = [];
+ /**
+ * Returns `true` if the specified value is equal, in [`R.equals`](#equals)
+ * terms, to at least one element of the given list; `false` otherwise.
+ * Works also with strings.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> Boolean
+ * @param {Object} a The item to compare against.
+ * @param {Array} list The array to consider.
+ * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
+ * @see R.includes
+ * @deprecated since v0.26.0
+ * @example
+ *
+ * R.contains(3, [1, 2, 3]); //=> true
+ * R.contains(4, [1, 2, 3]); //=> false
+ * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
+ * R.contains([42], [[42]]); //=> true
+ * R.contains('ba', 'banana'); //=>true
+ */
+ var contains$1 = _curry2(_includes);
+
+ /**
+ * Accepts a converging function and a list of branching functions and returns
+ * a new function. The arity of the new function is the same as the arity of
+ * the longest branching function. When invoked, this new function is applied
+ * to some arguments, and each branching function is applied to those same
+ * arguments. The results of each branching function are passed as arguments
+ * to the converging function to produce the return value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.4.2
+ * @category Function
+ * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z)
+ * @param {Function} after A function. `after` will be invoked with the return values of
+ * `fn1` and `fn2` as its arguments.
+ * @param {Array} functions A list of functions.
+ * @return {Function} A new function.
+ * @see R.useWith
+ * @example
+ *
+ * const average = R.converge(R.divide, [R.sum, R.length])
+ * average([1, 2, 3, 4, 5, 6, 7]) //=> 4
+ *
+ * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower])
+ * strangeConcat("Yodel") //=> "YODELyodel"
+ *
+ * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))
+ */
+ var converge = _curry2(function converge(after, fns) {
+ return curryN(reduce(max, 0, pluck('length', fns)), function () {
+ var args = arguments;
+ var context = this;
+ return after.apply(
+ context,
+ _map(function (fn) {
+ return fn.apply(context, args);
+ }, fns)
+ );
+ });
+ });
- while (idx < len) {
- if (fn(list[idx])) {
- result[result.length] = list[idx];
- }
- idx += 1;
- }
- return result;
-}
-
-function _isObject(x) {
- return Object.prototype.toString.call(x) === '[object Object]';
-}
-
-function XFilter(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XFilter.prototype['@@transducer/init'] = _xfBase.init;
-XFilter.prototype['@@transducer/result'] = _xfBase.result;
-XFilter.prototype['@@transducer/step'] = function(result, input) {
- return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
-};
-
-var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); });
-
-/**
- * Takes a predicate and a `Filterable`, and returns a new filterable of the
- * same type containing the members of the given filterable which satisfy the
- * given predicate. Filterable objects include plain objects or any object
- * that has a filter method such as `Array`.
- *
- * Dispatches to the `filter` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Filterable f => (a -> Boolean) -> f a -> f a
- * @param {Function} pred
- * @param {Array} filterable
- * @return {Array} Filterable
- * @see R.reject, R.transduce, R.addIndex
- * @example
- *
- * const isEven = n => n % 2 === 0;
- *
- * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
- *
- * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
- */
-var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) {
- return (
- _isObject(filterable) ?
- _reduce(function(acc, key) {
- if (pred(filterable[key])) {
- acc[key] = filterable[key];
+ function XReduceBy(valueFn, valueAcc, keyFn, xf) {
+ this.valueFn = valueFn;
+ this.valueAcc = valueAcc;
+ this.keyFn = keyFn;
+ this.xf = xf;
+ this.inputs = {};
+ }
+ XReduceBy.prototype['@@transducer/init'] = _xfBase.init;
+ XReduceBy.prototype['@@transducer/result'] = function (result) {
+ var key;
+ for (key in this.inputs) {
+ if (_has(key, this.inputs)) {
+ result = this.xf['@@transducer/step'](result, this.inputs[key]);
+ if (result['@@transducer/reduced']) {
+ result = result['@@transducer/value'];
+ break;
}
- return acc;
- }, {}, keys(filterable)) :
- // else
- _filter(pred, filterable)
+ }
+ }
+ this.inputs = null;
+ return this.xf['@@transducer/result'](result);
+ };
+ XReduceBy.prototype['@@transducer/step'] = function (result, input) {
+ var key = this.keyFn(input);
+ this.inputs[key] = this.inputs[key] || [key, this.valueAcc];
+ this.inputs[key][1] = this.valueFn(this.inputs[key][1], input);
+ return result;
+ };
+
+ var _xreduceBy = _curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) {
+ return new XReduceBy(valueFn, valueAcc, keyFn, xf);
+ });
+
+ /**
+ * Groups the elements of the list according to the result of calling
+ * the String-returning function `keyFn` on each element and reduces the elements
+ * of each group to a single value via the reducer function `valueFn`.
+ *
+ * This function is basically a more general [`groupBy`](#groupBy) function.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.20.0
+ * @category List
+ * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a}
+ * @param {Function} valueFn The function that reduces the elements of each group to a single
+ * value. Receives two values, accumulator for a particular group and the current element.
+ * @param {*} acc The (initial) accumulator value for each group.
+ * @param {Function} keyFn The function that maps the list's element into a key.
+ * @param {Array} list The array to group.
+ * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of
+ * `valueFn` for elements which produced that key when passed to `keyFn`.
+ * @see R.groupBy, R.reduce
+ * @example
+ *
+ * const groupNames = (acc, {name}) => acc.concat(name)
+ * const toGrade = ({score}) =>
+ * score < 65 ? 'F' :
+ * score < 70 ? 'D' :
+ * score < 80 ? 'C' :
+ * score < 90 ? 'B' : 'A'
+ *
+ * var students = [
+ * {name: 'Abby', score: 83},
+ * {name: 'Bart', score: 62},
+ * {name: 'Curt', score: 88},
+ * {name: 'Dora', score: 92},
+ * ]
+ *
+ * reduceBy(groupNames, [], toGrade, students)
+ * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]}
+ */
+ var reduceBy = _curryN(
+ 4,
+ [],
+ _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) {
+ return _reduce(
+ function (acc, elt) {
+ var key = keyFn(elt);
+ acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt);
+ return acc;
+ },
+ {},
+ list
+ );
+ })
);
-}));
-/**
- * The complement of [`filter`](#filter).
- *
- * Acts as a transducer if a transformer is given in list position. Filterable
- * objects include plain objects or any object that has a filter method such
- * as `Array`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Filterable f => (a -> Boolean) -> f a -> f a
- * @param {Function} pred
- * @param {Array} filterable
- * @return {Array}
- * @see R.filter, R.transduce, R.addIndex
- * @example
- *
- * const isOdd = (n) => n % 2 === 1;
- *
- * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
- *
- * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
- */
-var reject = _curry2(function reject(pred, filterable) {
- return filter(_complement(pred), filterable);
-});
+ /**
+ * Counts the elements of a list according to how many match each value of a
+ * key generated by the supplied function. Returns an object mapping the keys
+ * produced by `fn` to the number of occurrences in the list. Note that all
+ * keys are coerced to strings because of how JavaScript objects work.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig (a -> String) -> [a] -> {*}
+ * @param {Function} fn The function used to map values to keys.
+ * @param {Array} list The list to count elements from.
+ * @return {Object} An object mapping keys to number of occurrences in the list.
+ * @example
+ *
+ * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
+ * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}
+ *
+ * const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
+ * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}
+ */
+ var countBy = reduceBy(function (acc, elem) {
+ return acc + 1;
+ }, 0);
+
+ /**
+ * Decrements its argument.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Math
+ * @sig Number -> Number
+ * @param {Number} n
+ * @return {Number} n - 1
+ * @see R.inc
+ * @example
+ *
+ * R.dec(42); //=> 41
+ */
+ var dec = add(-1);
+
+ /**
+ * Returns the second argument if it is not `null`, `undefined` or `NaN`;
+ * otherwise the first argument is returned.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Logic
+ * @sig a -> b -> a | b
+ * @param {a} default The default value.
+ * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`.
+ * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value
+ * @example
+ *
+ * const defaultTo42 = R.defaultTo(42);
+ *
+ * defaultTo42(null); //=> 42
+ * defaultTo42(undefined); //=> 42
+ * defaultTo42(false); //=> false
+ * defaultTo42('Ramda'); //=> 'Ramda'
+ * // parseInt('string') results in NaN
+ * defaultTo42(parseInt('string')); //=> 42
+ */
+ var defaultTo = _curry2(function defaultTo(d, v) {
+ return v == null || v !== v ? d : v;
+ });
+
+ /**
+ * Makes a descending comparator function out of a function that returns a value
+ * that can be compared with `<` and `>`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.23.0
+ * @category Function
+ * @sig Ord b => (a -> b) -> a -> a -> Number
+ * @param {Function} fn A function of arity one that returns a value that can be compared
+ * @param {*} a The first item to be compared.
+ * @param {*} b The second item to be compared.
+ * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0`
+ * @see R.ascend
+ * @example
+ *
+ * const byAge = R.descend(R.prop('age'));
+ * const people = [
+ * { name: 'Emma', age: 70 },
+ * { name: 'Peter', age: 78 },
+ * { name: 'Mikhail', age: 62 },
+ * ];
+ * const peopleByOldestFirst = R.sort(byAge, people);
+ * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }]
+ */
+ var descend = _curry3(function descend(fn, a, b) {
+ var aa = fn(a);
+ var bb = fn(b);
+ return aa > bb ? -1 : aa < bb ? 1 : 0;
+ });
+
+ function _Set() {
+ /* globals Set */
+ this._nativeSet = typeof Set === 'function' ? new Set() : null;
+ this._items = {};
+ }
-function _toString(x, seen) {
- var recur = function recur(y) {
- var xs = seen.concat([x]);
- return _includes(y, xs) ? '' : _toString(y, xs);
+ // until we figure out why jsdoc chokes on this
+ // @param item The item to add to the Set
+ // @returns {boolean} true if the item did not exist prior, otherwise false
+ //
+ _Set.prototype.add = function (item) {
+ return !hasOrAdd(item, true, this);
};
- // mapPairs :: (Object, [String]) -> [String]
- var mapPairs = function(obj, keys$$1) {
- return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort());
+ //
+ // @param item The item to check for existence in the Set
+ // @returns {boolean} true if the item exists in the Set, otherwise false
+ //
+ _Set.prototype.has = function (item) {
+ return hasOrAdd(item, false, this);
};
- switch (Object.prototype.toString.call(x)) {
- case '[object Arguments]':
- return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))';
- case '[object Array]':
- return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']';
- case '[object Boolean]':
- return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
- case '[object Date]':
- return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')';
- case '[object Null]':
- return 'null';
- case '[object Number]':
- return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10);
- case '[object String]':
- return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x);
- case '[object Undefined]':
- return 'undefined';
- default:
- if (typeof x.toString === 'function') {
- var repr = x.toString();
- if (repr !== '[object Object]') {
- return repr;
+ //
+ // Combines the logic for checking whether an item is a member of the set and
+ // for adding a new item to the set.
+ //
+ // @param item The item to check or add to the Set instance.
+ // @param shouldAdd If true, the item will be added to the set if it doesn't
+ // already exist.
+ // @param set The set instance to check or add to.
+ // @return {boolean} true if the item already existed, otherwise false.
+ //
+ function hasOrAdd(item, shouldAdd, set) {
+ var type = typeof item;
+ var prevSize, newSize;
+ switch (type) {
+ case 'string':
+ case 'number':
+ // distinguish between +0 and -0
+ if (item === 0 && 1 / item === -Infinity) {
+ if (set._items['-0']) {
+ return true;
+ } else {
+ if (shouldAdd) {
+ set._items['-0'] = true;
+ }
+ return false;
+ }
+ }
+ // these types can all utilise the native Set
+ if (set._nativeSet !== null) {
+ if (shouldAdd) {
+ prevSize = set._nativeSet.size;
+ set._nativeSet.add(item);
+ newSize = set._nativeSet.size;
+ return newSize === prevSize;
+ } else {
+ return set._nativeSet.has(item);
+ }
+ } else {
+ if (!(type in set._items)) {
+ if (shouldAdd) {
+ set._items[type] = {};
+ set._items[type][item] = true;
+ }
+ return false;
+ } else if (item in set._items[type]) {
+ return true;
+ } else {
+ if (shouldAdd) {
+ set._items[type][item] = true;
+ }
+ return false;
+ }
}
- }
- return '{' + mapPairs(x, keys(x)).join(', ') + '}';
- }
-}
-/**
- * Returns the string representation of the given value. `eval`'ing the output
- * should result in a value equivalent to the input value. Many of the built-in
- * `toString` methods do not satisfy this requirement.
- *
- * If the given value is an `[object Object]` with a `toString` method other
- * than `Object.prototype.toString`, this method is invoked with no arguments
- * to produce the return value. This means user-defined constructor functions
- * can provide a suitable `toString` method. For example:
- *
- * function Point(x, y) {
- * this.x = x;
- * this.y = y;
- * }
- *
- * Point.prototype.toString = function() {
- * return 'new Point(' + this.x + ', ' + this.y + ')';
- * };
- *
- * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category String
- * @sig * -> String
- * @param {*} val
- * @return {String}
- * @example
- *
- * R.toString(42); //=> '42'
- * R.toString('abc'); //=> '"abc"'
- * R.toString([1, 2, 3]); //=> '[1, 2, 3]'
- * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
- * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'
- */
-var toString$1 = _curry1(function toString(val) { return _toString(val, []); });
+ case 'boolean':
+ // set._items['boolean'] holds a two element array
+ // representing [ falseExists, trueExists ]
+ if (type in set._items) {
+ var bIdx = item ? 1 : 0;
+ if (set._items[type][bIdx]) {
+ return true;
+ } else {
+ if (shouldAdd) {
+ set._items[type][bIdx] = true;
+ }
+ return false;
+ }
+ } else {
+ if (shouldAdd) {
+ set._items[type] = item ? [false, true] : [true, false];
+ }
+ return false;
+ }
-/**
- * Returns the result of concatenating the given lists or strings.
- *
- * Note: `R.concat` expects both arguments to be of the same type,
- * unlike the native `Array.prototype.concat` method. It will throw
- * an error if you `concat` an Array with a non-Array value.
- *
- * Dispatches to the `concat` method of the first argument, if present.
- * Can also concatenate two members of a [fantasy-land
- * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [a] -> [a]
- * @sig String -> String -> String
- * @param {Array|String} firstList The first list
- * @param {Array|String} secondList The second list
- * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of
- * `secondList`.
- *
- * @example
- *
- * R.concat('ABC', 'DEF'); // 'ABCDEF'
- * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
- * R.concat([], []); //=> []
- */
-var concat = _curry2(function concat(a, b) {
- if (_isArray(a)) {
- if (_isArray(b)) {
- return a.concat(b);
+ case 'function':
+ // compare functions for reference equality
+ if (set._nativeSet !== null) {
+ if (shouldAdd) {
+ prevSize = set._nativeSet.size;
+ set._nativeSet.add(item);
+ newSize = set._nativeSet.size;
+ return newSize === prevSize;
+ } else {
+ return set._nativeSet.has(item);
+ }
+ } else {
+ if (!(type in set._items)) {
+ if (shouldAdd) {
+ set._items[type] = [item];
+ }
+ return false;
+ }
+ if (!_includes(item, set._items[type])) {
+ if (shouldAdd) {
+ set._items[type].push(item);
+ }
+ return false;
+ }
+ return true;
+ }
+
+ case 'undefined':
+ if (set._items[type]) {
+ return true;
+ } else {
+ if (shouldAdd) {
+ set._items[type] = true;
+ }
+ return false;
+ }
+
+ case 'object':
+ if (item === null) {
+ if (!set._items['null']) {
+ if (shouldAdd) {
+ set._items['null'] = true;
+ }
+ return false;
+ }
+ return true;
+ }
+ /* falls through */
+ default:
+ // reduce the search size of heterogeneous sets by creating buckets
+ // for each type.
+ type = Object.prototype.toString.call(item);
+ if (!(type in set._items)) {
+ if (shouldAdd) {
+ set._items[type] = [item];
+ }
+ return false;
+ }
+ // scan through all previously applied items
+ if (!_includes(item, set._items[type])) {
+ if (shouldAdd) {
+ set._items[type].push(item);
+ }
+ return false;
+ }
+ return true;
}
- throw new TypeError(toString$1(b) + ' is not an array');
}
- if (_isString(a)) {
- if (_isString(b)) {
- return a + b;
+
+ /**
+ * Finds the set (i.e. no duplicates) of all elements in the first list not
+ * contained in the second list. Objects and Arrays are compared in terms of
+ * value equality, not reference equality.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig [*] -> [*] -> [*]
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The elements in `list1` that are not in `list2`.
+ * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without
+ * @example
+ *
+ * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
+ * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
+ * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]
+ */
+ var difference = _curry2(function difference(first, second) {
+ var out = [];
+ var idx = 0;
+ var firstLen = first.length;
+ var secondLen = second.length;
+ var toFilterOut = new _Set();
+
+ for (var i = 0; i < secondLen; i += 1) {
+ toFilterOut.add(second[i]);
}
- throw new TypeError(toString$1(b) + ' is not a string');
- }
- if (a != null && _isFunction(a['fantasy-land/concat'])) {
- return a['fantasy-land/concat'](b);
- }
- if (a != null && _isFunction(a.concat)) {
- return a.concat(b);
- }
- throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"');
-});
-/**
- * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
- * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
- * to `fn` are applied to each of the predicates in turn until one returns a
- * "truthy" value, at which point `fn` returns the result of applying its
- * arguments to the corresponding transformer. If none of the predicates
- * matches, `fn` returns undefined.
- *
- * @func
- * @memberOf R
- * @since v0.6.0
- * @category Logic
- * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *)
- * @param {Array} pairs A list of [predicate, transformer]
- * @return {Function}
- * @see R.ifElse, R.unless, R.when
- * @example
- *
- * const fn = R.cond([
- * [R.equals(0), R.always('water freezes at 0°C')],
- * [R.equals(100), R.always('water boils at 100°C')],
- * [R.T, temp => 'nothing special happens at ' + temp + '°C']
- * ]);
- * fn(0); //=> 'water freezes at 0°C'
- * fn(50); //=> 'nothing special happens at 50°C'
- * fn(100); //=> 'water boils at 100°C'
- */
-var cond = _curry1(function cond(pairs) {
- var arity = reduce(max,
- 0,
- map(function(pair) { return pair[0].length; }, pairs));
- return _arity(arity, function() {
+ while (idx < firstLen) {
+ if (toFilterOut.add(first[idx])) {
+ out[out.length] = first[idx];
+ }
+ idx += 1;
+ }
+ return out;
+ });
+
+ /**
+ * Finds the set (i.e. no duplicates) of all elements in the first list not
+ * contained in the second list. Duplication is determined according to the
+ * value returned by applying the supplied predicate to two list elements.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
+ * @param {Function} pred A predicate used to test whether two items are equal.
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The elements in `list1` that are not in `list2`.
+ * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith
+ * @example
+ *
+ * const cmp = (x, y) => x.a === y.a;
+ * const l1 = [{a: 1}, {a: 2}, {a: 3}];
+ * const l2 = [{a: 3}, {a: 4}];
+ * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]
+ */
+ var differenceWith = _curry3(function differenceWith(pred, first, second) {
+ var out = [];
var idx = 0;
- while (idx < pairs.length) {
- if (pairs[idx][0].apply(this, arguments)) {
- return pairs[idx][1].apply(this, arguments);
+ var firstLen = first.length;
+ while (idx < firstLen) {
+ if (!_includesWith(pred, first[idx], second) && !_includesWith(pred, first[idx], out)) {
+ out.push(first[idx]);
}
idx += 1;
}
+ return out;
});
-});
-/**
- * Wraps a constructor function inside a curried function that can be called
- * with the same arguments and returns the same type. The arity of the function
- * returned is specified to allow using variadic constructor functions.
- *
- * @func
- * @memberOf R
- * @since v0.4.0
- * @category Function
- * @sig Number -> (* -> {*}) -> (* -> {*})
- * @param {Number} n The arity of the constructor function.
- * @param {Function} Fn The constructor function to wrap.
- * @return {Function} A wrapped, curried constructor function.
- * @example
- *
- * // Variadic Constructor function
- * function Salad() {
- * this.ingredients = arguments;
- * }
- *
- * Salad.prototype.recipe = function() {
- * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients);
- * return R.join('\n', instructions);
- * };
- *
- * const ThreeLayerSalad = R.constructN(3, Salad);
- *
- * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments.
- * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup');
- *
- * console.log(salad.recipe());
- * // Add a dollop of Mayonnaise
- * // Add a dollop of Potato Chips
- * // Add a dollop of Ketchup
- */
-var constructN = _curry2(function constructN(n, Fn) {
- if (n > 10) {
- throw new Error('Constructor with greater than ten arguments');
- }
- if (n === 0) {
- return function() { return new Fn(); };
- }
- return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
- switch (arguments.length) {
- case 1: return new Fn($0);
- case 2: return new Fn($0, $1);
- case 3: return new Fn($0, $1, $2);
- case 4: return new Fn($0, $1, $2, $3);
- case 5: return new Fn($0, $1, $2, $3, $4);
- case 6: return new Fn($0, $1, $2, $3, $4, $5);
- case 7: return new Fn($0, $1, $2, $3, $4, $5, $6);
- case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7);
- case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8);
- case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
- }
- }));
-});
+ /**
+ * Returns a new object that does not contain a `prop` property.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Object
+ * @sig String -> {k: v} -> {k: v}
+ * @param {String} prop The name of the property to dissociate
+ * @param {Object} obj The object to clone
+ * @return {Object} A new object equivalent to the original but without the specified property
+ * @see R.assoc, R.omit
+ * @example
+ *
+ * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
+ */
+ var dissoc = _curry2(function dissoc(prop, obj) {
+ var result = {};
+ for (var p in obj) {
+ result[p] = obj[p];
+ }
+ delete result[prop];
+ return result;
+ });
-/**
- * Wraps a constructor function inside a curried function that can be called
- * with the same arguments and returns the same type.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig (* -> {*}) -> (* -> {*})
- * @param {Function} fn The constructor function to wrap.
- * @return {Function} A wrapped, curried constructor function.
- * @see R.invoker
- * @example
- *
- * // Constructor function
- * function Animal(kind) {
- * this.kind = kind;
- * };
- * Animal.prototype.sighting = function() {
- * return "It's a " + this.kind + "!";
- * }
- *
- * const AnimalConstructor = R.construct(Animal)
- *
- * // Notice we no longer need the 'new' keyword:
- * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};
- *
- * const animalTypes = ["Lion", "Tiger", "Bear"];
- * const animalSighting = R.invoker(0, 'sighting');
- * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
- * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]
- */
-var construct = _curry1(function construct(Fn) {
- return constructN(Fn.length, Fn);
-});
+ /**
+ * Removes the sub-list of `list` starting at index `start` and containing
+ * `count` elements. _Note that this is not destructive_: it returns a copy of
+ * the list with the changes.
+ * No lists have been harmed in the application of this function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.2
+ * @category List
+ * @sig Number -> Number -> [a] -> [a]
+ * @param {Number} start The position to start removing elements
+ * @param {Number} count The number of elements to remove
+ * @param {Array} list The list to remove from
+ * @return {Array} A new Array with `count` elements from `start` removed.
+ * @see R.without
+ * @example
+ *
+ * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
+ */
+ var remove = _curry3(function remove(start, count, list) {
+ var result = Array.prototype.slice.call(list, 0);
+ result.splice(start, count);
+ return result;
+ });
-/**
- * Returns `true` if the specified value is equal, in [`R.equals`](#equals)
- * terms, to at least one element of the given list; `false` otherwise.
- * Works also with strings.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> Boolean
- * @param {Object} a The item to compare against.
- * @param {Array} list The array to consider.
- * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
- * @see R.includes
- * @deprecated since v0.26.0
- * @example
- *
- * R.contains(3, [1, 2, 3]); //=> true
- * R.contains(4, [1, 2, 3]); //=> false
- * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
- * R.contains([42], [[42]]); //=> true
- * R.contains('ba', 'banana'); //=>true
- */
-var contains$1 = _curry2(_includes);
-
-/**
- * Accepts a converging function and a list of branching functions and returns
- * a new function. The arity of the new function is the same as the arity of
- * the longest branching function. When invoked, this new function is applied
- * to some arguments, and each branching function is applied to those same
- * arguments. The results of each branching function are passed as arguments
- * to the converging function to produce the return value.
- *
- * @func
- * @memberOf R
- * @since v0.4.2
- * @category Function
- * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z)
- * @param {Function} after A function. `after` will be invoked with the return values of
- * `fn1` and `fn2` as its arguments.
- * @param {Array} functions A list of functions.
- * @return {Function} A new function.
- * @see R.useWith
- * @example
- *
- * const average = R.converge(R.divide, [R.sum, R.length])
- * average([1, 2, 3, 4, 5, 6, 7]) //=> 4
- *
- * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower])
- * strangeConcat("Yodel") //=> "YODELyodel"
- *
- * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))
- */
-var converge = _curry2(function converge(after, fns) {
- return curryN(reduce(max, 0, pluck('length', fns)), function() {
- var args = arguments;
- var context = this;
- return after.apply(context, _map(function(fn) {
- return fn.apply(context, args);
- }, fns));
+ /**
+ * Returns a new copy of the array with the element at the provided index
+ * replaced with the given value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category List
+ * @sig Number -> a -> [a] -> [a]
+ * @param {Number} idx The index to update.
+ * @param {*} x The value to exist at the given index of the returned array.
+ * @param {Array|Arguments} list The source array-like object to be updated.
+ * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`.
+ * @see R.adjust
+ * @example
+ *
+ * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c']
+ * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']
+ * @symb R.update(-1, a, [b, c]) = [b, a]
+ * @symb R.update(0, a, [b, c]) = [a, c]
+ * @symb R.update(1, a, [b, c]) = [b, a]
+ */
+ var update = _curry3(function update(idx, x, list) {
+ return adjust(idx, always(x), list);
});
-});
-
-function XReduceBy(valueFn, valueAcc, keyFn, xf) {
- this.valueFn = valueFn;
- this.valueAcc = valueAcc;
- this.keyFn = keyFn;
- this.xf = xf;
- this.inputs = {};
-}
-XReduceBy.prototype['@@transducer/init'] = _xfBase.init;
-XReduceBy.prototype['@@transducer/result'] = function(result) {
- var key;
- for (key in this.inputs) {
- if (_has(key, this.inputs)) {
- result = this.xf['@@transducer/step'](result, this.inputs[key]);
- if (result['@@transducer/reduced']) {
- result = result['@@transducer/value'];
- break;
- }
- }
- }
- this.inputs = null;
- return this.xf['@@transducer/result'](result);
-};
-XReduceBy.prototype['@@transducer/step'] = function(result, input) {
- var key = this.keyFn(input);
- this.inputs[key] = this.inputs[key] || [key, this.valueAcc];
- this.inputs[key][1] = this.valueFn(this.inputs[key][1], input);
- return result;
-};
-
-var _xreduceBy = _curryN(4, [],
- function _xreduceBy(valueFn, valueAcc, keyFn, xf) {
- return new XReduceBy(valueFn, valueAcc, keyFn, xf);
- });
-
-/**
- * Groups the elements of the list according to the result of calling
- * the String-returning function `keyFn` on each element and reduces the elements
- * of each group to a single value via the reducer function `valueFn`.
- *
- * This function is basically a more general [`groupBy`](#groupBy) function.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.20.0
- * @category List
- * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a}
- * @param {Function} valueFn The function that reduces the elements of each group to a single
- * value. Receives two values, accumulator for a particular group and the current element.
- * @param {*} acc The (initial) accumulator value for each group.
- * @param {Function} keyFn The function that maps the list's element into a key.
- * @param {Array} list The array to group.
- * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of
- * `valueFn` for elements which produced that key when passed to `keyFn`.
- * @see R.groupBy, R.reduce
- * @example
- *
- * const groupNames = (acc, {name}) => acc.concat(name)
- * const toGrade = ({score}) =>
- * score < 65 ? 'F' :
- * score < 70 ? 'D' :
- * score < 80 ? 'C' :
- * score < 90 ? 'B' : 'A'
- *
- * var students = [
- * {name: 'Abby', score: 83},
- * {name: 'Bart', score: 62},
- * {name: 'Curt', score: 88},
- * {name: 'Dora', score: 92},
- * ]
- *
- * reduceBy(groupNames, [], toGrade, students)
- * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]}
- */
-var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy,
- function reduceBy(valueFn, valueAcc, keyFn, list) {
- return _reduce(function(acc, elt) {
- var key = keyFn(elt);
- acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt);
- return acc;
- }, {}, list);
- }));
-
-/**
- * Counts the elements of a list according to how many match each value of a
- * key generated by the supplied function. Returns an object mapping the keys
- * produced by `fn` to the number of occurrences in the list. Note that all
- * keys are coerced to strings because of how JavaScript objects work.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig (a -> String) -> [a] -> {*}
- * @param {Function} fn The function used to map values to keys.
- * @param {Array} list The list to count elements from.
- * @return {Object} An object mapping keys to number of occurrences in the list.
- * @example
- *
- * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
- * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}
- *
- * const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
- * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}
- */
-var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0);
-
-/**
- * Decrements its argument.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Math
- * @sig Number -> Number
- * @param {Number} n
- * @return {Number} n - 1
- * @see R.inc
- * @example
- *
- * R.dec(42); //=> 41
- */
-var dec = add(-1);
-
-/**
- * Returns the second argument if it is not `null`, `undefined` or `NaN`;
- * otherwise the first argument is returned.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Logic
- * @sig a -> b -> a | b
- * @param {a} default The default value.
- * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`.
- * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value
- * @example
- *
- * const defaultTo42 = R.defaultTo(42);
- *
- * defaultTo42(null); //=> 42
- * defaultTo42(undefined); //=> 42
- * defaultTo42(false); //=> false
- * defaultTo42('Ramda'); //=> 'Ramda'
- * // parseInt('string') results in NaN
- * defaultTo42(parseInt('string')); //=> 42
- */
-var defaultTo = _curry2(function defaultTo(d, v) {
- return v == null || v !== v ? d : v;
-});
-
-/**
- * Makes a descending comparator function out of a function that returns a value
- * that can be compared with `<` and `>`.
- *
- * @func
- * @memberOf R
- * @since v0.23.0
- * @category Function
- * @sig Ord b => (a -> b) -> a -> a -> Number
- * @param {Function} fn A function of arity one that returns a value that can be compared
- * @param {*} a The first item to be compared.
- * @param {*} b The second item to be compared.
- * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0`
- * @see R.ascend
- * @example
- *
- * const byAge = R.descend(R.prop('age'));
- * const people = [
- * { name: 'Emma', age: 70 },
- * { name: 'Peter', age: 78 },
- * { name: 'Mikhail', age: 62 },
- * ];
- * const peopleByOldestFirst = R.sort(byAge, people);
- * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }]
- */
-var descend = _curry3(function descend(fn, a, b) {
- var aa = fn(a);
- var bb = fn(b);
- return aa > bb ? -1 : aa < bb ? 1 : 0;
-});
-
-function _Set() {
- /* globals Set */
- this._nativeSet = typeof Set === 'function' ? new Set() : null;
- this._items = {};
-}
-
-// until we figure out why jsdoc chokes on this
-// @param item The item to add to the Set
-// @returns {boolean} true if the item did not exist prior, otherwise false
-//
-_Set.prototype.add = function(item) {
- return !hasOrAdd(item, true, this);
-};
-
-//
-// @param item The item to check for existence in the Set
-// @returns {boolean} true if the item exists in the Set, otherwise false
-//
-_Set.prototype.has = function(item) {
- return hasOrAdd(item, false, this);
-};
-
-//
-// Combines the logic for checking whether an item is a member of the set and
-// for adding a new item to the set.
-//
-// @param item The item to check or add to the Set instance.
-// @param shouldAdd If true, the item will be added to the set if it doesn't
-// already exist.
-// @param set The set instance to check or add to.
-// @return {boolean} true if the item already existed, otherwise false.
-//
-function hasOrAdd(item, shouldAdd, set) {
- var type = typeof item;
- var prevSize, newSize;
- switch (type) {
- case 'string':
- case 'number':
- // distinguish between +0 and -0
- if (item === 0 && 1 / item === -Infinity) {
- if (set._items['-0']) {
- return true;
- } else {
- if (shouldAdd) {
- set._items['-0'] = true;
- }
- return false;
- }
- }
- // these types can all utilise the native Set
- if (set._nativeSet !== null) {
- if (shouldAdd) {
- prevSize = set._nativeSet.size;
- set._nativeSet.add(item);
- newSize = set._nativeSet.size;
- return newSize === prevSize;
- } else {
- return set._nativeSet.has(item);
- }
- } else {
- if (!(type in set._items)) {
- if (shouldAdd) {
- set._items[type] = {};
- set._items[type][item] = true;
- }
- return false;
- } else if (item in set._items[type]) {
- return true;
- } else {
- if (shouldAdd) {
- set._items[type][item] = true;
- }
- return false;
- }
- }
-
- case 'boolean':
- // set._items['boolean'] holds a two element array
- // representing [ falseExists, trueExists ]
- if (type in set._items) {
- var bIdx = item ? 1 : 0;
- if (set._items[type][bIdx]) {
- return true;
- } else {
- if (shouldAdd) {
- set._items[type][bIdx] = true;
- }
- return false;
- }
- } else {
- if (shouldAdd) {
- set._items[type] = item ? [false, true] : [true, false];
- }
- return false;
- }
-
- case 'function':
- // compare functions for reference equality
- if (set._nativeSet !== null) {
- if (shouldAdd) {
- prevSize = set._nativeSet.size;
- set._nativeSet.add(item);
- newSize = set._nativeSet.size;
- return newSize === prevSize;
- } else {
- return set._nativeSet.has(item);
- }
- } else {
- if (!(type in set._items)) {
- if (shouldAdd) {
- set._items[type] = [item];
- }
- return false;
- }
- if (!_includes(item, set._items[type])) {
- if (shouldAdd) {
- set._items[type].push(item);
- }
- return false;
- }
- return true;
- }
- case 'undefined':
- if (set._items[type]) {
- return true;
- } else {
- if (shouldAdd) {
- set._items[type] = true;
- }
- return false;
- }
-
- case 'object':
- if (item === null) {
- if (!set._items['null']) {
- if (shouldAdd) {
- set._items['null'] = true;
- }
- return false;
- }
- return true;
- }
- /* falls through */
- default:
- // reduce the search size of heterogeneous sets by creating buckets
- // for each type.
- type = Object.prototype.toString.call(item);
- if (!(type in set._items)) {
- if (shouldAdd) {
- set._items[type] = [item];
- }
- return false;
- }
- // scan through all previously applied items
- if (!_includes(item, set._items[type])) {
- if (shouldAdd) {
- set._items[type].push(item);
- }
- return false;
- }
- return true;
- }
-}
-
-/**
- * Finds the set (i.e. no duplicates) of all elements in the first list not
- * contained in the second list. Objects and Arrays are compared in terms of
- * value equality, not reference equality.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig [*] -> [*] -> [*]
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The elements in `list1` that are not in `list2`.
- * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without
- * @example
- *
- * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
- * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
- * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]
- */
-var difference = _curry2(function difference(first, second) {
- var out = [];
- var idx = 0;
- var firstLen = first.length;
- var secondLen = second.length;
- var toFilterOut = new _Set();
-
- for (var i = 0; i < secondLen; i += 1) {
- toFilterOut.add(second[i]);
- }
-
- while (idx < firstLen) {
- if (toFilterOut.add(first[idx])) {
- out[out.length] = first[idx];
- }
- idx += 1;
- }
- return out;
-});
-
-/**
- * Finds the set (i.e. no duplicates) of all elements in the first list not
- * contained in the second list. Duplication is determined according to the
- * value returned by applying the supplied predicate to two list elements.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
- * @param {Function} pred A predicate used to test whether two items are equal.
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The elements in `list1` that are not in `list2`.
- * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith
- * @example
- *
- * const cmp = (x, y) => x.a === y.a;
- * const l1 = [{a: 1}, {a: 2}, {a: 3}];
- * const l2 = [{a: 3}, {a: 4}];
- * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]
- */
-var differenceWith = _curry3(function differenceWith(pred, first, second) {
- var out = [];
- var idx = 0;
- var firstLen = first.length;
- while (idx < firstLen) {
- if (!_includesWith(pred, first[idx], second) &&
- !_includesWith(pred, first[idx], out)) {
- out.push(first[idx]);
- }
- idx += 1;
- }
- return out;
-});
-
-/**
- * Returns a new object that does not contain a `prop` property.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Object
- * @sig String -> {k: v} -> {k: v}
- * @param {String} prop The name of the property to dissociate
- * @param {Object} obj The object to clone
- * @return {Object} A new object equivalent to the original but without the specified property
- * @see R.assoc, R.omit
- * @example
- *
- * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
- */
-var dissoc = _curry2(function dissoc(prop, obj) {
- var result = {};
- for (var p in obj) {
- result[p] = obj[p];
- }
- delete result[prop];
- return result;
-});
-
-/**
- * Removes the sub-list of `list` starting at index `start` and containing
- * `count` elements. _Note that this is not destructive_: it returns a copy of
- * the list with the changes.
- * No lists have been harmed in the application of this function.
- *
- * @func
- * @memberOf R
- * @since v0.2.2
- * @category List
- * @sig Number -> Number -> [a] -> [a]
- * @param {Number} start The position to start removing elements
- * @param {Number} count The number of elements to remove
- * @param {Array} list The list to remove from
- * @return {Array} A new Array with `count` elements from `start` removed.
- * @see R.without
- * @example
- *
- * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
- */
-var remove = _curry3(function remove(start, count, list) {
- var result = Array.prototype.slice.call(list, 0);
- result.splice(start, count);
- return result;
-});
-
-/**
- * Returns a new copy of the array with the element at the provided index
- * replaced with the given value.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category List
- * @sig Number -> a -> [a] -> [a]
- * @param {Number} idx The index to update.
- * @param {*} x The value to exist at the given index of the returned array.
- * @param {Array|Arguments} list The source array-like object to be updated.
- * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`.
- * @see R.adjust
- * @example
- *
- * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c']
- * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']
- * @symb R.update(-1, a, [b, c]) = [b, a]
- * @symb R.update(0, a, [b, c]) = [a, c]
- * @symb R.update(1, a, [b, c]) = [b, a]
- */
-var update = _curry3(function update(idx, x, list) {
- return adjust(idx, always(x), list);
-});
-
-/**
- * Makes a shallow clone of an object, omitting the property at the given path.
- * Note that this copies and flattens prototype properties onto the new object
- * as well. All non-primitive properties are copied by reference.
- *
- * @func
- * @memberOf R
- * @since v0.11.0
- * @category Object
- * @typedefn Idx = String | Int
- * @sig [Idx] -> {k: v} -> {k: v}
- * @param {Array} path The path to the value to omit
- * @param {Object} obj The object to clone
- * @return {Object} A new object without the property at path
- * @see R.assocPath
- * @example
- *
- * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
- */
-var dissocPath = _curry2(function dissocPath(path, obj) {
- switch (path.length) {
- case 0:
- return obj;
- case 1:
- return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj);
- default:
- var head = path[0];
- var tail = Array.prototype.slice.call(path, 1);
- if (obj[head] == null) {
+ /**
+ * Makes a shallow clone of an object, omitting the property at the given path.
+ * Note that this copies and flattens prototype properties onto the new object
+ * as well. All non-primitive properties are copied by reference.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.11.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @sig [Idx] -> {k: v} -> {k: v}
+ * @param {Array} path The path to the value to omit
+ * @param {Object} obj The object to clone
+ * @return {Object} A new object without the property at path
+ * @see R.assocPath
+ * @example
+ *
+ * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
+ */
+ var dissocPath = _curry2(function dissocPath(path, obj) {
+ switch (path.length) {
+ case 0:
return obj;
- } else if (_isInteger(head) && _isArray(obj)) {
- return update(head, dissocPath(tail, obj[head]), obj);
- } else {
- return assoc(head, dissocPath(tail, obj[head]), obj);
- }
- }
-});
-
-/**
- * Divides two numbers. Equivalent to `a / b`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} a The first value.
- * @param {Number} b The second value.
- * @return {Number} The result of `a / b`.
- * @see R.multiply
- * @example
- *
- * R.divide(71, 100); //=> 0.71
- *
- * const half = R.divide(R.__, 2);
- * half(42); //=> 21
- *
- * const reciprocal = R.divide(1);
- * reciprocal(4); //=> 0.25
- */
-var divide = _curry2(function divide(a, b) { return a / b; });
-
-function XDrop(n, xf) {
- this.xf = xf;
- this.n = n;
-}
-XDrop.prototype['@@transducer/init'] = _xfBase.init;
-XDrop.prototype['@@transducer/result'] = _xfBase.result;
-XDrop.prototype['@@transducer/step'] = function(result, input) {
- if (this.n > 0) {
- this.n -= 1;
- return result;
- }
- return this.xf['@@transducer/step'](result, input);
-};
-
-var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); });
-
-/**
- * Returns all but the first `n` elements of the given list, string, or
- * transducer/transformer (or object with a `drop` method).
- *
- * Dispatches to the `drop` method of the second argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Number -> [a] -> [a]
- * @sig Number -> String -> String
- * @param {Number} n
- * @param {*} list
- * @return {*} A copy of list without the first `n` elements
- * @see R.take, R.transduce, R.dropLast, R.dropWhile
- * @example
- *
- * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
- * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
- * R.drop(3, ['foo', 'bar', 'baz']); //=> []
- * R.drop(4, ['foo', 'bar', 'baz']); //=> []
- * R.drop(3, 'ramda'); //=> 'da'
- */
-var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) {
- return slice(Math.max(0, n), Infinity, xs);
-}));
-
-function XTake(n, xf) {
- this.xf = xf;
- this.n = n;
- this.i = 0;
-}
-XTake.prototype['@@transducer/init'] = _xfBase.init;
-XTake.prototype['@@transducer/result'] = _xfBase.result;
-XTake.prototype['@@transducer/step'] = function(result, input) {
- this.i += 1;
- var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input);
- return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret;
-};
-
-var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); });
-
-/**
- * Returns the first `n` elements of the given list, string, or
- * transducer/transformer (or object with a `take` method).
- *
- * Dispatches to the `take` method of the second argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Number -> [a] -> [a]
- * @sig Number -> String -> String
- * @param {Number} n
- * @param {*} list
- * @return {*}
- * @see R.drop
- * @example
- *
- * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
- * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
- * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
- * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
- * R.take(3, 'ramda'); //=> 'ram'
- *
- * const personnel = [
- * 'Dave Brubeck',
- * 'Paul Desmond',
- * 'Eugene Wright',
- * 'Joe Morello',
- * 'Gerry Mulligan',
- * 'Bob Bates',
- * 'Joe Dodge',
- * 'Ron Crotty'
- * ];
- *
- * const takeFive = R.take(5);
- * takeFive(personnel);
- * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']
- * @symb R.take(-1, [a, b]) = [a, b]
- * @symb R.take(0, [a, b]) = []
- * @symb R.take(1, [a, b]) = [a]
- * @symb R.take(2, [a, b]) = [a, b]
- */
-var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) {
- return slice(0, n < 0 ? Infinity : n, xs);
-}));
-
-function dropLast$2(n, xs) {
- return take(n < xs.length ? xs.length - n : 0, xs);
-}
-
-function XDropLast(n, xf) {
- this.xf = xf;
- this.pos = 0;
- this.full = false;
- this.acc = new Array(n);
-}
-XDropLast.prototype['@@transducer/init'] = _xfBase.init;
-XDropLast.prototype['@@transducer/result'] = function(result) {
- this.acc = null;
- return this.xf['@@transducer/result'](result);
-};
-XDropLast.prototype['@@transducer/step'] = function(result, input) {
- if (this.full) {
- result = this.xf['@@transducer/step'](result, this.acc[this.pos]);
- }
- this.store(input);
- return result;
-};
-XDropLast.prototype.store = function(input) {
- this.acc[this.pos] = input;
- this.pos += 1;
- if (this.pos === this.acc.length) {
- this.pos = 0;
- this.full = true;
- }
-};
-
-var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); });
-
-/**
- * Returns a list containing all but the last `n` elements of the given `list`.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig Number -> [a] -> [a]
- * @sig Number -> String -> String
- * @param {Number} n The number of elements of `list` to skip.
- * @param {Array} list The list of elements to consider.
- * @return {Array} A copy of the list with only the first `list.length - n` elements
- * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile
- * @example
- *
- * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
- * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
- * R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
- * R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
- * R.dropLast(3, 'ramda'); //=> 'ra'
- */
-var dropLast = _curry2(_dispatchable([], _xdropLast, dropLast$2));
-
-function dropLastWhile$2(pred, xs) {
- var idx = xs.length - 1;
- while (idx >= 0 && pred(xs[idx])) {
- idx -= 1;
- }
- return slice(0, idx + 1, xs);
-}
-
-function XDropLastWhile(fn, xf) {
- this.f = fn;
- this.retained = [];
- this.xf = xf;
-}
-XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init;
-XDropLastWhile.prototype['@@transducer/result'] = function(result) {
- this.retained = null;
- return this.xf['@@transducer/result'](result);
-};
-XDropLastWhile.prototype['@@transducer/step'] = function(result, input) {
- return this.f(input) ? this.retain(result, input)
- : this.flush(result, input);
-};
-XDropLastWhile.prototype.flush = function(result, input) {
- result = _reduce(
- this.xf['@@transducer/step'],
- result,
- this.retained
- );
- this.retained = [];
- return this.xf['@@transducer/step'](result, input);
-};
-XDropLastWhile.prototype.retain = function(result, input) {
- this.retained.push(input);
- return result;
-};
-
-var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); });
-
-/**
- * Returns a new list excluding all the tailing elements of a given list which
- * satisfy the supplied predicate function. It passes each value from the right
- * to the supplied predicate function, skipping elements until the predicate
- * function returns a `falsy` value. The predicate function is applied to one argument:
- * *(value)*.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> [a]
- * @sig (a -> Boolean) -> String -> String
- * @param {Function} predicate The function to be called on each element
- * @param {Array} xs The collection to iterate over.
- * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`.
- * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile
- * @example
- *
- * const lteThree = x => x <= 3;
- *
- * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
- *
- * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd'
- */
-var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile$2));
-
-function XDropRepeatsWith(pred, xf) {
- this.xf = xf;
- this.pred = pred;
- this.lastValue = undefined;
- this.seenFirstValue = false;
-}
-
-XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
-XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
-XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) {
- var sameAsLast = false;
- if (!this.seenFirstValue) {
- this.seenFirstValue = true;
- } else if (this.pred(this.lastValue, input)) {
- sameAsLast = true;
- }
- this.lastValue = input;
- return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
-};
-
-var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); });
-
-/**
- * Returns the last element of the given list or string.
- *
- * @func
- * @memberOf R
- * @since v0.1.4
- * @category List
- * @sig [a] -> a | Undefined
- * @sig String -> String
- * @param {*} list
- * @return {*}
- * @see R.init, R.head, R.tail
- * @example
- *
- * R.last(['fi', 'fo', 'fum']); //=> 'fum'
- * R.last([]); //=> undefined
- *
- * R.last('abc'); //=> 'c'
- * R.last(''); //=> ''
- */
-var last = nth(-1);
-
-/**
- * Returns a new list without any consecutively repeating elements. Equality is
- * determined by applying the supplied predicate to each pair of consecutive elements. The
- * first element in a series of equal elements will be preserved.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category List
- * @sig ((a, a) -> Boolean) -> [a] -> [a]
- * @param {Function} pred A predicate used to test whether two items are equal.
- * @param {Array} list The array to consider.
- * @return {Array} `list` without repeating elements.
- * @see R.transduce
- * @example
- *
- * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
- * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
- */
-var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
- var result = [];
- var idx = 1;
- var len = list.length;
- if (len !== 0) {
- result[0] = list[0];
- while (idx < len) {
- if (!pred(last(result), list[idx])) {
- result[result.length] = list[idx];
- }
- idx += 1;
- }
- }
- return result;
-}));
-
-/**
- * Returns a new list without any consecutively repeating elements.
- * [`R.equals`](#equals) is used to determine equality.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category List
- * @sig [a] -> [a]
- * @param {Array} list The array to consider.
- * @return {Array} `list` without repeating elements.
- * @see R.transduce
- * @example
- *
- * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
- */
-var dropRepeats = _curry1(_dispatchable([],
- _xdropRepeatsWith(equals),
- dropRepeatsWith(equals)));
-
-function XDropWhile(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XDropWhile.prototype['@@transducer/init'] = _xfBase.init;
-XDropWhile.prototype['@@transducer/result'] = _xfBase.result;
-XDropWhile.prototype['@@transducer/step'] = function(result, input) {
- if (this.f) {
- if (this.f(input)) {
- return result;
- }
- this.f = null;
- }
- return this.xf['@@transducer/step'](result, input);
-};
-
-var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); });
-
-/**
- * Returns a new list excluding the leading elements of a given list which
- * satisfy the supplied predicate function. It passes each value to the supplied
- * predicate function, skipping elements while the predicate function returns
- * `true`. The predicate function is applied to one argument: *(value)*.
- *
- * Dispatches to the `dropWhile` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> [a]
- * @sig (a -> Boolean) -> String -> String
- * @param {Function} fn The function called per iteration.
- * @param {Array} xs The collection to iterate over.
- * @return {Array} A new array.
- * @see R.takeWhile, R.transduce, R.addIndex
- * @example
- *
- * const lteTwo = x => x <= 2;
- *
- * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
- *
- * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'
- */
-var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) {
- var idx = 0;
- var len = xs.length;
- while (idx < len && pred(xs[idx])) {
- idx += 1;
- }
- return slice(idx, Infinity, xs);
-}));
-
-/**
- * Returns `true` if one or both of its arguments are `true`. Returns `false`
- * if both arguments are `false`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Logic
- * @sig a -> b -> a | b
- * @param {Any} a
- * @param {Any} b
- * @return {Any} the first argument if truthy, otherwise the second argument.
- * @see R.either
- * @example
- *
- * R.or(true, true); //=> true
- * R.or(true, false); //=> true
- * R.or(false, true); //=> true
- * R.or(false, false); //=> false
- */
-var or = _curry2(function or(a, b) {
- return a || b;
-});
-
-/**
- * A function wrapping calls to the two functions in an `||` operation,
- * returning the result of the first function if it is truth-y and the result
- * of the second function otherwise. Note that this is short-circuited,
- * meaning that the second function will not be invoked if the first returns a
- * truth-y value.
- *
- * In addition to functions, `R.either` also accepts any fantasy-land compatible
- * applicative functor.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category Logic
- * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
- * @param {Function} f a predicate
- * @param {Function} g another predicate
- * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together.
- * @see R.or
- * @example
- *
- * const gt10 = x => x > 10;
- * const even = x => x % 2 === 0;
- * const f = R.either(gt10, even);
- * f(101); //=> true
- * f(8); //=> true
- *
- * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55)
- * R.either([false, false, 'a'], [11]) // => [11, 11, "a"]
- */
-var either = _curry2(function either(f, g) {
- return _isFunction(f) ?
- function _either() {
- return f.apply(this, arguments) || g.apply(this, arguments);
- } :
- lift(or)(f, g);
-});
-
-/**
- * Returns the empty value of its argument's type. Ramda defines the empty
- * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
- * types are supported if they define `.empty`,
- * `.prototype.empty` or implement the
- * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
- *
- * Dispatches to the `empty` method of the first argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category Function
- * @sig a -> a
- * @param {*} x
- * @return {*}
- * @example
- *
- * R.empty(Just(42)); //=> Nothing()
- * R.empty([1, 2, 3]); //=> []
- * R.empty('unicorns'); //=> ''
- * R.empty({x: 1, y: 2}); //=> {}
- */
-var empty = _curry1(function empty(x) {
- return (
- (x != null && typeof x['fantasy-land/empty'] === 'function') ?
- x['fantasy-land/empty']() :
- (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') ?
- x.constructor['fantasy-land/empty']() :
- (x != null && typeof x.empty === 'function') ?
- x.empty() :
- (x != null && x.constructor != null && typeof x.constructor.empty === 'function') ?
- x.constructor.empty() :
- _isArray(x) ?
- [] :
- _isString(x) ?
- '' :
- _isObject(x) ?
- {} :
- _isArguments(x) ?
- (function() { return arguments; }()) :
- // else
- void 0
- );
-});
-
-/**
- * Returns a new list containing the last `n` elements of the given list.
- * If `n > list.length`, returns a list of `list.length` elements.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig Number -> [a] -> [a]
- * @sig Number -> String -> String
- * @param {Number} n The number of elements to return.
- * @param {Array} xs The collection to consider.
- * @return {Array}
- * @see R.dropLast
- * @example
- *
- * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
- * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
- * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
- * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
- * R.takeLast(3, 'ramda'); //=> 'mda'
- */
-var takeLast = _curry2(function takeLast(n, xs) {
- return drop(n >= 0 ? xs.length - n : 0, xs);
-});
-
-/**
- * Checks if a list ends with the provided sublist.
- *
- * Similarly, checks if a string ends with the provided substring.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category List
- * @sig [a] -> [a] -> Boolean
- * @sig String -> String -> Boolean
- * @param {*} suffix
- * @param {*} list
- * @return {Boolean}
- * @see R.startsWith
- * @example
- *
- * R.endsWith('c', 'abc') //=> true
- * R.endsWith('b', 'abc') //=> false
- * R.endsWith(['c'], ['a', 'b', 'c']) //=> true
- * R.endsWith(['b'], ['a', 'b', 'c']) //=> false
- */
-var endsWith = _curry2(function(suffix, list) {
- return equals(takeLast(suffix.length, list), suffix);
-});
-
-/**
- * Takes a function and two values in its domain and returns `true` if the
- * values map to the same value in the codomain; `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category Relation
- * @sig (a -> b) -> a -> a -> Boolean
- * @param {Function} f
- * @param {*} x
- * @param {*} y
- * @return {Boolean}
- * @example
- *
- * R.eqBy(Math.abs, 5, -5); //=> true
- */
-var eqBy = _curry3(function eqBy(f, x, y) {
- return equals(f(x), f(y));
-});
-
-/**
- * Reports whether two objects have the same value, in [`R.equals`](#equals)
- * terms, for the specified property. Useful as a curried predicate.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig k -> {k: v} -> {k: v} -> Boolean
- * @param {String} prop The name of the property to compare
- * @param {Object} obj1
- * @param {Object} obj2
- * @return {Boolean}
- *
- * @example
- *
- * const o1 = { a: 1, b: 2, c: 3, d: 4 };
- * const o2 = { a: 10, b: 20, c: 3, d: 40 };
- * R.eqProps('a', o1, o2); //=> false
- * R.eqProps('c', o1, o2); //=> true
- */
-var eqProps = _curry3(function eqProps(prop, obj1, obj2) {
- return equals(obj1[prop], obj2[prop]);
-});
-
-/**
- * Creates a new object by recursively evolving a shallow copy of `object`,
- * according to the `transformation` functions. All non-primitive properties
- * are copied by reference.
- *
- * A `transformation` function will not be invoked if its corresponding key
- * does not exist in the evolved object.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Object
- * @sig {k: (v -> v)} -> {k: v} -> {k: v}
- * @param {Object} transformations The object specifying transformation functions to apply
- * to the object.
- * @param {Object} object The object to be transformed.
- * @return {Object} The transformed object.
- * @example
- *
- * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
- * const transformations = {
- * firstName: R.trim,
- * lastName: R.trim, // Will not get invoked.
- * data: {elapsed: R.add(1), remaining: R.add(-1)}
- * };
- * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
- */
-var evolve = _curry2(function evolve(transformations, object) {
- var result = object instanceof Array ? [] : {};
- var transformation, key, type;
- for (key in object) {
- transformation = transformations[key];
- type = typeof transformation;
- result[key] = type === 'function' ? transformation(object[key])
- : transformation && type === 'object' ? evolve(transformation, object[key])
- : object[key];
- }
- return result;
-});
-
-function XFind(f, xf) {
- this.xf = xf;
- this.f = f;
- this.found = false;
-}
-XFind.prototype['@@transducer/init'] = _xfBase.init;
-XFind.prototype['@@transducer/result'] = function(result) {
- if (!this.found) {
- result = this.xf['@@transducer/step'](result, void 0);
- }
- return this.xf['@@transducer/result'](result);
-};
-XFind.prototype['@@transducer/step'] = function(result, input) {
- if (this.f(input)) {
- this.found = true;
- result = _reduced(this.xf['@@transducer/step'](result, input));
- }
- return result;
-};
-
-var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); });
-
-/**
- * Returns the first element of the list which matches the predicate, or
- * `undefined` if no element matches.
- *
- * Dispatches to the `find` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> a | undefined
- * @param {Function} fn The predicate function used to determine if the element is the
- * desired one.
- * @param {Array} list The array to consider.
- * @return {Object} The element found, or `undefined`.
- * @see R.transduce
- * @example
- *
- * const xs = [{a: 1}, {a: 2}, {a: 3}];
- * R.find(R.propEq('a', 2))(xs); //=> {a: 2}
- * R.find(R.propEq('a', 4))(xs); //=> undefined
- */
-var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) {
- var idx = 0;
- var len = list.length;
- while (idx < len) {
- if (fn(list[idx])) {
- return list[idx];
- }
- idx += 1;
- }
-}));
-
-function XFindIndex(f, xf) {
- this.xf = xf;
- this.f = f;
- this.idx = -1;
- this.found = false;
-}
-XFindIndex.prototype['@@transducer/init'] = _xfBase.init;
-XFindIndex.prototype['@@transducer/result'] = function(result) {
- if (!this.found) {
- result = this.xf['@@transducer/step'](result, -1);
- }
- return this.xf['@@transducer/result'](result);
-};
-XFindIndex.prototype['@@transducer/step'] = function(result, input) {
- this.idx += 1;
- if (this.f(input)) {
- this.found = true;
- result = _reduced(this.xf['@@transducer/step'](result, this.idx));
- }
- return result;
-};
-
-var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); });
-
-/**
- * Returns the index of the first element of the list which matches the
- * predicate, or `-1` if no element matches.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category List
- * @sig (a -> Boolean) -> [a] -> Number
- * @param {Function} fn The predicate function used to determine if the element is the
- * desired one.
- * @param {Array} list The array to consider.
- * @return {Number} The index of the element found, or `-1`.
- * @see R.transduce
- * @example
- *
- * const xs = [{a: 1}, {a: 2}, {a: 3}];
- * R.findIndex(R.propEq('a', 2))(xs); //=> 1
- * R.findIndex(R.propEq('a', 4))(xs); //=> -1
- */
-var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) {
- var idx = 0;
- var len = list.length;
- while (idx < len) {
- if (fn(list[idx])) {
- return idx;
- }
- idx += 1;
- }
- return -1;
-}));
-
-function XFindLast(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XFindLast.prototype['@@transducer/init'] = _xfBase.init;
-XFindLast.prototype['@@transducer/result'] = function(result) {
- return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last));
-};
-XFindLast.prototype['@@transducer/step'] = function(result, input) {
- if (this.f(input)) {
- this.last = input;
- }
- return result;
-};
-
-var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); });
-
-/**
- * Returns the last element of the list which matches the predicate, or
- * `undefined` if no element matches.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category List
- * @sig (a -> Boolean) -> [a] -> a | undefined
- * @param {Function} fn The predicate function used to determine if the element is the
- * desired one.
- * @param {Array} list The array to consider.
- * @return {Object} The element found, or `undefined`.
- * @see R.transduce
- * @example
- *
- * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
- * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
- * R.findLast(R.propEq('a', 4))(xs); //=> undefined
- */
-var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) {
- var idx = list.length - 1;
- while (idx >= 0) {
- if (fn(list[idx])) {
- return list[idx];
- }
- idx -= 1;
- }
-}));
-
-function XFindLastIndex(f, xf) {
- this.xf = xf;
- this.f = f;
- this.idx = -1;
- this.lastIdx = -1;
-}
-XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init;
-XFindLastIndex.prototype['@@transducer/result'] = function(result) {
- return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx));
-};
-XFindLastIndex.prototype['@@transducer/step'] = function(result, input) {
- this.idx += 1;
- if (this.f(input)) {
- this.lastIdx = this.idx;
- }
- return result;
-};
-
-var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); });
-
-/**
- * Returns the index of the last element of the list which matches the
- * predicate, or `-1` if no element matches.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category List
- * @sig (a -> Boolean) -> [a] -> Number
- * @param {Function} fn The predicate function used to determine if the element is the
- * desired one.
- * @param {Array} list The array to consider.
- * @return {Number} The index of the element found, or `-1`.
- * @see R.transduce
- * @example
- *
- * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
- * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
- * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
- */
-var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) {
- var idx = list.length - 1;
- while (idx >= 0) {
- if (fn(list[idx])) {
- return idx;
- }
- idx -= 1;
- }
- return -1;
-}));
-
-/**
- * Returns a new list by pulling every item out of it (and all its sub-arrays)
- * and putting them in a new array, depth-first.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [b]
- * @param {Array} list The array to consider.
- * @return {Array} The flattened list.
- * @see R.unnest
- * @example
- *
- * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
- * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
- */
-var flatten = _curry1(_makeFlat(true));
-
-/**
- * Returns a new function much like the supplied one, except that the first two
- * arguments' order is reversed.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z)
- * @param {Function} fn The function to invoke with its first two parameters reversed.
- * @return {*} The result of invoking `fn` with its first two parameters' order reversed.
- * @example
- *
- * const mergeThree = (a, b, c) => [].concat(a, b, c);
- *
- * mergeThree(1, 2, 3); //=> [1, 2, 3]
- *
- * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
- * @symb R.flip(f)(a, b, c) = f(b, a, c)
- */
-var flip = _curry1(function flip(fn) {
- return curryN(fn.length, function(a, b) {
- var args = Array.prototype.slice.call(arguments, 0);
- args[0] = b;
- args[1] = a;
- return fn.apply(this, args);
+ case 1:
+ return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj);
+ default:
+ var head = path[0];
+ var tail = Array.prototype.slice.call(path, 1);
+ if (obj[head] == null) {
+ return obj;
+ } else if (_isInteger(head) && _isArray(obj)) {
+ return update(head, dissocPath(tail, obj[head]), obj);
+ } else {
+ return assoc(head, dissocPath(tail, obj[head]), obj);
+ }
+ }
});
-});
-/**
- * Iterate over an input `list`, calling a provided function `fn` for each
- * element in the list.
- *
- * `fn` receives one argument: *(value)*.
- *
- * Note: `R.forEach` does not skip deleted or unassigned indices (sparse
- * arrays), unlike the native `Array.prototype.forEach` method. For more
- * details on this behavior, see:
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description
- *
- * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns
- * the original array. In some libraries this function is named `each`.
- *
- * Dispatches to the `forEach` method of the second argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category List
- * @sig (a -> *) -> [a] -> [a]
- * @param {Function} fn The function to invoke. Receives one argument, `value`.
- * @param {Array} list The list to iterate over.
- * @return {Array} The original list.
- * @see R.addIndex
- * @example
- *
- * const printXPlusFive = x => console.log(x + 5);
- * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
- * // logs 6
- * // logs 7
- * // logs 8
- * @symb R.forEach(f, [a, b, c]) = [a, b, c]
- */
-var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) {
- var len = list.length;
- var idx = 0;
- while (idx < len) {
- fn(list[idx]);
- idx += 1;
- }
- return list;
-}));
+ /**
+ * Divides two numbers. Equivalent to `a / b`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} a The first value.
+ * @param {Number} b The second value.
+ * @return {Number} The result of `a / b`.
+ * @see R.multiply
+ * @example
+ *
+ * R.divide(71, 100); //=> 0.71
+ *
+ * const half = R.divide(R.__, 2);
+ * half(42); //=> 21
+ *
+ * const reciprocal = R.divide(1);
+ * reciprocal(4); //=> 0.25
+ */
+ var divide = _curry2(function divide(a, b) {
+ return a / b;
+ });
-/**
- * Iterate over an input `object`, calling a provided function `fn` for each
- * key and value in the object.
- *
- * `fn` receives three argument: *(value, key, obj)*.
- *
- * @func
- * @memberOf R
- * @since v0.23.0
- * @category Object
- * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
- * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
- * @param {Object} obj The object to iterate over.
- * @return {Object} The original object.
- * @example
- *
- * const printKeyConcatValue = (value, key) => console.log(key + ':' + value);
- * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
- * // logs x:1
- * // logs y:2
- * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
- */
-var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) {
- var keyList = keys(obj);
- var idx = 0;
- while (idx < keyList.length) {
- var key = keyList[idx];
- fn(obj[key], key, obj);
- idx += 1;
+ function XDrop(n, xf) {
+ this.xf = xf;
+ this.n = n;
}
- return obj;
-});
+ XDrop.prototype['@@transducer/init'] = _xfBase.init;
+ XDrop.prototype['@@transducer/result'] = _xfBase.result;
+ XDrop.prototype['@@transducer/step'] = function (result, input) {
+ if (this.n > 0) {
+ this.n -= 1;
+ return result;
+ }
+ return this.xf['@@transducer/step'](result, input);
+ };
-/**
- * Creates a new object from a list key-value pairs. If a key appears in
- * multiple pairs, the rightmost pair is included in the object.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category List
- * @sig [[k,v]] -> {k: v}
- * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
- * @return {Object} The object made by pairing up `keys` and `values`.
- * @see R.toPairs, R.pair
- * @example
- *
- * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
- */
-var fromPairs = _curry1(function fromPairs(pairs) {
- var result = {};
- var idx = 0;
- while (idx < pairs.length) {
- result[pairs[idx][0]] = pairs[idx][1];
- idx += 1;
- }
- return result;
-});
+ var _xdrop = _curry2(function _xdrop(n, xf) {
+ return new XDrop(n, xf);
+ });
-/**
- * Splits a list into sub-lists stored in an object, based on the result of
- * calling a String-returning function on each element, and grouping the
- * results according to values returned.
- *
- * Dispatches to the `groupBy` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig (a -> String) -> [a] -> {String: [a]}
- * @param {Function} fn Function :: a -> String
- * @param {Array} list The array to group
- * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements
- * that produced that key when passed to `fn`.
- * @see R.reduceBy, R.transduce
- * @example
- *
- * const byGrade = R.groupBy(function(student) {
- * const score = student.score;
- * return score < 65 ? 'F' :
- * score < 70 ? 'D' :
- * score < 80 ? 'C' :
- * score < 90 ? 'B' : 'A';
- * });
- * const students = [{name: 'Abby', score: 84},
- * {name: 'Eddy', score: 58},
- * // ...
- * {name: 'Jack', score: 69}];
- * byGrade(students);
- * // {
- * // 'A': [{name: 'Dianne', score: 99}],
- * // 'B': [{name: 'Abby', score: 84}]
- * // // ...,
- * // 'F': [{name: 'Eddy', score: 58}]
- * // }
- */
-var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) {
- if (acc == null) {
- acc = [];
- }
- acc.push(item);
- return acc;
-}, null)));
-
-/**
- * Takes a list and returns a list of lists where each sublist's elements are
- * all satisfied pairwise comparison according to the provided function.
- * Only adjacent elements are passed to the comparison function.
- *
- * @func
- * @memberOf R
- * @since v0.21.0
- * @category List
- * @sig ((a, a) → Boolean) → [a] → [[a]]
- * @param {Function} fn Function for determining whether two given (adjacent)
- * elements should be in the same group
- * @param {Array} list The array to group. Also accepts a string, which will be
- * treated as a list of characters.
- * @return {List} A list that contains sublists of elements,
- * whose concatenations are equal to the original list.
- * @example
- *
- * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
- * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]
- *
- * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
- * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]
- *
- * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
- * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]
- *
- * R.groupWith(R.eqBy(isVowel), 'aestiou')
- * //=> ['ae', 'st', 'iou']
- */
-var groupWith = _curry2(function(fn, list) {
- var res = [];
- var idx = 0;
- var len = list.length;
- while (idx < len) {
- var nextidx = idx + 1;
- while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) {
- nextidx += 1;
- }
- res.push(list.slice(idx, nextidx));
- idx = nextidx;
- }
- return res;
-});
+ /**
+ * Returns all but the first `n` elements of the given list, string, or
+ * transducer/transformer (or object with a `drop` method).
+ *
+ * Dispatches to the `drop` method of the second argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Number -> [a] -> [a]
+ * @sig Number -> String -> String
+ * @param {Number} n
+ * @param {*} list
+ * @return {*} A copy of list without the first `n` elements
+ * @see R.take, R.transduce, R.dropLast, R.dropWhile
+ * @example
+ *
+ * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
+ * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
+ * R.drop(3, ['foo', 'bar', 'baz']); //=> []
+ * R.drop(4, ['foo', 'bar', 'baz']); //=> []
+ * R.drop(3, 'ramda'); //=> 'da'
+ */
+ var drop = _curry2(
+ _dispatchable(['drop'], _xdrop, function drop(n, xs) {
+ return slice(Math.max(0, n), Infinity, xs);
+ })
+ );
-/**
- * Returns `true` if the first argument is greater than the second; `false`
- * otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> Boolean
- * @param {*} a
- * @param {*} b
- * @return {Boolean}
- * @see R.lt
- * @example
- *
- * R.gt(2, 1); //=> true
- * R.gt(2, 2); //=> false
- * R.gt(2, 3); //=> false
- * R.gt('a', 'z'); //=> false
- * R.gt('z', 'a'); //=> true
- */
-var gt = _curry2(function gt(a, b) { return a > b; });
+ function XTake(n, xf) {
+ this.xf = xf;
+ this.n = n;
+ this.i = 0;
+ }
+ XTake.prototype['@@transducer/init'] = _xfBase.init;
+ XTake.prototype['@@transducer/result'] = _xfBase.result;
+ XTake.prototype['@@transducer/step'] = function (result, input) {
+ this.i += 1;
+ var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input);
+ return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret;
+ };
-/**
- * Returns `true` if the first argument is greater than or equal to the second;
- * `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> Boolean
- * @param {Number} a
- * @param {Number} b
- * @return {Boolean}
- * @see R.lte
- * @example
- *
- * R.gte(2, 1); //=> true
- * R.gte(2, 2); //=> true
- * R.gte(2, 3); //=> false
- * R.gte('a', 'z'); //=> false
- * R.gte('z', 'a'); //=> true
- */
-var gte = _curry2(function gte(a, b) { return a >= b; });
+ var _xtake = _curry2(function _xtake(n, xf) {
+ return new XTake(n, xf);
+ });
-/**
- * Returns whether or not a path exists in an object. Only the object's
- * own properties are checked.
- *
- * @func
- * @memberOf R
- * @since v0.26.0
- * @category Object
- * @typedefn Idx = String | Int
- * @sig [Idx] -> {a} -> Boolean
- * @param {Array} path The path to use.
- * @param {Object} obj The object to check the path in.
- * @return {Boolean} Whether the path exists.
- * @see R.has
- * @example
- *
- * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true
- * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true
- * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false
- * R.hasPath(['a', 'b'], {}); // => false
- */
-var hasPath = _curry2(function hasPath(_path, obj) {
- if (_path.length === 0) {
- return false;
+ /**
+ * Returns the first `n` elements of the given list, string, or
+ * transducer/transformer (or object with a `take` method).
+ *
+ * Dispatches to the `take` method of the second argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Number -> [a] -> [a]
+ * @sig Number -> String -> String
+ * @param {Number} n
+ * @param {*} list
+ * @return {*}
+ * @see R.drop
+ * @example
+ *
+ * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
+ * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
+ * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
+ * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
+ * R.take(3, 'ramda'); //=> 'ram'
+ *
+ * const personnel = [
+ * 'Dave Brubeck',
+ * 'Paul Desmond',
+ * 'Eugene Wright',
+ * 'Joe Morello',
+ * 'Gerry Mulligan',
+ * 'Bob Bates',
+ * 'Joe Dodge',
+ * 'Ron Crotty'
+ * ];
+ *
+ * const takeFive = R.take(5);
+ * takeFive(personnel);
+ * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']
+ * @symb R.take(-1, [a, b]) = [a, b]
+ * @symb R.take(0, [a, b]) = []
+ * @symb R.take(1, [a, b]) = [a]
+ * @symb R.take(2, [a, b]) = [a, b]
+ */
+ var take = _curry2(
+ _dispatchable(['take'], _xtake, function take(n, xs) {
+ return slice(0, n < 0 ? Infinity : n, xs);
+ })
+ );
+
+ function dropLast$2(n, xs) {
+ return take(n < xs.length ? xs.length - n : 0, xs);
}
- var val = obj;
- var idx = 0;
- while (idx < _path.length) {
- if (_has(_path[idx], val)) {
- val = val[_path[idx]];
- idx += 1;
- } else {
- return false;
- }
+
+ function XDropLast(n, xf) {
+ this.xf = xf;
+ this.pos = 0;
+ this.full = false;
+ this.acc = new Array(n);
}
- return true;
-});
+ XDropLast.prototype['@@transducer/init'] = _xfBase.init;
+ XDropLast.prototype['@@transducer/result'] = function (result) {
+ this.acc = null;
+ return this.xf['@@transducer/result'](result);
+ };
+ XDropLast.prototype['@@transducer/step'] = function (result, input) {
+ if (this.full) {
+ result = this.xf['@@transducer/step'](result, this.acc[this.pos]);
+ }
+ this.store(input);
+ return result;
+ };
+ XDropLast.prototype.store = function (input) {
+ this.acc[this.pos] = input;
+ this.pos += 1;
+ if (this.pos === this.acc.length) {
+ this.pos = 0;
+ this.full = true;
+ }
+ };
-/**
- * Returns whether or not an object has an own property with the specified name
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Object
- * @sig s -> {s: x} -> Boolean
- * @param {String} prop The name of the property to check for.
- * @param {Object} obj The object to query.
- * @return {Boolean} Whether the property exists.
- * @example
- *
- * const hasName = R.has('name');
- * hasName({name: 'alice'}); //=> true
- * hasName({name: 'bob'}); //=> true
- * hasName({}); //=> false
- *
- * const point = {x: 0, y: 0};
- * const pointHas = R.has(R.__, point);
- * pointHas('x'); //=> true
- * pointHas('y'); //=> true
- * pointHas('z'); //=> false
- */
-var has = _curry2(function has(prop, obj) {
- return hasPath([prop], obj);
-});
+ var _xdropLast = _curry2(function _xdropLast(n, xf) {
+ return new XDropLast(n, xf);
+ });
-/**
- * Returns whether or not an object or its prototype chain has a property with
- * the specified name
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Object
- * @sig s -> {s: x} -> Boolean
- * @param {String} prop The name of the property to check for.
- * @param {Object} obj The object to query.
- * @return {Boolean} Whether the property exists.
- * @example
- *
- * function Rectangle(width, height) {
- * this.width = width;
- * this.height = height;
- * }
- * Rectangle.prototype.area = function() {
- * return this.width * this.height;
- * };
- *
- * const square = new Rectangle(2, 2);
- * R.hasIn('width', square); //=> true
- * R.hasIn('area', square); //=> true
- */
-var hasIn = _curry2(function hasIn(prop, obj) {
- return prop in obj;
-});
+ /**
+ * Returns a list containing all but the last `n` elements of the given `list`.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig Number -> [a] -> [a]
+ * @sig Number -> String -> String
+ * @param {Number} n The number of elements of `list` to skip.
+ * @param {Array} list The list of elements to consider.
+ * @return {Array} A copy of the list with only the first `list.length - n` elements
+ * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile
+ * @example
+ *
+ * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
+ * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
+ * R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
+ * R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
+ * R.dropLast(3, 'ramda'); //=> 'ra'
+ */
+ var dropLast = _curry2(_dispatchable([], _xdropLast, dropLast$2));
+
+ function dropLastWhile$2(pred, xs) {
+ var idx = xs.length - 1;
+ while (idx >= 0 && pred(xs[idx])) {
+ idx -= 1;
+ }
+ return slice(0, idx + 1, xs);
+ }
-/**
- * Returns true if its arguments are identical, false otherwise. Values are
- * identical if they reference the same memory. `NaN` is identical to `NaN`;
- * `0` and `-0` are not identical.
- *
- * Note this is merely a curried version of ES6 `Object.is`.
- *
- * @func
- * @memberOf R
- * @since v0.15.0
- * @category Relation
- * @sig a -> a -> Boolean
- * @param {*} a
- * @param {*} b
- * @return {Boolean}
- * @example
- *
- * const o = {};
- * R.identical(o, o); //=> true
- * R.identical(1, 1); //=> true
- * R.identical(1, '1'); //=> false
- * R.identical([], []); //=> false
- * R.identical(0, -0); //=> false
- * R.identical(NaN, NaN); //=> true
- */
-var identical = _curry2(_objectIs$1);
+ function XDropLastWhile(fn, xf) {
+ this.f = fn;
+ this.retained = [];
+ this.xf = xf;
+ }
+ XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init;
+ XDropLastWhile.prototype['@@transducer/result'] = function (result) {
+ this.retained = null;
+ return this.xf['@@transducer/result'](result);
+ };
+ XDropLastWhile.prototype['@@transducer/step'] = function (result, input) {
+ return this.f(input) ? this.retain(result, input) : this.flush(result, input);
+ };
+ XDropLastWhile.prototype.flush = function (result, input) {
+ result = _reduce(this.xf['@@transducer/step'], result, this.retained);
+ this.retained = [];
+ return this.xf['@@transducer/step'](result, input);
+ };
+ XDropLastWhile.prototype.retain = function (result, input) {
+ this.retained.push(input);
+ return result;
+ };
-/**
- * Creates a function that will process either the `onTrue` or the `onFalse`
- * function depending upon the result of the `condition` predicate.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Logic
- * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *)
- * @param {Function} condition A predicate function
- * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value.
- * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value.
- * @return {Function} A new function that will process either the `onTrue` or the `onFalse`
- * function depending upon the result of the `condition` predicate.
- * @see R.unless, R.when, R.cond
- * @example
- *
- * const incCount = R.ifElse(
- * R.has('count'),
- * R.over(R.lensProp('count'), R.inc),
- * R.assoc('count', 1)
- * );
- * incCount({}); //=> { count: 1 }
- * incCount({ count: 1 }); //=> { count: 2 }
- */
-var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) {
- return curryN(Math.max(condition.length, onTrue.length, onFalse.length),
- function _ifElse() {
- return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments);
+ var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) {
+ return new XDropLastWhile(fn, xf);
+ });
+
+ /**
+ * Returns a new list excluding all the tailing elements of a given list which
+ * satisfy the supplied predicate function. It passes each value from the right
+ * to the supplied predicate function, skipping elements until the predicate
+ * function returns a `falsy` value. The predicate function is applied to one argument:
+ * *(value)*.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> [a]
+ * @sig (a -> Boolean) -> String -> String
+ * @param {Function} predicate The function to be called on each element
+ * @param {Array} xs The collection to iterate over.
+ * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`.
+ * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile
+ * @example
+ *
+ * const lteThree = x => x <= 3;
+ *
+ * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
+ *
+ * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd'
+ */
+ var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile$2));
+
+ function XDropRepeatsWith(pred, xf) {
+ this.xf = xf;
+ this.pred = pred;
+ this.lastValue = undefined;
+ this.seenFirstValue = false;
+ }
+
+ XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
+ XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
+ XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) {
+ var sameAsLast = false;
+ if (!this.seenFirstValue) {
+ this.seenFirstValue = true;
+ } else if (this.pred(this.lastValue, input)) {
+ sameAsLast = true;
}
- );
-});
+ this.lastValue = input;
+ return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
+ };
-/**
- * Increments its argument.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Math
- * @sig Number -> Number
- * @param {Number} n
- * @return {Number} n + 1
- * @see R.dec
- * @example
- *
- * R.inc(42); //=> 43
- */
-var inc = add(1);
+ var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) {
+ return new XDropRepeatsWith(pred, xf);
+ });
-/**
- * Returns `true` if the specified value is equal, in [`R.equals`](#equals)
- * terms, to at least one element of the given list; `false` otherwise.
- * Works also with strings.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> Boolean
- * @param {Object} a The item to compare against.
- * @param {Array} list The array to consider.
- * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
- * @see R.any
- * @example
- *
- * R.includes(3, [1, 2, 3]); //=> true
- * R.includes(4, [1, 2, 3]); //=> false
- * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
- * R.includes([42], [[42]]); //=> true
- * R.includes('ba', 'banana'); //=>true
- */
-var includes = _curry2(_includes);
+ /**
+ * Returns the last element of the given list or string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.4
+ * @category List
+ * @sig [a] -> a | Undefined
+ * @sig String -> String
+ * @param {*} list
+ * @return {*}
+ * @see R.init, R.head, R.tail
+ * @example
+ *
+ * R.last(['fi', 'fo', 'fum']); //=> 'fum'
+ * R.last([]); //=> undefined
+ *
+ * R.last('abc'); //=> 'c'
+ * R.last(''); //=> ''
+ */
+ var last = nth(-1);
+
+ /**
+ * Returns a new list without any consecutively repeating elements. Equality is
+ * determined by applying the supplied predicate to each pair of consecutive elements. The
+ * first element in a series of equal elements will be preserved.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category List
+ * @sig ((a, a) -> Boolean) -> [a] -> [a]
+ * @param {Function} pred A predicate used to test whether two items are equal.
+ * @param {Array} list The array to consider.
+ * @return {Array} `list` without repeating elements.
+ * @see R.transduce
+ * @example
+ *
+ * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
+ * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
+ */
+ var dropRepeatsWith = _curry2(
+ _dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
+ var result = [];
+ var idx = 1;
+ var len = list.length;
+ if (len !== 0) {
+ result[0] = list[0];
+ while (idx < len) {
+ if (!pred(last(result), list[idx])) {
+ result[result.length] = list[idx];
+ }
+ idx += 1;
+ }
+ }
+ return result;
+ })
+ );
-/**
- * Given a function that generates a key, turns a list of objects into an
- * object indexing the objects by the given key. Note that if multiple
- * objects generate the same value for the indexing key only the last value
- * will be included in the generated object.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig (a -> String) -> [{k: v}] -> {k: {k: v}}
- * @param {Function} fn Function :: a -> String
- * @param {Array} array The array of objects to index
- * @return {Object} An object indexing each array element by the given property.
- * @example
- *
- * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
- * R.indexBy(R.prop('id'), list);
- * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
- */
-var indexBy = reduceBy(function(acc, elem) { return elem; }, null);
+ /**
+ * Returns a new list without any consecutively repeating elements.
+ * [`R.equals`](#equals) is used to determine equality.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category List
+ * @sig [a] -> [a]
+ * @param {Array} list The array to consider.
+ * @return {Array} `list` without repeating elements.
+ * @see R.transduce
+ * @example
+ *
+ * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
+ */
+ var dropRepeats = _curry1(_dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals)));
+
+ function XDropWhile(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ }
+ XDropWhile.prototype['@@transducer/init'] = _xfBase.init;
+ XDropWhile.prototype['@@transducer/result'] = _xfBase.result;
+ XDropWhile.prototype['@@transducer/step'] = function (result, input) {
+ if (this.f) {
+ if (this.f(input)) {
+ return result;
+ }
+ this.f = null;
+ }
+ return this.xf['@@transducer/step'](result, input);
+ };
-/**
- * Returns the position of the first occurrence of an item in an array, or -1
- * if the item is not included in the array. [`R.equals`](#equals) is used to
- * determine equality.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> Number
- * @param {*} target The item to find.
- * @param {Array} xs The array to search in.
- * @return {Number} the index of the target, or -1 if the target is not found.
- * @see R.lastIndexOf
- * @example
- *
- * R.indexOf(3, [1,2,3,4]); //=> 2
- * R.indexOf(10, [1,2,3,4]); //=> -1
- */
-var indexOf = _curry2(function indexOf(target, xs) {
- return typeof xs.indexOf === 'function' && !_isArray(xs) ?
- xs.indexOf(target) :
- _indexOf(xs, target, 0);
-});
+ var _xdropWhile = _curry2(function _xdropWhile(f, xf) {
+ return new XDropWhile(f, xf);
+ });
-/**
- * Returns all but the last element of the given list or string.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category List
- * @sig [a] -> [a]
- * @sig String -> String
- * @param {*} list
- * @return {*}
- * @see R.last, R.head, R.tail
- * @example
- *
- * R.init([1, 2, 3]); //=> [1, 2]
- * R.init([1, 2]); //=> [1]
- * R.init([1]); //=> []
- * R.init([]); //=> []
- *
- * R.init('abc'); //=> 'ab'
- * R.init('ab'); //=> 'a'
- * R.init('a'); //=> ''
- * R.init(''); //=> ''
- */
-var init = slice(0, -1);
+ /**
+ * Returns a new list excluding the leading elements of a given list which
+ * satisfy the supplied predicate function. It passes each value to the supplied
+ * predicate function, skipping elements while the predicate function returns
+ * `true`. The predicate function is applied to one argument: *(value)*.
+ *
+ * Dispatches to the `dropWhile` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> [a]
+ * @sig (a -> Boolean) -> String -> String
+ * @param {Function} fn The function called per iteration.
+ * @param {Array} xs The collection to iterate over.
+ * @return {Array} A new array.
+ * @see R.takeWhile, R.transduce, R.addIndex
+ * @example
+ *
+ * const lteTwo = x => x <= 2;
+ *
+ * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
+ *
+ * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'
+ */
+ var dropWhile = _curry2(
+ _dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) {
+ var idx = 0;
+ var len = xs.length;
+ while (idx < len && pred(xs[idx])) {
+ idx += 1;
+ }
+ return slice(idx, Infinity, xs);
+ })
+ );
-/**
- * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
- * `xs'` comprising each of the elements of `xs` which is equal to one or more
- * elements of `ys` according to `pred`.
- *
- * `pred` must be a binary function expecting an element from each list.
- *
- * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
- * not be significant, but since `xs'` is ordered the implementation guarantees
- * that its values are in the same order as they appear in `xs`. Duplicates are
- * not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Relation
- * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a]
- * @param {Function} pred
- * @param {Array} xs
- * @param {Array} ys
- * @return {Array}
- * @see R.intersection
- * @example
- *
- * R.innerJoin(
- * (record, id) => record.id === id,
- * [{id: 824, name: 'Richie Furay'},
- * {id: 956, name: 'Dewey Martin'},
- * {id: 313, name: 'Bruce Palmer'},
- * {id: 456, name: 'Stephen Stills'},
- * {id: 177, name: 'Neil Young'}],
- * [177, 456, 999]
- * );
- * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
- */
-var innerJoin = _curry3(function innerJoin(pred, xs, ys) {
- return _filter(function(x) { return _includesWith(pred, x, ys); }, xs);
-});
+ /**
+ * Returns `true` if one or both of its arguments are `true`. Returns `false`
+ * if both arguments are `false`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Logic
+ * @sig a -> b -> a | b
+ * @param {Any} a
+ * @param {Any} b
+ * @return {Any} the first argument if truthy, otherwise the second argument.
+ * @see R.either
+ * @example
+ *
+ * R.or(true, true); //=> true
+ * R.or(true, false); //=> true
+ * R.or(false, true); //=> true
+ * R.or(false, false); //=> false
+ */
+ var or = _curry2(function or(a, b) {
+ return a || b;
+ });
-/**
- * Inserts the supplied element into the list, at the specified `index`. _Note that
+ /**
+ * A function wrapping calls to the two functions in an `||` operation,
+ * returning the result of the first function if it is truth-y and the result
+ * of the second function otherwise. Note that this is short-circuited,
+ * meaning that the second function will not be invoked if the first returns a
+ * truth-y value.
+ *
+ * In addition to functions, `R.either` also accepts any fantasy-land compatible
+ * applicative functor.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category Logic
+ * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
+ * @param {Function} f a predicate
+ * @param {Function} g another predicate
+ * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together.
+ * @see R.or
+ * @example
+ *
+ * const gt10 = x => x > 10;
+ * const even = x => x % 2 === 0;
+ * const f = R.either(gt10, even);
+ * f(101); //=> true
+ * f(8); //=> true
+ *
+ * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55)
+ * R.either([false, false, 'a'], [11]) // => [11, 11, "a"]
+ */
+ var either = _curry2(function either(f, g) {
+ return _isFunction(f)
+ ? function _either() {
+ return f.apply(this, arguments) || g.apply(this, arguments);
+ }
+ : lift(or)(f, g);
+ });
- * this is not destructive_: it returns a copy of the list with the changes.
- * No lists have been harmed in the application of this function.
- *
- * @func
- * @memberOf R
- * @since v0.2.2
- * @category List
- * @sig Number -> a -> [a] -> [a]
- * @param {Number} index The position to insert the element
- * @param {*} elt The element to insert into the Array
- * @param {Array} list The list to insert into
- * @return {Array} A new Array with `elt` inserted at `index`.
- * @example
- *
- * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
- */
-var insert = _curry3(function insert(idx, elt, list) {
- idx = idx < list.length && idx >= 0 ? idx : list.length;
- var result = Array.prototype.slice.call(list, 0);
- result.splice(idx, 0, elt);
- return result;
-});
+ /**
+ * Returns the empty value of its argument's type. Ramda defines the empty
+ * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
+ * types are supported if they define `.empty`,
+ * `.prototype.empty` or implement the
+ * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
+ *
+ * Dispatches to the `empty` method of the first argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category Function
+ * @sig a -> a
+ * @param {*} x
+ * @return {*}
+ * @example
+ *
+ * R.empty(Just(42)); //=> Nothing()
+ * R.empty([1, 2, 3]); //=> []
+ * R.empty('unicorns'); //=> ''
+ * R.empty({x: 1, y: 2}); //=> {}
+ */
+ var empty = _curry1(function empty(x) {
+ return x != null && typeof x['fantasy-land/empty'] === 'function'
+ ? x['fantasy-land/empty']()
+ : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function'
+ ? x.constructor['fantasy-land/empty']()
+ : x != null && typeof x.empty === 'function'
+ ? x.empty()
+ : x != null && x.constructor != null && typeof x.constructor.empty === 'function'
+ ? x.constructor.empty()
+ : _isArray(x)
+ ? []
+ : _isString(x)
+ ? ''
+ : _isObject(x)
+ ? {}
+ : _isArguments(x)
+ ? (function () {
+ return arguments;
+ })()
+ : // else
+ void 0;
+ });
-/**
- * Inserts the sub-list into the list, at the specified `index`. _Note that this is not
- * destructive_: it returns a copy of the list with the changes.
- * No lists have been harmed in the application of this function.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category List
- * @sig Number -> [a] -> [a] -> [a]
- * @param {Number} index The position to insert the sub-list
- * @param {Array} elts The sub-list to insert into the Array
- * @param {Array} list The list to insert the sub-list into
- * @return {Array} A new Array with `elts` inserted starting at `index`.
- * @example
- *
- * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
- */
-var insertAll = _curry3(function insertAll(idx, elts, list) {
- idx = idx < list.length && idx >= 0 ? idx : list.length;
- return [].concat(Array.prototype.slice.call(list, 0, idx),
- elts,
- Array.prototype.slice.call(list, idx));
-});
+ /**
+ * Returns a new list containing the last `n` elements of the given list.
+ * If `n > list.length`, returns a list of `list.length` elements.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig Number -> [a] -> [a]
+ * @sig Number -> String -> String
+ * @param {Number} n The number of elements to return.
+ * @param {Array} xs The collection to consider.
+ * @return {Array}
+ * @see R.dropLast
+ * @example
+ *
+ * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
+ * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
+ * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
+ * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
+ * R.takeLast(3, 'ramda'); //=> 'mda'
+ */
+ var takeLast = _curry2(function takeLast(n, xs) {
+ return drop(n >= 0 ? xs.length - n : 0, xs);
+ });
-/**
- * Returns a new list containing only one copy of each element in the original
- * list, based upon the value returned by applying the supplied function to
- * each list element. Prefers the first item if the supplied function produces
- * the same value on two items. [`R.equals`](#equals) is used for comparison.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig (a -> b) -> [a] -> [a]
- * @param {Function} fn A function used to produce a value to use during comparisons.
- * @param {Array} list The array to consider.
- * @return {Array} The list of unique items.
- * @example
- *
- * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10]
- */
-var uniqBy = _curry2(function uniqBy(fn, list) {
- var set = new _Set();
- var result = [];
- var idx = 0;
- var appliedItem, item;
-
- while (idx < list.length) {
- item = list[idx];
- appliedItem = fn(item);
- if (set.add(appliedItem)) {
- result.push(item);
- }
- idx += 1;
- }
- return result;
-});
+ /**
+ * Checks if a list ends with the provided sublist.
+ *
+ * Similarly, checks if a string ends with the provided substring.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category List
+ * @sig [a] -> [a] -> Boolean
+ * @sig String -> String -> Boolean
+ * @param {*} suffix
+ * @param {*} list
+ * @return {Boolean}
+ * @see R.startsWith
+ * @example
+ *
+ * R.endsWith('c', 'abc') //=> true
+ * R.endsWith('b', 'abc') //=> false
+ * R.endsWith(['c'], ['a', 'b', 'c']) //=> true
+ * R.endsWith(['b'], ['a', 'b', 'c']) //=> false
+ */
+ var endsWith = _curry2(function (suffix, list) {
+ return equals(takeLast(suffix.length, list), suffix);
+ });
-/**
- * Returns a new list containing only one copy of each element in the original
- * list. [`R.equals`](#equals) is used to determine equality.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [a]
- * @param {Array} list The array to consider.
- * @return {Array} The list of unique items.
- * @example
- *
- * R.uniq([1, 1, 2, 1]); //=> [1, 2]
- * R.uniq([1, '1']); //=> [1, '1']
- * R.uniq([[42], [42]]); //=> [[42]]
- */
-var uniq = uniqBy(identity);
+ /**
+ * Takes a function and two values in its domain and returns `true` if the
+ * values map to the same value in the codomain; `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category Relation
+ * @sig (a -> b) -> a -> a -> Boolean
+ * @param {Function} f
+ * @param {*} x
+ * @param {*} y
+ * @return {Boolean}
+ * @example
+ *
+ * R.eqBy(Math.abs, 5, -5); //=> true
+ */
+ var eqBy = _curry3(function eqBy(f, x, y) {
+ return equals(f(x), f(y));
+ });
-/**
- * Combines two lists into a set (i.e. no duplicates) composed of those
- * elements common to both lists.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig [*] -> [*] -> [*]
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The list of elements found in both `list1` and `list2`.
- * @see R.innerJoin
- * @example
- *
- * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3]
- */
-var intersection = _curry2(function intersection(list1, list2) {
- var lookupList, filteredList;
- if (list1.length > list2.length) {
- lookupList = list1;
- filteredList = list2;
- } else {
- lookupList = list2;
- filteredList = list1;
- }
- return uniq(_filter(flip(_includes)(lookupList), filteredList));
-});
+ /**
+ * Reports whether two objects have the same value, in [`R.equals`](#equals)
+ * terms, for the specified property. Useful as a curried predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig k -> {k: v} -> {k: v} -> Boolean
+ * @param {String} prop The name of the property to compare
+ * @param {Object} obj1
+ * @param {Object} obj2
+ * @return {Boolean}
+ *
+ * @example
+ *
+ * const o1 = { a: 1, b: 2, c: 3, d: 4 };
+ * const o2 = { a: 10, b: 20, c: 3, d: 40 };
+ * R.eqProps('a', o1, o2); //=> false
+ * R.eqProps('c', o1, o2); //=> true
+ */
+ var eqProps = _curry3(function eqProps(prop, obj1, obj2) {
+ return equals(obj1[prop], obj2[prop]);
+ });
-/**
- * Creates a new list with the separator interposed between elements.
- *
- * Dispatches to the `intersperse` method of the second argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category List
- * @sig a -> [a] -> [a]
- * @param {*} separator The element to add to the list.
- * @param {Array} list The list to be interposed.
- * @return {Array} The new list.
- * @example
- *
- * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's']
- */
-var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) {
- var out = [];
- var idx = 0;
- var length = list.length;
- while (idx < length) {
- if (idx === length - 1) {
- out.push(list[idx]);
- } else {
- out.push(list[idx], separator);
+ /**
+ * Creates a new object by recursively evolving a shallow copy of `object`,
+ * according to the `transformation` functions. All non-primitive properties
+ * are copied by reference.
+ *
+ * A `transformation` function will not be invoked if its corresponding key
+ * does not exist in the evolved object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Object
+ * @sig {k: (v -> v)} -> {k: v} -> {k: v}
+ * @param {Object} transformations The object specifying transformation functions to apply
+ * to the object.
+ * @param {Object} object The object to be transformed.
+ * @return {Object} The transformed object.
+ * @example
+ *
+ * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
+ * const transformations = {
+ * firstName: R.trim,
+ * lastName: R.trim, // Will not get invoked.
+ * data: {elapsed: R.add(1), remaining: R.add(-1)}
+ * };
+ * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
+ */
+ var evolve = _curry2(function evolve(transformations, object) {
+ var result = object instanceof Array ? [] : {};
+ var transformation, key, type;
+ for (key in object) {
+ transformation = transformations[key];
+ type = typeof transformation;
+ result[key] =
+ type === 'function'
+ ? transformation(object[key])
+ : transformation && type === 'object'
+ ? evolve(transformation, object[key])
+ : object[key];
}
- idx += 1;
- }
- return out;
-}));
+ return result;
+ });
-// Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
-function _objectAssign(target) {
- if (target == null) {
- throw new TypeError('Cannot convert undefined or null to object');
+ function XFind(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ this.found = false;
}
+ XFind.prototype['@@transducer/init'] = _xfBase.init;
+ XFind.prototype['@@transducer/result'] = function (result) {
+ if (!this.found) {
+ result = this.xf['@@transducer/step'](result, void 0);
+ }
+ return this.xf['@@transducer/result'](result);
+ };
+ XFind.prototype['@@transducer/step'] = function (result, input) {
+ if (this.f(input)) {
+ this.found = true;
+ result = _reduced(this.xf['@@transducer/step'](result, input));
+ }
+ return result;
+ };
+
+ var _xfind = _curry2(function _xfind(f, xf) {
+ return new XFind(f, xf);
+ });
- var output = Object(target);
- var idx = 1;
- var length = arguments.length;
- while (idx < length) {
- var source = arguments[idx];
- if (source != null) {
- for (var nextKey in source) {
- if (_has(nextKey, source)) {
- output[nextKey] = source[nextKey];
+ /**
+ * Returns the first element of the list which matches the predicate, or
+ * `undefined` if no element matches.
+ *
+ * Dispatches to the `find` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> a | undefined
+ * @param {Function} fn The predicate function used to determine if the element is the
+ * desired one.
+ * @param {Array} list The array to consider.
+ * @return {Object} The element found, or `undefined`.
+ * @see R.transduce
+ * @example
+ *
+ * const xs = [{a: 1}, {a: 2}, {a: 3}];
+ * R.find(R.propEq('a', 2))(xs); //=> {a: 2}
+ * R.find(R.propEq('a', 4))(xs); //=> undefined
+ */
+ var find = _curry2(
+ _dispatchable(['find'], _xfind, function find(fn, list) {
+ var idx = 0;
+ var len = list.length;
+ while (idx < len) {
+ if (fn(list[idx])) {
+ return list[idx];
}
+ idx += 1;
}
- }
- idx += 1;
- }
- return output;
-}
+ })
+ );
-var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign;
+ function XFindIndex(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ this.idx = -1;
+ this.found = false;
+ }
+ XFindIndex.prototype['@@transducer/init'] = _xfBase.init;
+ XFindIndex.prototype['@@transducer/result'] = function (result) {
+ if (!this.found) {
+ result = this.xf['@@transducer/step'](result, -1);
+ }
+ return this.xf['@@transducer/result'](result);
+ };
+ XFindIndex.prototype['@@transducer/step'] = function (result, input) {
+ this.idx += 1;
+ if (this.f(input)) {
+ this.found = true;
+ result = _reduced(this.xf['@@transducer/step'](result, this.idx));
+ }
+ return result;
+ };
-/**
- * Creates an object containing a single key:value pair.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category Object
- * @sig String -> a -> {String:a}
- * @param {String} key
- * @param {*} val
- * @return {Object}
- * @see R.pair
- * @example
- *
- * const matchPhrases = R.compose(
- * R.objOf('must'),
- * R.map(R.objOf('match_phrase'))
- * );
- * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]}
- */
-var objOf = _curry2(function objOf(key, val) {
- var obj = {};
- obj[key] = val;
- return obj;
-});
+ var _xfindIndex = _curry2(function _xfindIndex(f, xf) {
+ return new XFindIndex(f, xf);
+ });
-var _stepCatArray = {
- '@@transducer/init': Array,
- '@@transducer/step': function(xs, x) {
- xs.push(x);
- return xs;
- },
- '@@transducer/result': _identity
-};
-var _stepCatString = {
- '@@transducer/init': String,
- '@@transducer/step': function(a, b) { return a + b; },
- '@@transducer/result': _identity
-};
-var _stepCatObject = {
- '@@transducer/init': Object,
- '@@transducer/step': function(result, input) {
- return _objectAssign$1(
- result,
- _isArrayLike(input) ? objOf(input[0], input[1]) : input
- );
- },
- '@@transducer/result': _identity
-};
+ /**
+ * Returns the index of the first element of the list which matches the
+ * predicate, or `-1` if no element matches.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> Number
+ * @param {Function} fn The predicate function used to determine if the element is the
+ * desired one.
+ * @param {Array} list The array to consider.
+ * @return {Number} The index of the element found, or `-1`.
+ * @see R.transduce
+ * @example
+ *
+ * const xs = [{a: 1}, {a: 2}, {a: 3}];
+ * R.findIndex(R.propEq('a', 2))(xs); //=> 1
+ * R.findIndex(R.propEq('a', 4))(xs); //=> -1
+ */
+ var findIndex = _curry2(
+ _dispatchable([], _xfindIndex, function findIndex(fn, list) {
+ var idx = 0;
+ var len = list.length;
+ while (idx < len) {
+ if (fn(list[idx])) {
+ return idx;
+ }
+ idx += 1;
+ }
+ return -1;
+ })
+ );
-function _stepCat(obj) {
- if (_isTransformer(obj)) {
- return obj;
- }
- if (_isArrayLike(obj)) {
- return _stepCatArray;
+ function XFindLast(f, xf) {
+ this.xf = xf;
+ this.f = f;
}
- if (typeof obj === 'string') {
- return _stepCatString;
- }
- if (typeof obj === 'object') {
- return _stepCatObject;
- }
- throw new Error('Cannot create transformer for ' + obj);
-}
+ XFindLast.prototype['@@transducer/init'] = _xfBase.init;
+ XFindLast.prototype['@@transducer/result'] = function (result) {
+ return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last));
+ };
+ XFindLast.prototype['@@transducer/step'] = function (result, input) {
+ if (this.f(input)) {
+ this.last = input;
+ }
+ return result;
+ };
-/**
- * Transforms the items of the list with the transducer and appends the
- * transformed items to the accumulator using an appropriate iterator function
- * based on the accumulator type.
- *
- * The accumulator can be an array, string, object or a transformer. Iterated
- * items will be appended to arrays and concatenated to strings. Objects will
- * be merged directly or 2-item arrays will be merged as key, value pairs.
- *
- * The accumulator can also be a transformer object that provides a 2-arity
- * reducing iterator function, step, 0-arity initial value function, init, and
- * 1-arity result extraction function result. The step function is used as the
- * iterator function in reduce. The result function is used to convert the
- * final accumulator into the return type and in most cases is R.identity. The
- * init function is used to provide the initial accumulator.
- *
- * The iteration is performed with [`R.reduce`](#reduce) after initializing the
- * transducer.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category List
- * @sig a -> (b -> b) -> [c] -> a
- * @param {*} acc The initial accumulator value.
- * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.transduce
- * @example
- *
- * const numbers = [1, 2, 3, 4];
- * const transducer = R.compose(R.map(R.add(1)), R.take(2));
- *
- * R.into([], transducer, numbers); //=> [2, 3]
- *
- * const intoArray = R.into([]);
- * intoArray(transducer, numbers); //=> [2, 3]
- */
-var into = _curry3(function into(acc, xf, list) {
- return _isTransformer(acc) ?
- _reduce(xf(acc), acc['@@transducer/init'](), list) :
- _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list);
-});
+ var _xfindLast = _curry2(function _xfindLast(f, xf) {
+ return new XFindLast(f, xf);
+ });
-/**
- * Same as [`R.invertObj`](#invertObj), however this accounts for objects with
- * duplicate values by putting the values into an array.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Object
- * @sig {s: x} -> {x: [ s, ... ]}
- * @param {Object} obj The object or array to invert
- * @return {Object} out A new object with keys in an array.
- * @see R.invertObj
- * @example
- *
- * const raceResultsByFirstName = {
- * first: 'alice',
- * second: 'jake',
- * third: 'alice',
- * };
- * R.invert(raceResultsByFirstName);
- * //=> { 'alice': ['first', 'third'], 'jake':['second'] }
- */
-var invert = _curry1(function invert(obj) {
- var props = keys(obj);
- var len = props.length;
- var idx = 0;
- var out = {};
-
- while (idx < len) {
- var key = props[idx];
- var val = obj[key];
- var list = _has(val, out) ? out[val] : (out[val] = []);
- list[list.length] = key;
- idx += 1;
- }
- return out;
-});
+ /**
+ * Returns the last element of the list which matches the predicate, or
+ * `undefined` if no element matches.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> a | undefined
+ * @param {Function} fn The predicate function used to determine if the element is the
+ * desired one.
+ * @param {Array} list The array to consider.
+ * @return {Object} The element found, or `undefined`.
+ * @see R.transduce
+ * @example
+ *
+ * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
+ * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
+ * R.findLast(R.propEq('a', 4))(xs); //=> undefined
+ */
+ var findLast = _curry2(
+ _dispatchable([], _xfindLast, function findLast(fn, list) {
+ var idx = list.length - 1;
+ while (idx >= 0) {
+ if (fn(list[idx])) {
+ return list[idx];
+ }
+ idx -= 1;
+ }
+ })
+ );
-/**
- * Returns a new object with the keys of the given object as values, and the
- * values of the given object, which are coerced to strings, as keys. Note
- * that the last key found is preferred when handling the same value.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Object
- * @sig {s: x} -> {x: s}
- * @param {Object} obj The object or array to invert
- * @return {Object} out A new object
- * @see R.invert
- * @example
- *
- * const raceResults = {
- * first: 'alice',
- * second: 'jake'
- * };
- * R.invertObj(raceResults);
- * //=> { 'alice': 'first', 'jake':'second' }
- *
- * // Alternatively:
- * const raceResults = ['alice', 'jake'];
- * R.invertObj(raceResults);
- * //=> { 'alice': '0', 'jake':'1' }
- */
-var invertObj = _curry1(function invertObj(obj) {
- var props = keys(obj);
- var len = props.length;
- var idx = 0;
- var out = {};
-
- while (idx < len) {
- var key = props[idx];
- out[obj[key]] = key;
- idx += 1;
+ function XFindLastIndex(f, xf) {
+ this.xf = xf;
+ this.f = f;
+ this.idx = -1;
+ this.lastIdx = -1;
}
- return out;
-});
-
-/**
- * Turns a named method with a specified arity into a function that can be
- * called directly supplied with arguments and a target object.
- *
- * The returned function is curried and accepts `arity + 1` parameters where
- * the final parameter is the target object.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *)
- * @param {Number} arity Number of arguments the returned function should take
- * before the target object.
- * @param {String} method Name of the method to call.
- * @return {Function} A new curried function.
- * @see R.construct
- * @example
- *
- * const sliceFrom = R.invoker(1, 'slice');
- * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
- * const sliceFrom6 = R.invoker(2, 'slice')(6);
- * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'
- * @symb R.invoker(0, 'method')(o) = o['method']()
- * @symb R.invoker(1, 'method')(a, o) = o['method'](a)
- * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b)
- */
-var invoker = _curry2(function invoker(arity, method) {
- return curryN(arity + 1, function() {
- var target = arguments[arity];
- if (target != null && _isFunction(target[method])) {
- return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity));
+ XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init;
+ XFindLastIndex.prototype['@@transducer/result'] = function (result) {
+ return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx));
+ };
+ XFindLastIndex.prototype['@@transducer/step'] = function (result, input) {
+ this.idx += 1;
+ if (this.f(input)) {
+ this.lastIdx = this.idx;
}
- throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"');
+ return result;
+ };
+
+ var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) {
+ return new XFindLastIndex(f, xf);
});
-});
-/**
- * See if an object (`val`) is an instance of the supplied constructor. This
- * function will check up the inheritance chain, if any.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category Type
- * @sig (* -> {*}) -> a -> Boolean
- * @param {Object} ctor A constructor
- * @param {*} val The value to test
- * @return {Boolean}
- * @example
- *
- * R.is(Object, {}); //=> true
- * R.is(Number, 1); //=> true
- * R.is(Object, 1); //=> false
- * R.is(String, 's'); //=> true
- * R.is(String, new String('')); //=> true
- * R.is(Object, new String('')); //=> true
- * R.is(Object, 's'); //=> false
- * R.is(Number, {}); //=> false
- */
-var is = _curry2(function is(Ctor, val) {
- return val != null && val.constructor === Ctor || val instanceof Ctor;
-});
+ /**
+ * Returns the index of the last element of the list which matches the
+ * predicate, or `-1` if no element matches.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> Number
+ * @param {Function} fn The predicate function used to determine if the element is the
+ * desired one.
+ * @param {Array} list The array to consider.
+ * @return {Number} The index of the element found, or `-1`.
+ * @see R.transduce
+ * @example
+ *
+ * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
+ * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
+ * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
+ */
+ var findLastIndex = _curry2(
+ _dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) {
+ var idx = list.length - 1;
+ while (idx >= 0) {
+ if (fn(list[idx])) {
+ return idx;
+ }
+ idx -= 1;
+ }
+ return -1;
+ })
+ );
-/**
- * Returns `true` if the given value is its type's empty value; `false`
- * otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Logic
- * @sig a -> Boolean
- * @param {*} x
- * @return {Boolean}
- * @see R.empty
- * @example
- *
- * R.isEmpty([1, 2, 3]); //=> false
- * R.isEmpty([]); //=> true
- * R.isEmpty(''); //=> true
- * R.isEmpty(null); //=> false
- * R.isEmpty({}); //=> true
- * R.isEmpty({length: 0}); //=> false
- */
-var isEmpty = _curry1(function isEmpty(x) {
- return x != null && equals(x, empty(x));
-});
+ /**
+ * Returns a new list by pulling every item out of it (and all its sub-arrays)
+ * and putting them in a new array, depth-first.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [b]
+ * @param {Array} list The array to consider.
+ * @return {Array} The flattened list.
+ * @see R.unnest
+ * @example
+ *
+ * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
+ * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
+ */
+ var flatten = _curry1(_makeFlat(true));
+
+ /**
+ * Returns a new function much like the supplied one, except that the first two
+ * arguments' order is reversed.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z)
+ * @param {Function} fn The function to invoke with its first two parameters reversed.
+ * @return {*} The result of invoking `fn` with its first two parameters' order reversed.
+ * @example
+ *
+ * const mergeThree = (a, b, c) => [].concat(a, b, c);
+ *
+ * mergeThree(1, 2, 3); //=> [1, 2, 3]
+ *
+ * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
+ * @symb R.flip(f)(a, b, c) = f(b, a, c)
+ */
+ var flip = _curry1(function flip(fn) {
+ return curryN(fn.length, function (a, b) {
+ var args = Array.prototype.slice.call(arguments, 0);
+ args[0] = b;
+ args[1] = a;
+ return fn.apply(this, args);
+ });
+ });
-/**
- * Returns a string made by inserting the `separator` between each element and
- * concatenating all the elements into a single string.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig String -> [a] -> String
- * @param {Number|String} separator The string used to separate the elements.
- * @param {Array} xs The elements to join into a string.
- * @return {String} str The string made by concatenating `xs` with `separator`.
- * @see R.split
- * @example
- *
- * const spacer = R.join(' ');
- * spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
- * R.join('|', [1, 2, 3]); //=> '1|2|3'
- */
-var join = invoker(1, 'join');
+ /**
+ * Iterate over an input `list`, calling a provided function `fn` for each
+ * element in the list.
+ *
+ * `fn` receives one argument: *(value)*.
+ *
+ * Note: `R.forEach` does not skip deleted or unassigned indices (sparse
+ * arrays), unlike the native `Array.prototype.forEach` method. For more
+ * details on this behavior, see:
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description
+ *
+ * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns
+ * the original array. In some libraries this function is named `each`.
+ *
+ * Dispatches to the `forEach` method of the second argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category List
+ * @sig (a -> *) -> [a] -> [a]
+ * @param {Function} fn The function to invoke. Receives one argument, `value`.
+ * @param {Array} list The list to iterate over.
+ * @return {Array} The original list.
+ * @see R.addIndex
+ * @example
+ *
+ * const printXPlusFive = x => console.log(x + 5);
+ * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
+ * // logs 6
+ * // logs 7
+ * // logs 8
+ * @symb R.forEach(f, [a, b, c]) = [a, b, c]
+ */
+ var forEach = _curry2(
+ _checkForMethod('forEach', function forEach(fn, list) {
+ var len = list.length;
+ var idx = 0;
+ while (idx < len) {
+ fn(list[idx]);
+ idx += 1;
+ }
+ return list;
+ })
+ );
-/**
- * juxt applies a list of functions to a list of values.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Function
- * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n])
- * @param {Array} fns An array of functions
- * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters.
- * @see R.applySpec
- * @example
- *
- * const getRange = R.juxt([Math.min, Math.max]);
- * getRange(3, 4, 9, -3); //=> [-3, 9]
- * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)]
- */
-var juxt = _curry1(function juxt(fns) {
- return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns);
-});
+ /**
+ * Iterate over an input `object`, calling a provided function `fn` for each
+ * key and value in the object.
+ *
+ * `fn` receives three argument: *(value, key, obj)*.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.23.0
+ * @category Object
+ * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
+ * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
+ * @param {Object} obj The object to iterate over.
+ * @return {Object} The original object.
+ * @example
+ *
+ * const printKeyConcatValue = (value, key) => console.log(key + ':' + value);
+ * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
+ * // logs x:1
+ * // logs y:2
+ * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
+ */
+ var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) {
+ var keyList = keys(obj);
+ var idx = 0;
+ while (idx < keyList.length) {
+ var key = keyList[idx];
+ fn(obj[key], key, obj);
+ idx += 1;
+ }
+ return obj;
+ });
-/**
- * Returns a list containing the names of all the properties of the supplied
- * object, including prototype properties.
- * Note that the order of the output array is not guaranteed to be consistent
- * across different JS platforms.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category Object
- * @sig {k: v} -> [k]
- * @param {Object} obj The object to extract properties from
- * @return {Array} An array of the object's own and prototype properties.
- * @see R.keys, R.valuesIn
- * @example
- *
- * const F = function() { this.x = 'X'; };
- * F.prototype.y = 'Y';
- * const f = new F();
- * R.keysIn(f); //=> ['x', 'y']
- */
-var keysIn = _curry1(function keysIn(obj) {
- var prop;
- var ks = [];
- for (prop in obj) {
- ks[ks.length] = prop;
- }
- return ks;
-});
+ /**
+ * Creates a new object from a list key-value pairs. If a key appears in
+ * multiple pairs, the rightmost pair is included in the object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category List
+ * @sig [[k,v]] -> {k: v}
+ * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
+ * @return {Object} The object made by pairing up `keys` and `values`.
+ * @see R.toPairs, R.pair
+ * @example
+ *
+ * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
+ */
+ var fromPairs = _curry1(function fromPairs(pairs) {
+ var result = {};
+ var idx = 0;
+ while (idx < pairs.length) {
+ result[pairs[idx][0]] = pairs[idx][1];
+ idx += 1;
+ }
+ return result;
+ });
-/**
- * Returns the position of the last occurrence of an item in an array, or -1 if
- * the item is not included in the array. [`R.equals`](#equals) is used to
- * determine equality.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> Number
- * @param {*} target The item to find.
- * @param {Array} xs The array to search in.
- * @return {Number} the index of the target, or -1 if the target is not found.
- * @see R.indexOf
- * @example
- *
- * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6
- * R.lastIndexOf(10, [1,2,3,4]); //=> -1
- */
-var lastIndexOf = _curry2(function lastIndexOf(target, xs) {
- if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) {
- return xs.lastIndexOf(target);
- } else {
- var idx = xs.length - 1;
- while (idx >= 0) {
- if (equals(xs[idx], target)) {
- return idx;
+ /**
+ * Splits a list into sub-lists stored in an object, based on the result of
+ * calling a String-returning function on each element, and grouping the
+ * results according to values returned.
+ *
+ * Dispatches to the `groupBy` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig (a -> String) -> [a] -> {String: [a]}
+ * @param {Function} fn Function :: a -> String
+ * @param {Array} list The array to group
+ * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements
+ * that produced that key when passed to `fn`.
+ * @see R.reduceBy, R.transduce
+ * @example
+ *
+ * const byGrade = R.groupBy(function(student) {
+ * const score = student.score;
+ * return score < 65 ? 'F' :
+ * score < 70 ? 'D' :
+ * score < 80 ? 'C' :
+ * score < 90 ? 'B' : 'A';
+ * });
+ * const students = [{name: 'Abby', score: 84},
+ * {name: 'Eddy', score: 58},
+ * // ...
+ * {name: 'Jack', score: 69}];
+ * byGrade(students);
+ * // {
+ * // 'A': [{name: 'Dianne', score: 99}],
+ * // 'B': [{name: 'Abby', score: 84}]
+ * // // ...,
+ * // 'F': [{name: 'Eddy', score: 58}]
+ * // }
+ */
+ var groupBy = _curry2(
+ _checkForMethod(
+ 'groupBy',
+ reduceBy(function (acc, item) {
+ if (acc == null) {
+ acc = [];
+ }
+ acc.push(item);
+ return acc;
+ }, null)
+ )
+ );
+
+ /**
+ * Takes a list and returns a list of lists where each sublist's elements are
+ * all satisfied pairwise comparison according to the provided function.
+ * Only adjacent elements are passed to the comparison function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.21.0
+ * @category List
+ * @sig ((a, a) → Boolean) → [a] → [[a]]
+ * @param {Function} fn Function for determining whether two given (adjacent)
+ * elements should be in the same group
+ * @param {Array} list The array to group. Also accepts a string, which will be
+ * treated as a list of characters.
+ * @return {List} A list that contains sublists of elements,
+ * whose concatenations are equal to the original list.
+ * @example
+ *
+ * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
+ * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]
+ *
+ * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
+ * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]
+ *
+ * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
+ * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]
+ *
+ * R.groupWith(R.eqBy(isVowel), 'aestiou')
+ * //=> ['ae', 'st', 'iou']
+ */
+ var groupWith = _curry2(function (fn, list) {
+ var res = [];
+ var idx = 0;
+ var len = list.length;
+ while (idx < len) {
+ var nextidx = idx + 1;
+ while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) {
+ nextidx += 1;
}
- idx -= 1;
+ res.push(list.slice(idx, nextidx));
+ idx = nextidx;
}
- return -1;
- }
-});
+ return res;
+ });
-function _isNumber(x) {
- return Object.prototype.toString.call(x) === '[object Number]';
-}
+ /**
+ * Returns `true` if the first argument is greater than the second; `false`
+ * otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> Boolean
+ * @param {*} a
+ * @param {*} b
+ * @return {Boolean}
+ * @see R.lt
+ * @example
+ *
+ * R.gt(2, 1); //=> true
+ * R.gt(2, 2); //=> false
+ * R.gt(2, 3); //=> false
+ * R.gt('a', 'z'); //=> false
+ * R.gt('z', 'a'); //=> true
+ */
+ var gt = _curry2(function gt(a, b) {
+ return a > b;
+ });
-/**
- * Returns the number of elements in the array by returning `list.length`.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category List
- * @sig [a] -> Number
- * @param {Array} list The array to inspect.
- * @return {Number} The length of the array.
- * @example
- *
- * R.length([]); //=> 0
- * R.length([1, 2, 3]); //=> 3
- */
-var length = _curry1(function length(list) {
- return list != null && _isNumber(list.length) ? list.length : NaN;
-});
+ /**
+ * Returns `true` if the first argument is greater than or equal to the second;
+ * `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> Boolean
+ * @param {Number} a
+ * @param {Number} b
+ * @return {Boolean}
+ * @see R.lte
+ * @example
+ *
+ * R.gte(2, 1); //=> true
+ * R.gte(2, 2); //=> true
+ * R.gte(2, 3); //=> false
+ * R.gte('a', 'z'); //=> false
+ * R.gte('z', 'a'); //=> true
+ */
+ var gte = _curry2(function gte(a, b) {
+ return a >= b;
+ });
-/**
- * Returns a lens for the given getter and setter functions. The getter "gets"
- * the value of the focus; the setter "sets" the value of the focus. The setter
- * should not mutate the data structure.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig (s -> a) -> ((a, s) -> s) -> Lens s a
- * @param {Function} getter
- * @param {Function} setter
- * @return {Lens}
- * @see R.view, R.set, R.over, R.lensIndex, R.lensProp
- * @example
- *
- * const xLens = R.lens(R.prop('x'), R.assoc('x'));
- *
- * R.view(xLens, {x: 1, y: 2}); //=> 1
- * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
- * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
- */
-var lens = _curry2(function lens(getter, setter) {
- return function(toFunctorFn) {
- return function(target) {
- return map(
- function(focus) {
- return setter(focus, target);
- },
- toFunctorFn(getter(target))
- );
- };
- };
-});
+ /**
+ * Returns whether or not a path exists in an object. Only the object's
+ * own properties are checked.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.26.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @sig [Idx] -> {a} -> Boolean
+ * @param {Array} path The path to use.
+ * @param {Object} obj The object to check the path in.
+ * @return {Boolean} Whether the path exists.
+ * @see R.has
+ * @example
+ *
+ * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true
+ * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true
+ * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false
+ * R.hasPath(['a', 'b'], {}); // => false
+ */
+ var hasPath = _curry2(function hasPath(_path, obj) {
+ if (_path.length === 0) {
+ return false;
+ }
+ var val = obj;
+ var idx = 0;
+ while (idx < _path.length) {
+ if (_has(_path[idx], val)) {
+ val = val[_path[idx]];
+ idx += 1;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ });
-/**
- * Returns a lens whose focus is the specified index.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig Number -> Lens s a
- * @param {Number} n
- * @return {Lens}
- * @see R.view, R.set, R.over
- * @example
- *
- * const headLens = R.lensIndex(0);
- *
- * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
- * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
- * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
- */
-var lensIndex = _curry1(function lensIndex(n) {
- return lens(nth(n), update(n));
-});
+ /**
+ * Returns whether or not an object has an own property with the specified name
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Object
+ * @sig s -> {s: x} -> Boolean
+ * @param {String} prop The name of the property to check for.
+ * @param {Object} obj The object to query.
+ * @return {Boolean} Whether the property exists.
+ * @example
+ *
+ * const hasName = R.has('name');
+ * hasName({name: 'alice'}); //=> true
+ * hasName({name: 'bob'}); //=> true
+ * hasName({}); //=> false
+ *
+ * const point = {x: 0, y: 0};
+ * const pointHas = R.has(R.__, point);
+ * pointHas('x'); //=> true
+ * pointHas('y'); //=> true
+ * pointHas('z'); //=> false
+ */
+ var has = _curry2(function has(prop, obj) {
+ return hasPath([prop], obj);
+ });
-/**
- * Returns a lens whose focus is the specified path.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Object
- * @typedefn Idx = String | Int
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig [Idx] -> Lens s a
- * @param {Array} path The path to use.
- * @return {Lens}
- * @see R.view, R.set, R.over
- * @example
- *
- * const xHeadYLens = R.lensPath(['x', 0, 'y']);
- *
- * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
- * //=> 2
- * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
- * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
- * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
- * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}
- */
-var lensPath = _curry1(function lensPath(p) {
- return lens(path(p), assocPath(p));
-});
+ /**
+ * Returns whether or not an object or its prototype chain has a property with
+ * the specified name
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Object
+ * @sig s -> {s: x} -> Boolean
+ * @param {String} prop The name of the property to check for.
+ * @param {Object} obj The object to query.
+ * @return {Boolean} Whether the property exists.
+ * @example
+ *
+ * function Rectangle(width, height) {
+ * this.width = width;
+ * this.height = height;
+ * }
+ * Rectangle.prototype.area = function() {
+ * return this.width * this.height;
+ * };
+ *
+ * const square = new Rectangle(2, 2);
+ * R.hasIn('width', square); //=> true
+ * R.hasIn('area', square); //=> true
+ */
+ var hasIn = _curry2(function hasIn(prop, obj) {
+ return prop in obj;
+ });
-/**
- * Returns a lens whose focus is the specified property.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig String -> Lens s a
- * @param {String} k
- * @return {Lens}
- * @see R.view, R.set, R.over
- * @example
- *
- * const xLens = R.lensProp('x');
- *
- * R.view(xLens, {x: 1, y: 2}); //=> 1
- * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
- * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
- */
-var lensProp = _curry1(function lensProp(k) {
- return lens(prop(k), assoc(k));
-});
+ /**
+ * Returns true if its arguments are identical, false otherwise. Values are
+ * identical if they reference the same memory. `NaN` is identical to `NaN`;
+ * `0` and `-0` are not identical.
+ *
+ * Note this is merely a curried version of ES6 `Object.is`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.15.0
+ * @category Relation
+ * @sig a -> a -> Boolean
+ * @param {*} a
+ * @param {*} b
+ * @return {Boolean}
+ * @example
+ *
+ * const o = {};
+ * R.identical(o, o); //=> true
+ * R.identical(1, 1); //=> true
+ * R.identical(1, '1'); //=> false
+ * R.identical([], []); //=> false
+ * R.identical(0, -0); //=> false
+ * R.identical(NaN, NaN); //=> true
+ */
+ var identical = _curry2(_objectIs$1);
+
+ /**
+ * Creates a function that will process either the `onTrue` or the `onFalse`
+ * function depending upon the result of the `condition` predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Logic
+ * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *)
+ * @param {Function} condition A predicate function
+ * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value.
+ * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value.
+ * @return {Function} A new function that will process either the `onTrue` or the `onFalse`
+ * function depending upon the result of the `condition` predicate.
+ * @see R.unless, R.when, R.cond
+ * @example
+ *
+ * const incCount = R.ifElse(
+ * R.has('count'),
+ * R.over(R.lensProp('count'), R.inc),
+ * R.assoc('count', 1)
+ * );
+ * incCount({}); //=> { count: 1 }
+ * incCount({ count: 1 }); //=> { count: 2 }
+ */
+ var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) {
+ return curryN(Math.max(condition.length, onTrue.length, onFalse.length), function _ifElse() {
+ return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments);
+ });
+ });
+
+ /**
+ * Increments its argument.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Math
+ * @sig Number -> Number
+ * @param {Number} n
+ * @return {Number} n + 1
+ * @see R.dec
+ * @example
+ *
+ * R.inc(42); //=> 43
+ */
+ var inc = add(1);
+
+ /**
+ * Returns `true` if the specified value is equal, in [`R.equals`](#equals)
+ * terms, to at least one element of the given list; `false` otherwise.
+ * Works also with strings.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> Boolean
+ * @param {Object} a The item to compare against.
+ * @param {Array} list The array to consider.
+ * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
+ * @see R.any
+ * @example
+ *
+ * R.includes(3, [1, 2, 3]); //=> true
+ * R.includes(4, [1, 2, 3]); //=> false
+ * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
+ * R.includes([42], [[42]]); //=> true
+ * R.includes('ba', 'banana'); //=>true
+ */
+ var includes = _curry2(_includes);
+
+ /**
+ * Given a function that generates a key, turns a list of objects into an
+ * object indexing the objects by the given key. Note that if multiple
+ * objects generate the same value for the indexing key only the last value
+ * will be included in the generated object.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig (a -> String) -> [{k: v}] -> {k: {k: v}}
+ * @param {Function} fn Function :: a -> String
+ * @param {Array} array The array of objects to index
+ * @return {Object} An object indexing each array element by the given property.
+ * @example
+ *
+ * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
+ * R.indexBy(R.prop('id'), list);
+ * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
+ */
+ var indexBy = reduceBy(function (acc, elem) {
+ return elem;
+ }, null);
+
+ /**
+ * Returns the position of the first occurrence of an item in an array, or -1
+ * if the item is not included in the array. [`R.equals`](#equals) is used to
+ * determine equality.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> Number
+ * @param {*} target The item to find.
+ * @param {Array} xs The array to search in.
+ * @return {Number} the index of the target, or -1 if the target is not found.
+ * @see R.lastIndexOf
+ * @example
+ *
+ * R.indexOf(3, [1,2,3,4]); //=> 2
+ * R.indexOf(10, [1,2,3,4]); //=> -1
+ */
+ var indexOf = _curry2(function indexOf(target, xs) {
+ return typeof xs.indexOf === 'function' && !_isArray(xs) ? xs.indexOf(target) : _indexOf(xs, target, 0);
+ });
-/**
- * Returns `true` if the first argument is less than the second; `false`
- * otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> Boolean
- * @param {*} a
- * @param {*} b
- * @return {Boolean}
- * @see R.gt
- * @example
- *
- * R.lt(2, 1); //=> false
- * R.lt(2, 2); //=> false
- * R.lt(2, 3); //=> true
- * R.lt('a', 'z'); //=> true
- * R.lt('z', 'a'); //=> false
- */
-var lt = _curry2(function lt(a, b) { return a < b; });
+ /**
+ * Returns all but the last element of the given list or string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category List
+ * @sig [a] -> [a]
+ * @sig String -> String
+ * @param {*} list
+ * @return {*}
+ * @see R.last, R.head, R.tail
+ * @example
+ *
+ * R.init([1, 2, 3]); //=> [1, 2]
+ * R.init([1, 2]); //=> [1]
+ * R.init([1]); //=> []
+ * R.init([]); //=> []
+ *
+ * R.init('abc'); //=> 'ab'
+ * R.init('ab'); //=> 'a'
+ * R.init('a'); //=> ''
+ * R.init(''); //=> ''
+ */
+ var init = slice(0, -1);
+
+ /**
+ * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
+ * `xs'` comprising each of the elements of `xs` which is equal to one or more
+ * elements of `ys` according to `pred`.
+ *
+ * `pred` must be a binary function expecting an element from each list.
+ *
+ * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
+ * not be significant, but since `xs'` is ordered the implementation guarantees
+ * that its values are in the same order as they appear in `xs`. Duplicates are
+ * not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Relation
+ * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a]
+ * @param {Function} pred
+ * @param {Array} xs
+ * @param {Array} ys
+ * @return {Array}
+ * @see R.intersection
+ * @example
+ *
+ * R.innerJoin(
+ * (record, id) => record.id === id,
+ * [{id: 824, name: 'Richie Furay'},
+ * {id: 956, name: 'Dewey Martin'},
+ * {id: 313, name: 'Bruce Palmer'},
+ * {id: 456, name: 'Stephen Stills'},
+ * {id: 177, name: 'Neil Young'}],
+ * [177, 456, 999]
+ * );
+ * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
+ */
+ var innerJoin = _curry3(function innerJoin(pred, xs, ys) {
+ return _filter(function (x) {
+ return _includesWith(pred, x, ys);
+ }, xs);
+ });
-/**
- * Returns `true` if the first argument is less than or equal to the second;
- * `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> Boolean
- * @param {Number} a
- * @param {Number} b
- * @return {Boolean}
- * @see R.gte
- * @example
- *
- * R.lte(2, 1); //=> false
- * R.lte(2, 2); //=> true
- * R.lte(2, 3); //=> true
- * R.lte('a', 'z'); //=> true
- * R.lte('z', 'a'); //=> false
- */
-var lte = _curry2(function lte(a, b) { return a <= b; });
+ /**
+ * Inserts the supplied element into the list, at the specified `index`. _Note that
-/**
- * The `mapAccum` function behaves like a combination of map and reduce; it
- * applies a function to each element of a list, passing an accumulating
- * parameter from left to right, and returning a final value of this
- * accumulator together with the new list.
- *
- * The iterator function receives two arguments, *acc* and *value*, and should
- * return a tuple *[acc, value]*.
+ * this is not destructive_: it returns a copy of the list with the changes.
+ * No lists have been harmed in the application of this function.
*
* @func
* @memberOf R
- * @since v0.10.0
+ * @since v0.2.2
* @category List
- * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y])
- * @param {Function} fn The function to be called on every element of the input `list`.
- * @param {*} acc The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.scan, R.addIndex, R.mapAccumRight
+ * @sig Number -> a -> [a] -> [a]
+ * @param {Number} index The position to insert the element
+ * @param {*} elt The element to insert into the Array
+ * @param {Array} list The list to insert into
+ * @return {Array} A new Array with `elt` inserted at `index`.
* @example
*
- * const digits = ['1', '2', '3', '4'];
- * const appender = (a, b) => [a + b, a + b];
- *
- * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']]
- * @symb R.mapAccum(f, a, [b, c, d]) = [
- * f(f(f(a, b)[0], c)[0], d)[0],
- * [
- * f(a, b)[1],
- * f(f(a, b)[0], c)[1],
- * f(f(f(a, b)[0], c)[0], d)[1]
- * ]
- * ]
+ * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
*/
-var mapAccum = _curry3(function mapAccum(fn, acc, list) {
- var idx = 0;
- var len = list.length;
- var result = [];
- var tuple = [acc];
- while (idx < len) {
- tuple = fn(tuple[0], list[idx]);
- result[idx] = tuple[1];
- idx += 1;
- }
- return [tuple[0], result];
-});
+ var insert = _curry3(function insert(idx, elt, list) {
+ idx = idx < list.length && idx >= 0 ? idx : list.length;
+ var result = Array.prototype.slice.call(list, 0);
+ result.splice(idx, 0, elt);
+ return result;
+ });
-/**
- * The `mapAccumRight` function behaves like a combination of map and reduce; it
- * applies a function to each element of a list, passing an accumulating
- * parameter from right to left, and returning a final value of this
- * accumulator together with the new list.
- *
- * Similar to [`mapAccum`](#mapAccum), except moves through the input list from
- * the right to the left.
- *
- * The iterator function receives two arguments, *acc* and *value*, and should
- * return a tuple *[acc, value]*.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category List
- * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y])
- * @param {Function} fn The function to be called on every element of the input `list`.
- * @param {*} acc The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.addIndex, R.mapAccum
- * @example
- *
- * const digits = ['1', '2', '3', '4'];
- * const appender = (a, b) => [b + a, b + a];
- *
- * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']]
- * @symb R.mapAccumRight(f, a, [b, c, d]) = [
- * f(f(f(a, d)[0], c)[0], b)[0],
- * [
- * f(a, d)[1],
- * f(f(a, d)[0], c)[1],
- * f(f(f(a, d)[0], c)[0], b)[1]
- * ]
- * ]
- */
-var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) {
- var idx = list.length - 1;
- var result = [];
- var tuple = [acc];
- while (idx >= 0) {
- tuple = fn(tuple[0], list[idx]);
- result[idx] = tuple[1];
- idx -= 1;
- }
- return [tuple[0], result];
-});
+ /**
+ * Inserts the sub-list into the list, at the specified `index`. _Note that this is not
+ * destructive_: it returns a copy of the list with the changes.
+ * No lists have been harmed in the application of this function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category List
+ * @sig Number -> [a] -> [a] -> [a]
+ * @param {Number} index The position to insert the sub-list
+ * @param {Array} elts The sub-list to insert into the Array
+ * @param {Array} list The list to insert the sub-list into
+ * @return {Array} A new Array with `elts` inserted starting at `index`.
+ * @example
+ *
+ * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
+ */
+ var insertAll = _curry3(function insertAll(idx, elts, list) {
+ idx = idx < list.length && idx >= 0 ? idx : list.length;
+ return [].concat(Array.prototype.slice.call(list, 0, idx), elts, Array.prototype.slice.call(list, idx));
+ });
-/**
- * An Object-specific version of [`map`](#map). The function is applied to three
- * arguments: *(value, key, obj)*. If only the value is significant, use
- * [`map`](#map) instead.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Object
- * @sig ((*, String, Object) -> *) -> Object -> Object
- * @param {Function} fn
- * @param {Object} obj
- * @return {Object}
- * @see R.map
- * @example
- *
- * const xyz = { x: 1, y: 2, z: 3 };
- * const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
- *
- * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
- */
-var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) {
- return _reduce(function(acc, key) {
- acc[key] = fn(obj[key], key, obj);
- return acc;
- }, {}, keys(obj));
-});
+ /**
+ * Returns a new list containing only one copy of each element in the original
+ * list, based upon the value returned by applying the supplied function to
+ * each list element. Prefers the first item if the supplied function produces
+ * the same value on two items. [`R.equals`](#equals) is used for comparison.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig (a -> b) -> [a] -> [a]
+ * @param {Function} fn A function used to produce a value to use during comparisons.
+ * @param {Array} list The array to consider.
+ * @return {Array} The list of unique items.
+ * @example
+ *
+ * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10]
+ */
+ var uniqBy = _curry2(function uniqBy(fn, list) {
+ var set = new _Set();
+ var result = [];
+ var idx = 0;
+ var appliedItem, item;
-/**
- * Tests a regular expression against a String. Note that this function will
- * return an empty array when there are no matches. This differs from
- * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
- * which returns `null` when there are no matches.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category String
- * @sig RegExp -> String -> [String | Undefined]
- * @param {RegExp} rx A regular expression.
- * @param {String} str The string to match against
- * @return {Array} The list of matches or empty array.
- * @see R.test
- * @example
- *
- * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
- * R.match(/a/, 'b'); //=> []
- * R.match(/a/, null); //=> TypeError: null does not have a method named "match"
- */
-var match = _curry2(function match(rx, str) {
- return str.match(rx) || [];
-});
+ while (idx < list.length) {
+ item = list[idx];
+ appliedItem = fn(item);
+ if (set.add(appliedItem)) {
+ result.push(item);
+ }
+ idx += 1;
+ }
+ return result;
+ });
-/**
- * `mathMod` behaves like the modulo operator should mathematically, unlike the
- * `%` operator (and by extension, [`R.modulo`](#modulo)). So while
- * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer
- * arguments, and returns NaN when the modulus is zero or negative.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} m The dividend.
- * @param {Number} p the modulus.
- * @return {Number} The result of `b mod a`.
- * @see R.modulo
- * @example
- *
- * R.mathMod(-17, 5); //=> 3
- * R.mathMod(17, 5); //=> 2
- * R.mathMod(17, -5); //=> NaN
- * R.mathMod(17, 0); //=> NaN
- * R.mathMod(17.2, 5); //=> NaN
- * R.mathMod(17, 5.3); //=> NaN
- *
- * const clock = R.mathMod(R.__, 12);
- * clock(15); //=> 3
- * clock(24); //=> 0
- *
- * const seventeenMod = R.mathMod(17);
- * seventeenMod(3); //=> 2
- * seventeenMod(4); //=> 1
- * seventeenMod(10); //=> 7
- */
-var mathMod = _curry2(function mathMod(m, p) {
- if (!_isInteger(m)) { return NaN; }
- if (!_isInteger(p) || p < 1) { return NaN; }
- return ((m % p) + p) % p;
-});
+ /**
+ * Returns a new list containing only one copy of each element in the original
+ * list. [`R.equals`](#equals) is used to determine equality.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [a]
+ * @param {Array} list The array to consider.
+ * @return {Array} The list of unique items.
+ * @example
+ *
+ * R.uniq([1, 1, 2, 1]); //=> [1, 2]
+ * R.uniq([1, '1']); //=> [1, '1']
+ * R.uniq([[42], [42]]); //=> [[42]]
+ */
+ var uniq = uniqBy(identity);
+
+ /**
+ * Combines two lists into a set (i.e. no duplicates) composed of those
+ * elements common to both lists.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig [*] -> [*] -> [*]
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The list of elements found in both `list1` and `list2`.
+ * @see R.innerJoin
+ * @example
+ *
+ * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3]
+ */
+ var intersection = _curry2(function intersection(list1, list2) {
+ var lookupList, filteredList;
+ if (list1.length > list2.length) {
+ lookupList = list1;
+ filteredList = list2;
+ } else {
+ lookupList = list2;
+ filteredList = list1;
+ }
+ return uniq(_filter(flip(_includes)(lookupList), filteredList));
+ });
-/**
- * Takes a function and two values, and returns whichever value produces the
- * larger result when passed to the provided function.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Relation
- * @sig Ord b => (a -> b) -> a -> a -> a
- * @param {Function} f
- * @param {*} a
- * @param {*} b
- * @return {*}
- * @see R.max, R.minBy
- * @example
- *
- * // square :: Number -> Number
- * const square = n => n * n;
- *
- * R.maxBy(square, -3, 2); //=> -3
- *
- * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
- * R.reduce(R.maxBy(square), 0, []); //=> 0
- */
-var maxBy = _curry3(function maxBy(f, a, b) {
- return f(b) > f(a) ? b : a;
-});
+ /**
+ * Creates a new list with the separator interposed between elements.
+ *
+ * Dispatches to the `intersperse` method of the second argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category List
+ * @sig a -> [a] -> [a]
+ * @param {*} separator The element to add to the list.
+ * @param {Array} list The list to be interposed.
+ * @return {Array} The new list.
+ * @example
+ *
+ * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's']
+ */
+ var intersperse = _curry2(
+ _checkForMethod('intersperse', function intersperse(separator, list) {
+ var out = [];
+ var idx = 0;
+ var length = list.length;
+ while (idx < length) {
+ if (idx === length - 1) {
+ out.push(list[idx]);
+ } else {
+ out.push(list[idx], separator);
+ }
+ idx += 1;
+ }
+ return out;
+ })
+ );
-/**
- * Adds together all the elements of a list.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig [Number] -> Number
- * @param {Array} list An array of numbers
- * @return {Number} The sum of all the numbers in the list.
- * @see R.reduce
- * @example
- *
- * R.sum([2,4,6,8,100,1]); //=> 121
- */
-var sum = reduce(add, 0);
+ // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
+ function _objectAssign(target) {
+ if (target == null) {
+ throw new TypeError('Cannot convert undefined or null to object');
+ }
-/**
- * Returns the mean of the given list of numbers.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Math
- * @sig [Number] -> Number
- * @param {Array} list
- * @return {Number}
- * @see R.median
- * @example
- *
- * R.mean([2, 7, 9]); //=> 6
- * R.mean([]); //=> NaN
- */
-var mean = _curry1(function mean(list) {
- return sum(list) / list.length;
-});
+ var output = Object(target);
+ var idx = 1;
+ var length = arguments.length;
+ while (idx < length) {
+ var source = arguments[idx];
+ if (source != null) {
+ for (var nextKey in source) {
+ if (_has(nextKey, source)) {
+ output[nextKey] = source[nextKey];
+ }
+ }
+ }
+ idx += 1;
+ }
+ return output;
+ }
+
+ var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign;
+
+ /**
+ * Creates an object containing a single key:value pair.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category Object
+ * @sig String -> a -> {String:a}
+ * @param {String} key
+ * @param {*} val
+ * @return {Object}
+ * @see R.pair
+ * @example
+ *
+ * const matchPhrases = R.compose(
+ * R.objOf('must'),
+ * R.map(R.objOf('match_phrase'))
+ * );
+ * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]}
+ */
+ var objOf = _curry2(function objOf(key, val) {
+ var obj = {};
+ obj[key] = val;
+ return obj;
+ });
-/**
- * Returns the median of the given list of numbers.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Math
- * @sig [Number] -> Number
- * @param {Array} list
- * @return {Number}
- * @see R.mean
- * @example
- *
- * R.median([2, 9, 7]); //=> 7
- * R.median([7, 2, 10, 9]); //=> 8
- * R.median([]); //=> NaN
- */
-var median = _curry1(function median(list) {
- var len = list.length;
- if (len === 0) {
- return NaN;
- }
- var width = 2 - len % 2;
- var idx = (len - width) / 2;
- return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) {
- return a < b ? -1 : a > b ? 1 : 0;
- }).slice(idx, idx + width));
-});
+ var _stepCatArray = {
+ '@@transducer/init': Array,
+ '@@transducer/step': function (xs, x) {
+ xs.push(x);
+ return xs;
+ },
+ '@@transducer/result': _identity,
+ };
+ var _stepCatString = {
+ '@@transducer/init': String,
+ '@@transducer/step': function (a, b) {
+ return a + b;
+ },
+ '@@transducer/result': _identity,
+ };
+ var _stepCatObject = {
+ '@@transducer/init': Object,
+ '@@transducer/step': function (result, input) {
+ return _objectAssign$1(result, _isArrayLike(input) ? objOf(input[0], input[1]) : input);
+ },
+ '@@transducer/result': _identity,
+ };
-/**
- * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an
- * additional function that will be applied to a given argument set and used to
- * create the cache key under which the results of the function to be memoized
- * will be stored. Care must be taken when implementing key generation to avoid
- * clashes that may overwrite previous entries erroneously.
- *
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Function
- * @sig (*... -> String) -> (*... -> a) -> (*... -> a)
- * @param {Function} fn The function to generate the cache key.
- * @param {Function} fn The function to memoize.
- * @return {Function} Memoized version of `fn`.
- * @example
- *
- * let count = 0;
- * const factorial = R.memoizeWith(R.identity, n => {
- * count += 1;
- * return R.product(R.range(1, n + 1));
- * });
- * factorial(5); //=> 120
- * factorial(5); //=> 120
- * factorial(5); //=> 120
- * count; //=> 1
- */
-var memoizeWith = _curry2(function memoizeWith(mFn, fn) {
- var cache = {};
- return _arity(fn.length, function() {
- var key = mFn.apply(this, arguments);
- if (!_has(key, cache)) {
- cache[key] = fn.apply(this, arguments);
+ function _stepCat(obj) {
+ if (_isTransformer(obj)) {
+ return obj;
+ }
+ if (_isArrayLike(obj)) {
+ return _stepCatArray;
}
- return cache[key];
+ if (typeof obj === 'string') {
+ return _stepCatString;
+ }
+ if (typeof obj === 'object') {
+ return _stepCatObject;
+ }
+ throw new Error('Cannot create transformer for ' + obj);
+ }
+
+ /**
+ * Transforms the items of the list with the transducer and appends the
+ * transformed items to the accumulator using an appropriate iterator function
+ * based on the accumulator type.
+ *
+ * The accumulator can be an array, string, object or a transformer. Iterated
+ * items will be appended to arrays and concatenated to strings. Objects will
+ * be merged directly or 2-item arrays will be merged as key, value pairs.
+ *
+ * The accumulator can also be a transformer object that provides a 2-arity
+ * reducing iterator function, step, 0-arity initial value function, init, and
+ * 1-arity result extraction function result. The step function is used as the
+ * iterator function in reduce. The result function is used to convert the
+ * final accumulator into the return type and in most cases is R.identity. The
+ * init function is used to provide the initial accumulator.
+ *
+ * The iteration is performed with [`R.reduce`](#reduce) after initializing the
+ * transducer.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category List
+ * @sig a -> (b -> b) -> [c] -> a
+ * @param {*} acc The initial accumulator value.
+ * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.transduce
+ * @example
+ *
+ * const numbers = [1, 2, 3, 4];
+ * const transducer = R.compose(R.map(R.add(1)), R.take(2));
+ *
+ * R.into([], transducer, numbers); //=> [2, 3]
+ *
+ * const intoArray = R.into([]);
+ * intoArray(transducer, numbers); //=> [2, 3]
+ */
+ var into = _curry3(function into(acc, xf, list) {
+ return _isTransformer(acc)
+ ? _reduce(xf(acc), acc['@@transducer/init'](), list)
+ : _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list);
});
-});
-/**
- * Create a new object with the own properties of the first object merged with
- * the own properties of the second object. If a key exists in both objects,
- * the value from the second object will be used.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig {k: v} -> {k: v} -> {k: v}
- * @param {Object} l
- * @param {Object} r
- * @return {Object}
- * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey
- * @deprecated
- * @example
- *
- * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
- * //=> { 'name': 'fred', 'age': 40 }
- *
- * const withDefaults = R.merge({x: 0, y: 0});
- * withDefaults({y: 2}); //=> {x: 0, y: 2}
- * @symb R.merge(a, b) = {...a, ...b}
- */
-var merge = _curry2(function merge(l, r) {
- return _objectAssign$1({}, l, r);
-});
+ /**
+ * Same as [`R.invertObj`](#invertObj), however this accounts for objects with
+ * duplicate values by putting the values into an array.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Object
+ * @sig {s: x} -> {x: [ s, ... ]}
+ * @param {Object} obj The object or array to invert
+ * @return {Object} out A new object with keys in an array.
+ * @see R.invertObj
+ * @example
+ *
+ * const raceResultsByFirstName = {
+ * first: 'alice',
+ * second: 'jake',
+ * third: 'alice',
+ * };
+ * R.invert(raceResultsByFirstName);
+ * //=> { 'alice': ['first', 'third'], 'jake':['second'] }
+ */
+ var invert = _curry1(function invert(obj) {
+ var props = keys(obj);
+ var len = props.length;
+ var idx = 0;
+ var out = {};
-/**
- * Merges a list of objects together into one object.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category List
- * @sig [{k: v}] -> {k: v}
- * @param {Array} list An array of objects
- * @return {Object} A merged object.
- * @see R.reduce
- * @example
- *
- * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
- * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}
- * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 }
- */
-var mergeAll = _curry1(function mergeAll(list) {
- return _objectAssign$1.apply(null, [{}].concat(list));
-});
+ while (idx < len) {
+ var key = props[idx];
+ var val = obj[key];
+ var list = _has(val, out) ? out[val] : (out[val] = []);
+ list[list.length] = key;
+ idx += 1;
+ }
+ return out;
+ });
-/**
- * Creates a new object with the own properties of the two provided objects. If
- * a key exists in both objects, the provided function is applied to the key
- * and the values associated with the key in each object, with the result being
- * used as the value associated with the key in the returned object.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Object
- * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a}
- * @param {Function} fn
- * @param {Object} l
- * @param {Object} r
- * @return {Object}
- * @see R.mergeDeepWithKey, R.merge, R.mergeWith
- * @example
- *
- * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
- * R.mergeWithKey(concatValues,
- * { a: true, thing: 'foo', values: [10, 20] },
- * { b: true, thing: 'bar', values: [15, 35] });
- * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
- * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
- */
-var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) {
- var result = {};
- var k;
+ /**
+ * Returns a new object with the keys of the given object as values, and the
+ * values of the given object, which are coerced to strings, as keys. Note
+ * that the last key found is preferred when handling the same value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Object
+ * @sig {s: x} -> {x: s}
+ * @param {Object} obj The object or array to invert
+ * @return {Object} out A new object
+ * @see R.invert
+ * @example
+ *
+ * const raceResults = {
+ * first: 'alice',
+ * second: 'jake'
+ * };
+ * R.invertObj(raceResults);
+ * //=> { 'alice': 'first', 'jake':'second' }
+ *
+ * // Alternatively:
+ * const raceResults = ['alice', 'jake'];
+ * R.invertObj(raceResults);
+ * //=> { 'alice': '0', 'jake':'1' }
+ */
+ var invertObj = _curry1(function invertObj(obj) {
+ var props = keys(obj);
+ var len = props.length;
+ var idx = 0;
+ var out = {};
- for (k in l) {
- if (_has(k, l)) {
- result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k];
+ while (idx < len) {
+ var key = props[idx];
+ out[obj[key]] = key;
+ idx += 1;
}
- }
+ return out;
+ });
- for (k in r) {
- if (_has(k, r) && !(_has(k, result))) {
- result[k] = r[k];
- }
- }
+ /**
+ * Turns a named method with a specified arity into a function that can be
+ * called directly supplied with arguments and a target object.
+ *
+ * The returned function is curried and accepts `arity + 1` parameters where
+ * the final parameter is the target object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *)
+ * @param {Number} arity Number of arguments the returned function should take
+ * before the target object.
+ * @param {String} method Name of the method to call.
+ * @return {Function} A new curried function.
+ * @see R.construct
+ * @example
+ *
+ * const sliceFrom = R.invoker(1, 'slice');
+ * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
+ * const sliceFrom6 = R.invoker(2, 'slice')(6);
+ * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'
+ * @symb R.invoker(0, 'method')(o) = o['method']()
+ * @symb R.invoker(1, 'method')(a, o) = o['method'](a)
+ * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b)
+ */
+ var invoker = _curry2(function invoker(arity, method) {
+ return curryN(arity + 1, function () {
+ var target = arguments[arity];
+ if (target != null && _isFunction(target[method])) {
+ return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity));
+ }
+ throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"');
+ });
+ });
- return result;
-});
+ /**
+ * See if an object (`val`) is an instance of the supplied constructor. This
+ * function will check up the inheritance chain, if any.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category Type
+ * @sig (* -> {*}) -> a -> Boolean
+ * @param {Object} ctor A constructor
+ * @param {*} val The value to test
+ * @return {Boolean}
+ * @example
+ *
+ * R.is(Object, {}); //=> true
+ * R.is(Number, 1); //=> true
+ * R.is(Object, 1); //=> false
+ * R.is(String, 's'); //=> true
+ * R.is(String, new String('')); //=> true
+ * R.is(Object, new String('')); //=> true
+ * R.is(Object, 's'); //=> false
+ * R.is(Number, {}); //=> false
+ */
+ var is = _curry2(function is(Ctor, val) {
+ return (val != null && val.constructor === Ctor) || val instanceof Ctor;
+ });
-/**
- * Creates a new object with the own properties of the two provided objects.
- * If a key exists in both objects:
- * - and both associated values are also objects then the values will be
- * recursively merged.
- * - otherwise the provided function is applied to the key and associated values
- * using the resulting value as the new value associated with the key.
- * If a key only exists in one object, the value will be associated with the key
- * of the resulting object.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Object
- * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a}
- * @param {Function} fn
- * @param {Object} lObj
- * @param {Object} rObj
- * @return {Object}
- * @see R.mergeWithKey, R.mergeDeepWith
- * @example
- *
- * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
- * R.mergeDeepWithKey(concatValues,
- * { a: true, c: { thing: 'foo', values: [10, 20] }},
- * { b: true, c: { thing: 'bar', values: [15, 35] }});
- * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
- */
-var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
- return mergeWithKey(function(k, lVal, rVal) {
- if (_isObject(lVal) && _isObject(rVal)) {
- return mergeDeepWithKey(fn, lVal, rVal);
+ /**
+ * Returns `true` if the given value is its type's empty value; `false`
+ * otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Logic
+ * @sig a -> Boolean
+ * @param {*} x
+ * @return {Boolean}
+ * @see R.empty
+ * @example
+ *
+ * R.isEmpty([1, 2, 3]); //=> false
+ * R.isEmpty([]); //=> true
+ * R.isEmpty(''); //=> true
+ * R.isEmpty(null); //=> false
+ * R.isEmpty({}); //=> true
+ * R.isEmpty({length: 0}); //=> false
+ */
+ var isEmpty = _curry1(function isEmpty(x) {
+ return x != null && equals(x, empty(x));
+ });
+
+ /**
+ * Returns a string made by inserting the `separator` between each element and
+ * concatenating all the elements into a single string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig String -> [a] -> String
+ * @param {Number|String} separator The string used to separate the elements.
+ * @param {Array} xs The elements to join into a string.
+ * @return {String} str The string made by concatenating `xs` with `separator`.
+ * @see R.split
+ * @example
+ *
+ * const spacer = R.join(' ');
+ * spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
+ * R.join('|', [1, 2, 3]); //=> '1|2|3'
+ */
+ var join = invoker(1, 'join');
+
+ /**
+ * juxt applies a list of functions to a list of values.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Function
+ * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n])
+ * @param {Array} fns An array of functions
+ * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters.
+ * @see R.applySpec
+ * @example
+ *
+ * const getRange = R.juxt([Math.min, Math.max]);
+ * getRange(3, 4, 9, -3); //=> [-3, 9]
+ * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)]
+ */
+ var juxt = _curry1(function juxt(fns) {
+ return converge(function () {
+ return Array.prototype.slice.call(arguments, 0);
+ }, fns);
+ });
+
+ /**
+ * Returns a list containing the names of all the properties of the supplied
+ * object, including prototype properties.
+ * Note that the order of the output array is not guaranteed to be consistent
+ * across different JS platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category Object
+ * @sig {k: v} -> [k]
+ * @param {Object} obj The object to extract properties from
+ * @return {Array} An array of the object's own and prototype properties.
+ * @see R.keys, R.valuesIn
+ * @example
+ *
+ * const F = function() { this.x = 'X'; };
+ * F.prototype.y = 'Y';
+ * const f = new F();
+ * R.keysIn(f); //=> ['x', 'y']
+ */
+ var keysIn = _curry1(function keysIn(obj) {
+ var prop;
+ var ks = [];
+ for (prop in obj) {
+ ks[ks.length] = prop;
+ }
+ return ks;
+ });
+
+ /**
+ * Returns the position of the last occurrence of an item in an array, or -1 if
+ * the item is not included in the array. [`R.equals`](#equals) is used to
+ * determine equality.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> Number
+ * @param {*} target The item to find.
+ * @param {Array} xs The array to search in.
+ * @return {Number} the index of the target, or -1 if the target is not found.
+ * @see R.indexOf
+ * @example
+ *
+ * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6
+ * R.lastIndexOf(10, [1,2,3,4]); //=> -1
+ */
+ var lastIndexOf = _curry2(function lastIndexOf(target, xs) {
+ if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) {
+ return xs.lastIndexOf(target);
} else {
- return fn(k, lVal, rVal);
+ var idx = xs.length - 1;
+ while (idx >= 0) {
+ if (equals(xs[idx], target)) {
+ return idx;
+ }
+ idx -= 1;
+ }
+ return -1;
}
- }, lObj, rObj);
-});
+ });
-/**
- * Creates a new object with the own properties of the first object merged with
- * the own properties of the second object. If a key exists in both objects:
- * - and both values are objects, the two values will be recursively merged
- * - otherwise the value from the first object will be used.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Object
- * @sig {a} -> {a} -> {a}
- * @param {Object} lObj
- * @param {Object} rObj
- * @return {Object}
- * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey
- * @example
- *
- * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
- * { age: 40, contact: { email: 'baa@example.com' }});
- * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }}
- */
-var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) {
- return mergeDeepWithKey(function(k, lVal, rVal) {
- return lVal;
- }, lObj, rObj);
-});
+ function _isNumber(x) {
+ return Object.prototype.toString.call(x) === '[object Number]';
+ }
+
+ /**
+ * Returns the number of elements in the array by returning `list.length`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category List
+ * @sig [a] -> Number
+ * @param {Array} list The array to inspect.
+ * @return {Number} The length of the array.
+ * @example
+ *
+ * R.length([]); //=> 0
+ * R.length([1, 2, 3]); //=> 3
+ */
+ var length = _curry1(function length(list) {
+ return list != null && _isNumber(list.length) ? list.length : NaN;
+ });
-/**
- * Creates a new object with the own properties of the first object merged with
- * the own properties of the second object. If a key exists in both objects:
- * - and both values are objects, the two values will be recursively merged
- * - otherwise the value from the second object will be used.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Object
- * @sig {a} -> {a} -> {a}
- * @param {Object} lObj
- * @param {Object} rObj
- * @return {Object}
- * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey
- * @example
- *
- * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
- * { age: 40, contact: { email: 'baa@example.com' }});
- * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}
- */
-var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) {
- return mergeDeepWithKey(function(k, lVal, rVal) {
- return rVal;
- }, lObj, rObj);
-});
+ /**
+ * Returns a lens for the given getter and setter functions. The getter "gets"
+ * the value of the focus; the setter "sets" the value of the focus. The setter
+ * should not mutate the data structure.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig (s -> a) -> ((a, s) -> s) -> Lens s a
+ * @param {Function} getter
+ * @param {Function} setter
+ * @return {Lens}
+ * @see R.view, R.set, R.over, R.lensIndex, R.lensProp
+ * @example
+ *
+ * const xLens = R.lens(R.prop('x'), R.assoc('x'));
+ *
+ * R.view(xLens, {x: 1, y: 2}); //=> 1
+ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
+ * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
+ */
+ var lens = _curry2(function lens(getter, setter) {
+ return function (toFunctorFn) {
+ return function (target) {
+ return map(function (focus) {
+ return setter(focus, target);
+ }, toFunctorFn(getter(target)));
+ };
+ };
+ });
-/**
- * Creates a new object with the own properties of the two provided objects.
- * If a key exists in both objects:
- * - and both associated values are also objects then the values will be
- * recursively merged.
- * - otherwise the provided function is applied to associated values using the
- * resulting value as the new value associated with the key.
- * If a key only exists in one object, the value will be associated with the key
- * of the resulting object.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Object
- * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
- * @param {Function} fn
- * @param {Object} lObj
- * @param {Object} rObj
- * @return {Object}
- * @see R.mergeWith, R.mergeDeepWithKey
- * @example
- *
- * R.mergeDeepWith(R.concat,
- * { a: true, c: { values: [10, 20] }},
- * { b: true, c: { values: [15, 35] }});
- * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
- */
-var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) {
- return mergeDeepWithKey(function(k, lVal, rVal) {
- return fn(lVal, rVal);
- }, lObj, rObj);
-});
+ /**
+ * Returns a lens whose focus is the specified index.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig Number -> Lens s a
+ * @param {Number} n
+ * @return {Lens}
+ * @see R.view, R.set, R.over
+ * @example
+ *
+ * const headLens = R.lensIndex(0);
+ *
+ * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
+ * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
+ * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
+ */
+ var lensIndex = _curry1(function lensIndex(n) {
+ return lens(nth(n), update(n));
+ });
-/**
- * Create a new object with the own properties of the first object merged with
- * the own properties of the second object. If a key exists in both objects,
- * the value from the first object will be used.
- *
- * @func
- * @memberOf R
- * @category Object
- * @sig {k: v} -> {k: v} -> {k: v}
- * @param {Object} l
- * @param {Object} r
- * @return {Object}
- * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey
- * @example
- *
- * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
- * //=> { 'name': 'fred', 'age': 40 }
- *
- * const resetToDefault = R.mergeLeft({x: 0});
- * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2}
- * @symb R.mergeLeft(a, b) = {...b, ...a}
- */
-var mergeLeft = _curry2(function mergeLeft(l, r) {
- return _objectAssign$1({}, r, l);
-});
+ /**
+ * Returns a lens whose focus is the specified path.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig [Idx] -> Lens s a
+ * @param {Array} path The path to use.
+ * @return {Lens}
+ * @see R.view, R.set, R.over
+ * @example
+ *
+ * const xHeadYLens = R.lensPath(['x', 0, 'y']);
+ *
+ * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
+ * //=> 2
+ * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
+ * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
+ * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
+ * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}
+ */
+ var lensPath = _curry1(function lensPath(p) {
+ return lens(path(p), assocPath(p));
+ });
-/**
- * Create a new object with the own properties of the first object merged with
- * the own properties of the second object. If a key exists in both objects,
- * the value from the second object will be used.
- *
- * @func
- * @memberOf R
- * @category Object
- * @sig {k: v} -> {k: v} -> {k: v}
- * @param {Object} l
- * @param {Object} r
- * @return {Object}
- * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey
- * @example
- *
- * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
- * //=> { 'name': 'fred', 'age': 40 }
- *
- * const withDefaults = R.mergeRight({x: 0, y: 0});
- * withDefaults({y: 2}); //=> {x: 0, y: 2}
- * @symb R.mergeRight(a, b) = {...a, ...b}
- */
-var mergeRight = _curry2(function mergeRight(l, r) {
- return _objectAssign$1({}, l, r);
-});
+ /**
+ * Returns a lens whose focus is the specified property.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig String -> Lens s a
+ * @param {String} k
+ * @return {Lens}
+ * @see R.view, R.set, R.over
+ * @example
+ *
+ * const xLens = R.lensProp('x');
+ *
+ * R.view(xLens, {x: 1, y: 2}); //=> 1
+ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
+ * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
+ */
+ var lensProp = _curry1(function lensProp(k) {
+ return lens(prop(k), assoc(k));
+ });
-/**
- * Creates a new object with the own properties of the two provided objects. If
- * a key exists in both objects, the provided function is applied to the values
- * associated with the key in each object, with the result being used as the
- * value associated with the key in the returned object.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Object
- * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
- * @param {Function} fn
- * @param {Object} l
- * @param {Object} r
- * @return {Object}
- * @see R.mergeDeepWith, R.merge, R.mergeWithKey
- * @example
- *
- * R.mergeWith(R.concat,
- * { a: true, values: [10, 20] },
- * { b: true, values: [15, 35] });
- * //=> { a: true, b: true, values: [10, 20, 15, 35] }
- */
-var mergeWith = _curry3(function mergeWith(fn, l, r) {
- return mergeWithKey(function(_, _l, _r) {
- return fn(_l, _r);
- }, l, r);
-});
+ /**
+ * Returns `true` if the first argument is less than the second; `false`
+ * otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> Boolean
+ * @param {*} a
+ * @param {*} b
+ * @return {Boolean}
+ * @see R.gt
+ * @example
+ *
+ * R.lt(2, 1); //=> false
+ * R.lt(2, 2); //=> false
+ * R.lt(2, 3); //=> true
+ * R.lt('a', 'z'); //=> true
+ * R.lt('z', 'a'); //=> false
+ */
+ var lt = _curry2(function lt(a, b) {
+ return a < b;
+ });
+
+ /**
+ * Returns `true` if the first argument is less than or equal to the second;
+ * `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> Boolean
+ * @param {Number} a
+ * @param {Number} b
+ * @return {Boolean}
+ * @see R.gte
+ * @example
+ *
+ * R.lte(2, 1); //=> false
+ * R.lte(2, 2); //=> true
+ * R.lte(2, 3); //=> true
+ * R.lte('a', 'z'); //=> true
+ * R.lte('z', 'a'); //=> false
+ */
+ var lte = _curry2(function lte(a, b) {
+ return a <= b;
+ });
-/**
- * Returns the smaller of its two arguments.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord a => a -> a -> a
- * @param {*} a
- * @param {*} b
- * @return {*}
- * @see R.minBy, R.max
- * @example
- *
- * R.min(789, 123); //=> 123
- * R.min('a', 'b'); //=> 'a'
- */
-var min = _curry2(function min(a, b) { return b < a ? b : a; });
+ /**
+ * The `mapAccum` function behaves like a combination of map and reduce; it
+ * applies a function to each element of a list, passing an accumulating
+ * parameter from left to right, and returning a final value of this
+ * accumulator together with the new list.
+ *
+ * The iterator function receives two arguments, *acc* and *value*, and should
+ * return a tuple *[acc, value]*.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category List
+ * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y])
+ * @param {Function} fn The function to be called on every element of the input `list`.
+ * @param {*} acc The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.scan, R.addIndex, R.mapAccumRight
+ * @example
+ *
+ * const digits = ['1', '2', '3', '4'];
+ * const appender = (a, b) => [a + b, a + b];
+ *
+ * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']]
+ * @symb R.mapAccum(f, a, [b, c, d]) = [
+ * f(f(f(a, b)[0], c)[0], d)[0],
+ * [
+ * f(a, b)[1],
+ * f(f(a, b)[0], c)[1],
+ * f(f(f(a, b)[0], c)[0], d)[1]
+ * ]
+ * ]
+ */
+ var mapAccum = _curry3(function mapAccum(fn, acc, list) {
+ var idx = 0;
+ var len = list.length;
+ var result = [];
+ var tuple = [acc];
+ while (idx < len) {
+ tuple = fn(tuple[0], list[idx]);
+ result[idx] = tuple[1];
+ idx += 1;
+ }
+ return [tuple[0], result];
+ });
-/**
- * Takes a function and two values, and returns whichever value produces the
- * smaller result when passed to the provided function.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Relation
- * @sig Ord b => (a -> b) -> a -> a -> a
- * @param {Function} f
- * @param {*} a
- * @param {*} b
- * @return {*}
- * @see R.min, R.maxBy
- * @example
- *
- * // square :: Number -> Number
- * const square = n => n * n;
- *
- * R.minBy(square, -3, 2); //=> 2
- *
- * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
- * R.reduce(R.minBy(square), Infinity, []); //=> Infinity
- */
-var minBy = _curry3(function minBy(f, a, b) {
- return f(b) < f(a) ? b : a;
-});
+ /**
+ * The `mapAccumRight` function behaves like a combination of map and reduce; it
+ * applies a function to each element of a list, passing an accumulating
+ * parameter from right to left, and returning a final value of this
+ * accumulator together with the new list.
+ *
+ * Similar to [`mapAccum`](#mapAccum), except moves through the input list from
+ * the right to the left.
+ *
+ * The iterator function receives two arguments, *acc* and *value*, and should
+ * return a tuple *[acc, value]*.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category List
+ * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y])
+ * @param {Function} fn The function to be called on every element of the input `list`.
+ * @param {*} acc The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.addIndex, R.mapAccum
+ * @example
+ *
+ * const digits = ['1', '2', '3', '4'];
+ * const appender = (a, b) => [b + a, b + a];
+ *
+ * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']]
+ * @symb R.mapAccumRight(f, a, [b, c, d]) = [
+ * f(f(f(a, d)[0], c)[0], b)[0],
+ * [
+ * f(a, d)[1],
+ * f(f(a, d)[0], c)[1],
+ * f(f(f(a, d)[0], c)[0], b)[1]
+ * ]
+ * ]
+ */
+ var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) {
+ var idx = list.length - 1;
+ var result = [];
+ var tuple = [acc];
+ while (idx >= 0) {
+ tuple = fn(tuple[0], list[idx]);
+ result[idx] = tuple[1];
+ idx -= 1;
+ }
+ return [tuple[0], result];
+ });
-/**
- * Divides the first parameter by the second and returns the remainder. Note
- * that this function preserves the JavaScript-style behavior for modulo. For
- * mathematical modulo see [`mathMod`](#mathMod).
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} a The value to the divide.
- * @param {Number} b The pseudo-modulus
- * @return {Number} The result of `b % a`.
- * @see R.mathMod
- * @example
- *
- * R.modulo(17, 3); //=> 2
- * // JS behavior:
- * R.modulo(-17, 3); //=> -2
- * R.modulo(17, -3); //=> 2
- *
- * const isOdd = R.modulo(R.__, 2);
- * isOdd(42); //=> 0
- * isOdd(21); //=> 1
- */
-var modulo = _curry2(function modulo(a, b) { return a % b; });
+ /**
+ * An Object-specific version of [`map`](#map). The function is applied to three
+ * arguments: *(value, key, obj)*. If only the value is significant, use
+ * [`map`](#map) instead.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Object
+ * @sig ((*, String, Object) -> *) -> Object -> Object
+ * @param {Function} fn
+ * @param {Object} obj
+ * @return {Object}
+ * @see R.map
+ * @example
+ *
+ * const xyz = { x: 1, y: 2, z: 3 };
+ * const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
+ *
+ * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
+ */
+ var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) {
+ return _reduce(
+ function (acc, key) {
+ acc[key] = fn(obj[key], key, obj);
+ return acc;
+ },
+ {},
+ keys(obj)
+ );
+ });
-/**
- * Multiplies two numbers. Equivalent to `a * b` but curried.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} a The first value.
- * @param {Number} b The second value.
- * @return {Number} The result of `a * b`.
- * @see R.divide
- * @example
- *
- * const double = R.multiply(2);
- * const triple = R.multiply(3);
- * double(3); //=> 6
- * triple(4); //=> 12
- * R.multiply(2, 5); //=> 10
- */
-var multiply = _curry2(function multiply(a, b) { return a * b; });
+ /**
+ * Tests a regular expression against a String. Note that this function will
+ * return an empty array when there are no matches. This differs from
+ * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
+ * which returns `null` when there are no matches.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category String
+ * @sig RegExp -> String -> [String | Undefined]
+ * @param {RegExp} rx A regular expression.
+ * @param {String} str The string to match against
+ * @return {Array} The list of matches or empty array.
+ * @see R.test
+ * @example
+ *
+ * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
+ * R.match(/a/, 'b'); //=> []
+ * R.match(/a/, null); //=> TypeError: null does not have a method named "match"
+ */
+ var match = _curry2(function match(rx, str) {
+ return str.match(rx) || [];
+ });
-/**
- * Negates its argument.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Math
- * @sig Number -> Number
- * @param {Number} n
- * @return {Number}
- * @example
- *
- * R.negate(42); //=> -42
- */
-var negate = _curry1(function negate(n) { return -n; });
+ /**
+ * `mathMod` behaves like the modulo operator should mathematically, unlike the
+ * `%` operator (and by extension, [`R.modulo`](#modulo)). So while
+ * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer
+ * arguments, and returns NaN when the modulus is zero or negative.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} m The dividend.
+ * @param {Number} p the modulus.
+ * @return {Number} The result of `b mod a`.
+ * @see R.modulo
+ * @example
+ *
+ * R.mathMod(-17, 5); //=> 3
+ * R.mathMod(17, 5); //=> 2
+ * R.mathMod(17, -5); //=> NaN
+ * R.mathMod(17, 0); //=> NaN
+ * R.mathMod(17.2, 5); //=> NaN
+ * R.mathMod(17, 5.3); //=> NaN
+ *
+ * const clock = R.mathMod(R.__, 12);
+ * clock(15); //=> 3
+ * clock(24); //=> 0
+ *
+ * const seventeenMod = R.mathMod(17);
+ * seventeenMod(3); //=> 2
+ * seventeenMod(4); //=> 1
+ * seventeenMod(10); //=> 7
+ */
+ var mathMod = _curry2(function mathMod(m, p) {
+ if (!_isInteger(m)) {
+ return NaN;
+ }
+ if (!_isInteger(p) || p < 1) {
+ return NaN;
+ }
+ return ((m % p) + p) % p;
+ });
-/**
- * Returns `true` if no elements of the list match the predicate, `false`
- * otherwise.
- *
- * Dispatches to the `all` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> Boolean
- * @param {Function} fn The predicate function.
- * @param {Array} list The array to consider.
- * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise.
- * @see R.all, R.any
- * @example
- *
- * const isEven = n => n % 2 === 0;
- * const isOdd = n => n % 2 === 1;
- *
- * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true
- * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false
- */
-const none = _curry2(function none(fn, input) {
- return all(_complement(fn), input);
-});
+ /**
+ * Takes a function and two values, and returns whichever value produces the
+ * larger result when passed to the provided function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Relation
+ * @sig Ord b => (a -> b) -> a -> a -> a
+ * @param {Function} f
+ * @param {*} a
+ * @param {*} b
+ * @return {*}
+ * @see R.max, R.minBy
+ * @example
+ *
+ * // square :: Number -> Number
+ * const square = n => n * n;
+ *
+ * R.maxBy(square, -3, 2); //=> -3
+ *
+ * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
+ * R.reduce(R.maxBy(square), 0, []); //=> 0
+ */
+ var maxBy = _curry3(function maxBy(f, a, b) {
+ return f(b) > f(a) ? b : a;
+ });
-/**
- * Returns a function which returns its nth argument.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category Function
- * @sig Number -> *... -> *
- * @param {Number} n
- * @return {Function}
- * @example
- *
- * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
- * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
- * @symb R.nthArg(-1)(a, b, c) = c
- * @symb R.nthArg(0)(a, b, c) = a
- * @symb R.nthArg(1)(a, b, c) = b
- */
-var nthArg = _curry1(function nthArg(n) {
- var arity = n < 0 ? 1 : n + 1;
- return curryN(arity, function() {
- return nth(n, arguments);
+ /**
+ * Adds together all the elements of a list.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig [Number] -> Number
+ * @param {Array} list An array of numbers
+ * @return {Number} The sum of all the numbers in the list.
+ * @see R.reduce
+ * @example
+ *
+ * R.sum([2,4,6,8,100,1]); //=> 121
+ */
+ var sum = reduce(add, 0);
+
+ /**
+ * Returns the mean of the given list of numbers.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Math
+ * @sig [Number] -> Number
+ * @param {Array} list
+ * @return {Number}
+ * @see R.median
+ * @example
+ *
+ * R.mean([2, 7, 9]); //=> 6
+ * R.mean([]); //=> NaN
+ */
+ var mean = _curry1(function mean(list) {
+ return sum(list) / list.length;
});
-});
-/**
- * `o` is a curried composition function that returns a unary function.
- * Like [`compose`](#compose), `o` performs right-to-left function composition.
- * Unlike [`compose`](#compose), the rightmost function passed to `o` will be
- * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is
- * limited to accepting only 2 unary functions. The name o was chosen because
- * of its similarity to the mathematical composition operator ∘.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category Function
- * @sig (b -> c) -> (a -> b) -> a -> c
- * @param {Function} f
- * @param {Function} g
- * @return {Function}
- * @see R.compose, R.pipe
- * @example
- *
- * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last
- * const yellGreeting = R.o(R.toUpper, classyGreeting);
- * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND"
- *
- * R.o(R.multiply(10), R.add(10))(-4) //=> 60
- *
- * @symb R.o(f, g, x) = f(g(x))
- */
-var o = _curry3(function o(f, g, x) {
- return f(g(x));
-});
+ /**
+ * Returns the median of the given list of numbers.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Math
+ * @sig [Number] -> Number
+ * @param {Array} list
+ * @return {Number}
+ * @see R.mean
+ * @example
+ *
+ * R.median([2, 9, 7]); //=> 7
+ * R.median([7, 2, 10, 9]); //=> 8
+ * R.median([]); //=> NaN
+ */
+ var median = _curry1(function median(list) {
+ var len = list.length;
+ if (len === 0) {
+ return NaN;
+ }
+ var width = 2 - (len % 2);
+ var idx = (len - width) / 2;
+ return mean(
+ Array.prototype.slice
+ .call(list, 0)
+ .sort(function (a, b) {
+ return a < b ? -1 : a > b ? 1 : 0;
+ })
+ .slice(idx, idx + width)
+ );
+ });
-function _of(x) { return [x]; }
+ /**
+ * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an
+ * additional function that will be applied to a given argument set and used to
+ * create the cache key under which the results of the function to be memoized
+ * will be stored. Care must be taken when implementing key generation to avoid
+ * clashes that may overwrite previous entries erroneously.
+ *
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Function
+ * @sig (*... -> String) -> (*... -> a) -> (*... -> a)
+ * @param {Function} fn The function to generate the cache key.
+ * @param {Function} fn The function to memoize.
+ * @return {Function} Memoized version of `fn`.
+ * @example
+ *
+ * let count = 0;
+ * const factorial = R.memoizeWith(R.identity, n => {
+ * count += 1;
+ * return R.product(R.range(1, n + 1));
+ * });
+ * factorial(5); //=> 120
+ * factorial(5); //=> 120
+ * factorial(5); //=> 120
+ * count; //=> 1
+ */
+ var memoizeWith = _curry2(function memoizeWith(mFn, fn) {
+ var cache = {};
+ return _arity(fn.length, function () {
+ var key = mFn.apply(this, arguments);
+ if (!_has(key, cache)) {
+ cache[key] = fn.apply(this, arguments);
+ }
+ return cache[key];
+ });
+ });
-/**
- * Returns a singleton array containing the value provided.
- *
- * Note this `of` is different from the ES6 `of`; See
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category Function
- * @sig a -> [a]
- * @param {*} x any value
- * @return {Array} An array wrapping `x`.
- * @example
- *
- * R.of(null); //=> [null]
- * R.of([42]); //=> [[42]]
- */
-var of = _curry1(_of);
+ /**
+ * Create a new object with the own properties of the first object merged with
+ * the own properties of the second object. If a key exists in both objects,
+ * the value from the second object will be used.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig {k: v} -> {k: v} -> {k: v}
+ * @param {Object} l
+ * @param {Object} r
+ * @return {Object}
+ * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey
+ * @deprecated
+ * @example
+ *
+ * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
+ * //=> { 'name': 'fred', 'age': 40 }
+ *
+ * const withDefaults = R.merge({x: 0, y: 0});
+ * withDefaults({y: 2}); //=> {x: 0, y: 2}
+ * @symb R.merge(a, b) = {...a, ...b}
+ */
+ var merge = _curry2(function merge(l, r) {
+ return _objectAssign$1({}, l, r);
+ });
-/**
- * Returns a partial copy of an object omitting the keys specified.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig [String] -> {String: *} -> {String: *}
- * @param {Array} names an array of String property names to omit from the new object
- * @param {Object} obj The object to copy from
- * @return {Object} A new object with properties from `names` not on it.
- * @see R.pick
- * @example
- *
- * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
- */
-var omit = _curry2(function omit(names, obj) {
- var result = {};
- var index = {};
- var idx = 0;
- var len = names.length;
-
- while (idx < len) {
- index[names[idx]] = 1;
- idx += 1;
- }
+ /**
+ * Merges a list of objects together into one object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category List
+ * @sig [{k: v}] -> {k: v}
+ * @param {Array} list An array of objects
+ * @return {Object} A merged object.
+ * @see R.reduce
+ * @example
+ *
+ * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
+ * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}
+ * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 }
+ */
+ var mergeAll = _curry1(function mergeAll(list) {
+ return _objectAssign$1.apply(null, [{}].concat(list));
+ });
- for (var prop in obj) {
- if (!index.hasOwnProperty(prop)) {
- result[prop] = obj[prop];
+ /**
+ * Creates a new object with the own properties of the two provided objects. If
+ * a key exists in both objects, the provided function is applied to the key
+ * and the values associated with the key in each object, with the result being
+ * used as the value associated with the key in the returned object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Object
+ * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a}
+ * @param {Function} fn
+ * @param {Object} l
+ * @param {Object} r
+ * @return {Object}
+ * @see R.mergeDeepWithKey, R.merge, R.mergeWith
+ * @example
+ *
+ * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
+ * R.mergeWithKey(concatValues,
+ * { a: true, thing: 'foo', values: [10, 20] },
+ * { b: true, thing: 'bar', values: [15, 35] });
+ * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
+ * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
+ */
+ var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) {
+ var result = {};
+ var k;
+
+ for (k in l) {
+ if (_has(k, l)) {
+ result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k];
+ }
}
- }
- return result;
-});
-/**
- * Accepts a function `fn` and returns a function that guards invocation of
- * `fn` such that `fn` can only ever be called once, no matter how many times
- * the returned function is invoked. The first value calculated is returned in
- * subsequent invocations.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig (a... -> b) -> (a... -> b)
- * @param {Function} fn The function to wrap in a call-only-once wrapper.
- * @return {Function} The wrapped function.
- * @example
- *
- * const addOneOnce = R.once(x => x + 1);
- * addOneOnce(10); //=> 11
- * addOneOnce(addOneOnce(50)); //=> 11
- */
-var once = _curry1(function once(fn) {
- var called = false;
- var result;
- return _arity(fn.length, function() {
- if (called) {
- return result;
+ for (k in r) {
+ if (_has(k, r) && !_has(k, result)) {
+ result[k] = r[k];
+ }
}
- called = true;
- result = fn.apply(this, arguments);
+
return result;
});
-});
-function _assertPromise(name, p) {
- if (p == null || !_isFunction(p.then)) {
- throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, []));
- }
-}
+ /**
+ * Creates a new object with the own properties of the two provided objects.
+ * If a key exists in both objects:
+ * - and both associated values are also objects then the values will be
+ * recursively merged.
+ * - otherwise the provided function is applied to the key and associated values
+ * using the resulting value as the new value associated with the key.
+ * If a key only exists in one object, the value will be associated with the key
+ * of the resulting object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Object
+ * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a}
+ * @param {Function} fn
+ * @param {Object} lObj
+ * @param {Object} rObj
+ * @return {Object}
+ * @see R.mergeWithKey, R.mergeDeepWith
+ * @example
+ *
+ * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
+ * R.mergeDeepWithKey(concatValues,
+ * { a: true, c: { thing: 'foo', values: [10, 20] }},
+ * { b: true, c: { thing: 'bar', values: [15, 35] }});
+ * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
+ */
+ var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
+ return mergeWithKey(
+ function (k, lVal, rVal) {
+ if (_isObject(lVal) && _isObject(rVal)) {
+ return mergeDeepWithKey(fn, lVal, rVal);
+ } else {
+ return fn(k, lVal, rVal);
+ }
+ },
+ lObj,
+ rObj
+ );
+ });
-/**
- * Returns the result of applying the onFailure function to the value inside
- * a failed promise. This is useful for handling rejected promises
- * inside function compositions.
- *
- * @func
- * @memberOf R
- * @category Function
- * @sig (e -> b) -> (Promise e a) -> (Promise e b)
- * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b)
- * @param {Function} onFailure The function to apply. Can return a value or a promise of a value.
- * @param {Promise} p
- * @return {Promise} The result of calling `p.then(null, onFailure)`
- * @see R.then
- * @example
- *
- * var failedFetch = (id) => Promise.reject('bad ID');
- * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' })
- *
- * //recoverFromFailure :: String -> Promise ({firstName, lastName})
- * var recoverFromFailure = R.pipe(
- * failedFetch(12345),
- * R.otherwise(useDefault),
- * R.then(R.pick(['firstName', 'lastName']))
- * );
- */
-const otherwise = _curry2(function otherwise(f, p) {
- _assertPromise('otherwise', p);
+ /**
+ * Creates a new object with the own properties of the first object merged with
+ * the own properties of the second object. If a key exists in both objects:
+ * - and both values are objects, the two values will be recursively merged
+ * - otherwise the value from the first object will be used.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Object
+ * @sig {a} -> {a} -> {a}
+ * @param {Object} lObj
+ * @param {Object} rObj
+ * @return {Object}
+ * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey
+ * @example
+ *
+ * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
+ * { age: 40, contact: { email: 'baa@example.com' }});
+ * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }}
+ */
+ var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) {
+ return mergeDeepWithKey(
+ function (k, lVal, rVal) {
+ return lVal;
+ },
+ lObj,
+ rObj
+ );
+ });
- return p.then(null, f);
-});
+ /**
+ * Creates a new object with the own properties of the first object merged with
+ * the own properties of the second object. If a key exists in both objects:
+ * - and both values are objects, the two values will be recursively merged
+ * - otherwise the value from the second object will be used.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Object
+ * @sig {a} -> {a} -> {a}
+ * @param {Object} lObj
+ * @param {Object} rObj
+ * @return {Object}
+ * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey
+ * @example
+ *
+ * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
+ * { age: 40, contact: { email: 'baa@example.com' }});
+ * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}
+ */
+ var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) {
+ return mergeDeepWithKey(
+ function (k, lVal, rVal) {
+ return rVal;
+ },
+ lObj,
+ rObj
+ );
+ });
-// `Identity` is a functor that holds a single value, where `map` simply
-// transforms the held value with the provided function.
-var Identity = function(x) {
- return {value: x, map: function(f) { return Identity(f(x)); }};
-};
+ /**
+ * Creates a new object with the own properties of the two provided objects.
+ * If a key exists in both objects:
+ * - and both associated values are also objects then the values will be
+ * recursively merged.
+ * - otherwise the provided function is applied to associated values using the
+ * resulting value as the new value associated with the key.
+ * If a key only exists in one object, the value will be associated with the key
+ * of the resulting object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Object
+ * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
+ * @param {Function} fn
+ * @param {Object} lObj
+ * @param {Object} rObj
+ * @return {Object}
+ * @see R.mergeWith, R.mergeDeepWithKey
+ * @example
+ *
+ * R.mergeDeepWith(R.concat,
+ * { a: true, c: { values: [10, 20] }},
+ * { b: true, c: { values: [15, 35] }});
+ * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
+ */
+ var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) {
+ return mergeDeepWithKey(
+ function (k, lVal, rVal) {
+ return fn(lVal, rVal);
+ },
+ lObj,
+ rObj
+ );
+ });
+ /**
+ * Create a new object with the own properties of the first object merged with
+ * the own properties of the second object. If a key exists in both objects,
+ * the value from the first object will be used.
+ *
+ * @func
+ * @memberOf R
+ * @category Object
+ * @sig {k: v} -> {k: v} -> {k: v}
+ * @param {Object} l
+ * @param {Object} r
+ * @return {Object}
+ * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey
+ * @example
+ *
+ * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
+ * //=> { 'name': 'fred', 'age': 40 }
+ *
+ * const resetToDefault = R.mergeLeft({x: 0});
+ * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2}
+ * @symb R.mergeLeft(a, b) = {...b, ...a}
+ */
+ var mergeLeft = _curry2(function mergeLeft(l, r) {
+ return _objectAssign$1({}, r, l);
+ });
-/**
- * Returns the result of "setting" the portion of the given data structure
- * focused by the given lens to the result of applying the given function to
- * the focused value.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig Lens s a -> (a -> a) -> s -> s
- * @param {Lens} lens
- * @param {*} v
- * @param {*} x
- * @return {*}
- * @see R.prop, R.lensIndex, R.lensProp
- * @example
- *
- * const headLens = R.lensIndex(0);
- *
- * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz']
- */
-var over = _curry3(function over(lens, f, x) {
- // The value returned by the getter function is first transformed with `f`,
- // then set as the value of an `Identity`. This is then mapped over with the
- // setter function of the lens.
- return lens(function(y) { return Identity(f(y)); })(x).value;
-});
+ /**
+ * Create a new object with the own properties of the first object merged with
+ * the own properties of the second object. If a key exists in both objects,
+ * the value from the second object will be used.
+ *
+ * @func
+ * @memberOf R
+ * @category Object
+ * @sig {k: v} -> {k: v} -> {k: v}
+ * @param {Object} l
+ * @param {Object} r
+ * @return {Object}
+ * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey
+ * @example
+ *
+ * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
+ * //=> { 'name': 'fred', 'age': 40 }
+ *
+ * const withDefaults = R.mergeRight({x: 0, y: 0});
+ * withDefaults({y: 2}); //=> {x: 0, y: 2}
+ * @symb R.mergeRight(a, b) = {...a, ...b}
+ */
+ var mergeRight = _curry2(function mergeRight(l, r) {
+ return _objectAssign$1({}, l, r);
+ });
-/**
- * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category List
- * @sig a -> b -> (a,b)
- * @param {*} fst
- * @param {*} snd
- * @return {Array}
- * @see R.objOf, R.of
- * @example
- *
- * R.pair('foo', 'bar'); //=> ['foo', 'bar']
- */
-var pair = _curry2(function pair(fst, snd) { return [fst, snd]; });
+ /**
+ * Creates a new object with the own properties of the two provided objects. If
+ * a key exists in both objects, the provided function is applied to the values
+ * associated with the key in each object, with the result being used as the
+ * value associated with the key in the returned object.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Object
+ * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
+ * @param {Function} fn
+ * @param {Object} l
+ * @param {Object} r
+ * @return {Object}
+ * @see R.mergeDeepWith, R.merge, R.mergeWithKey
+ * @example
+ *
+ * R.mergeWith(R.concat,
+ * { a: true, values: [10, 20] },
+ * { b: true, values: [15, 35] });
+ * //=> { a: true, b: true, values: [10, 20, 15, 35] }
+ */
+ var mergeWith = _curry3(function mergeWith(fn, l, r) {
+ return mergeWithKey(
+ function (_, _l, _r) {
+ return fn(_l, _r);
+ },
+ l,
+ r
+ );
+ });
-function _createPartialApplicator(concat) {
- return _curry2(function(fn, args) {
- return _arity(Math.max(0, fn.length - args.length), function() {
- return fn.apply(this, concat(args, arguments));
- });
+ /**
+ * Returns the smaller of its two arguments.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord a => a -> a -> a
+ * @param {*} a
+ * @param {*} b
+ * @return {*}
+ * @see R.minBy, R.max
+ * @example
+ *
+ * R.min(789, 123); //=> 123
+ * R.min('a', 'b'); //=> 'a'
+ */
+ var min = _curry2(function min(a, b) {
+ return b < a ? b : a;
});
-}
-/**
- * Takes a function `f` and a list of arguments, and returns a function `g`.
- * When applied, `g` returns the result of applying `f` to the arguments
- * provided initially followed by the arguments provided to `g`.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Function
- * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x)
- * @param {Function} f
- * @param {Array} args
- * @return {Function}
- * @see R.partialRight, R.curry
- * @example
- *
- * const multiply2 = (a, b) => a * b;
- * const double = R.partial(multiply2, [2]);
- * double(2); //=> 4
- *
- * const greet = (salutation, title, firstName, lastName) =>
- * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
- *
- * const sayHello = R.partial(greet, ['Hello']);
- * const sayHelloToMs = R.partial(sayHello, ['Ms.']);
- * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'
- * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d)
- */
-var partial = _createPartialApplicator(_concat);
+ /**
+ * Takes a function and two values, and returns whichever value produces the
+ * smaller result when passed to the provided function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Relation
+ * @sig Ord b => (a -> b) -> a -> a -> a
+ * @param {Function} f
+ * @param {*} a
+ * @param {*} b
+ * @return {*}
+ * @see R.min, R.maxBy
+ * @example
+ *
+ * // square :: Number -> Number
+ * const square = n => n * n;
+ *
+ * R.minBy(square, -3, 2); //=> 2
+ *
+ * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
+ * R.reduce(R.minBy(square), Infinity, []); //=> Infinity
+ */
+ var minBy = _curry3(function minBy(f, a, b) {
+ return f(b) < f(a) ? b : a;
+ });
-/**
- * Takes a function `f` and a list of arguments, and returns a function `g`.
- * When applied, `g` returns the result of applying `f` to the arguments
- * provided to `g` followed by the arguments provided initially.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category Function
- * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x)
- * @param {Function} f
- * @param {Array} args
- * @return {Function}
- * @see R.partial
- * @example
- *
- * const greet = (salutation, title, firstName, lastName) =>
- * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
- *
- * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);
- *
- * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
- * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b)
- */
-var partialRight = _createPartialApplicator(flip(_concat));
+ /**
+ * Divides the first parameter by the second and returns the remainder. Note
+ * that this function preserves the JavaScript-style behavior for modulo. For
+ * mathematical modulo see [`mathMod`](#mathMod).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} a The value to the divide.
+ * @param {Number} b The pseudo-modulus
+ * @return {Number} The result of `b % a`.
+ * @see R.mathMod
+ * @example
+ *
+ * R.modulo(17, 3); //=> 2
+ * // JS behavior:
+ * R.modulo(-17, 3); //=> -2
+ * R.modulo(17, -3); //=> 2
+ *
+ * const isOdd = R.modulo(R.__, 2);
+ * isOdd(42); //=> 0
+ * isOdd(21); //=> 1
+ */
+ var modulo = _curry2(function modulo(a, b) {
+ return a % b;
+ });
-/**
- * Takes a predicate and a list or other `Filterable` object and returns the
- * pair of filterable objects of the same type of elements which do and do not
- * satisfy, the predicate, respectively. Filterable objects include plain objects or any object
- * that has a filter method such as `Array`.
- *
- * @func
- * @memberOf R
- * @since v0.1.4
- * @category List
- * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a]
- * @param {Function} pred A predicate to determine which side the element belongs to.
- * @param {Array} filterable the list (or other filterable) to partition.
- * @return {Array} An array, containing first the subset of elements that satisfy the
- * predicate, and second the subset of elements that do not satisfy.
- * @see R.filter, R.reject
- * @example
- *
- * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
- * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
- *
- * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
- * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
- */
-var partition = juxt([filter, reject]);
+ /**
+ * Multiplies two numbers. Equivalent to `a * b` but curried.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} a The first value.
+ * @param {Number} b The second value.
+ * @return {Number} The result of `a * b`.
+ * @see R.divide
+ * @example
+ *
+ * const double = R.multiply(2);
+ * const triple = R.multiply(3);
+ * double(3); //=> 6
+ * triple(4); //=> 12
+ * R.multiply(2, 5); //=> 10
+ */
+ var multiply = _curry2(function multiply(a, b) {
+ return a * b;
+ });
-/**
- * Determines whether a nested path on an object has a specific value, in
- * [`R.equals`](#equals) terms. Most likely used to filter a list.
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category Relation
- * @typedefn Idx = String | Int
- * @sig [Idx] -> a -> {a} -> Boolean
- * @param {Array} path The path of the nested property to use
- * @param {*} val The value to compare the nested property with
- * @param {Object} obj The object to check the nested property in
- * @return {Boolean} `true` if the value equals the nested object property,
- * `false` otherwise.
- * @example
- *
- * const user1 = { address: { zipCode: 90210 } };
- * const user2 = { address: { zipCode: 55555 } };
- * const user3 = { name: 'Bob' };
- * const users = [ user1, user2, user3 ];
- * const isFamous = R.pathEq(['address', 'zipCode'], 90210);
- * R.filter(isFamous, users); //=> [ user1 ]
- */
-var pathEq = _curry3(function pathEq(_path, val, obj) {
- return equals(path(_path, obj), val);
-});
+ /**
+ * Negates its argument.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Math
+ * @sig Number -> Number
+ * @param {Number} n
+ * @return {Number}
+ * @example
+ *
+ * R.negate(42); //=> -42
+ */
+ var negate = _curry1(function negate(n) {
+ return -n;
+ });
-/**
- * If the given, non-null object has a value at the given path, returns the
- * value at that path. Otherwise returns the provided default value.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category Object
- * @typedefn Idx = String | Int
- * @sig a -> [Idx] -> {a} -> a
- * @param {*} d The default value.
- * @param {Array} p The path to use.
- * @param {Object} obj The object to retrieve the nested property from.
- * @return {*} The data at `path` of the supplied object or the default value.
- * @example
- *
- * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
- * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
- */
-var pathOr = _curry3(function pathOr(d, p, obj) {
- return defaultTo(d, path(p, obj));
-});
+ /**
+ * Returns `true` if no elements of the list match the predicate, `false`
+ * otherwise.
+ *
+ * Dispatches to the `all` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> Boolean
+ * @param {Function} fn The predicate function.
+ * @param {Array} list The array to consider.
+ * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise.
+ * @see R.all, R.any
+ * @example
+ *
+ * const isEven = n => n % 2 === 0;
+ * const isOdd = n => n % 2 === 1;
+ *
+ * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true
+ * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false
+ */
+ const none = _curry2(function none(fn, input) {
+ return all(_complement(fn), input);
+ });
-/**
- * Returns `true` if the specified object property at given path satisfies the
- * given predicate; `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Logic
- * @typedefn Idx = String | Int
- * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean
- * @param {Function} pred
- * @param {Array} propPath
- * @param {*} obj
- * @return {Boolean}
- * @see R.propSatisfies, R.path
- * @example
- *
- * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
- */
-var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) {
- return propPath.length > 0 && pred(path(propPath, obj));
-});
+ /**
+ * Returns a function which returns its nth argument.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category Function
+ * @sig Number -> *... -> *
+ * @param {Number} n
+ * @return {Function}
+ * @example
+ *
+ * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
+ * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
+ * @symb R.nthArg(-1)(a, b, c) = c
+ * @symb R.nthArg(0)(a, b, c) = a
+ * @symb R.nthArg(1)(a, b, c) = b
+ */
+ var nthArg = _curry1(function nthArg(n) {
+ var arity = n < 0 ? 1 : n + 1;
+ return curryN(arity, function () {
+ return nth(n, arguments);
+ });
+ });
-/**
- * Returns a partial copy of an object containing only the keys specified. If
- * the key does not exist, the property is ignored.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig [k] -> {k: v} -> {k: v}
- * @param {Array} names an array of String property names to copy onto a new object
- * @param {Object} obj The object to copy from
- * @return {Object} A new object with only properties from `names` on it.
- * @see R.omit, R.props
- * @example
- *
- * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
- * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
- */
-var pick = _curry2(function pick(names, obj) {
- var result = {};
- var idx = 0;
- while (idx < names.length) {
- if (names[idx] in obj) {
- result[names[idx]] = obj[names[idx]];
- }
- idx += 1;
- }
- return result;
-});
+ /**
+ * `o` is a curried composition function that returns a unary function.
+ * Like [`compose`](#compose), `o` performs right-to-left function composition.
+ * Unlike [`compose`](#compose), the rightmost function passed to `o` will be
+ * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is
+ * limited to accepting only 2 unary functions. The name o was chosen because
+ * of its similarity to the mathematical composition operator ∘.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category Function
+ * @sig (b -> c) -> (a -> b) -> a -> c
+ * @param {Function} f
+ * @param {Function} g
+ * @return {Function}
+ * @see R.compose, R.pipe
+ * @example
+ *
+ * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last
+ * const yellGreeting = R.o(R.toUpper, classyGreeting);
+ * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND"
+ *
+ * R.o(R.multiply(10), R.add(10))(-4) //=> 60
+ *
+ * @symb R.o(f, g, x) = f(g(x))
+ */
+ var o = _curry3(function o(f, g, x) {
+ return f(g(x));
+ });
-/**
- * Similar to `pick` except that this one includes a `key: undefined` pair for
- * properties that don't exist.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig [k] -> {k: v} -> {k: v}
- * @param {Array} names an array of String property names to copy onto a new object
- * @param {Object} obj The object to copy from
- * @return {Object} A new object with only properties from `names` on it.
- * @see R.pick
- * @example
- *
- * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
- * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}
- */
-var pickAll = _curry2(function pickAll(names, obj) {
- var result = {};
- var idx = 0;
- var len = names.length;
- while (idx < len) {
- var name = names[idx];
- result[name] = obj[name];
- idx += 1;
- }
- return result;
-});
+ function _of(x) {
+ return [x];
+ }
+
+ /**
+ * Returns a singleton array containing the value provided.
+ *
+ * Note this `of` is different from the ES6 `of`; See
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category Function
+ * @sig a -> [a]
+ * @param {*} x any value
+ * @return {Array} An array wrapping `x`.
+ * @example
+ *
+ * R.of(null); //=> [null]
+ * R.of([42]); //=> [[42]]
+ */
+ var of = _curry1(_of);
+
+ /**
+ * Returns a partial copy of an object omitting the keys specified.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig [String] -> {String: *} -> {String: *}
+ * @param {Array} names an array of String property names to omit from the new object
+ * @param {Object} obj The object to copy from
+ * @return {Object} A new object with properties from `names` not on it.
+ * @see R.pick
+ * @example
+ *
+ * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
+ */
+ var omit = _curry2(function omit(names, obj) {
+ var result = {};
+ var index = {};
+ var idx = 0;
+ var len = names.length;
-/**
- * Returns a partial copy of an object containing only the keys that satisfy
- * the supplied predicate.
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Object
- * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v}
- * @param {Function} pred A predicate to determine whether or not a key
- * should be included on the output object.
- * @param {Object} obj The object to copy from
- * @return {Object} A new object with only properties that satisfy `pred`
- * on it.
- * @see R.pick, R.filter
- * @example
- *
- * const isUpperCase = (val, key) => key.toUpperCase() === key;
- * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
- */
-var pickBy = _curry2(function pickBy(test, obj) {
- var result = {};
- for (var prop in obj) {
- if (test(obj[prop], prop, obj)) {
- result[prop] = obj[prop];
+ while (idx < len) {
+ index[names[idx]] = 1;
+ idx += 1;
+ }
+
+ for (var prop in obj) {
+ if (!index.hasOwnProperty(prop)) {
+ result[prop] = obj[prop];
+ }
+ }
+ return result;
+ });
+
+ /**
+ * Accepts a function `fn` and returns a function that guards invocation of
+ * `fn` such that `fn` can only ever be called once, no matter how many times
+ * the returned function is invoked. The first value calculated is returned in
+ * subsequent invocations.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig (a... -> b) -> (a... -> b)
+ * @param {Function} fn The function to wrap in a call-only-once wrapper.
+ * @return {Function} The wrapped function.
+ * @example
+ *
+ * const addOneOnce = R.once(x => x + 1);
+ * addOneOnce(10); //=> 11
+ * addOneOnce(addOneOnce(50)); //=> 11
+ */
+ var once = _curry1(function once(fn) {
+ var called = false;
+ var result;
+ return _arity(fn.length, function () {
+ if (called) {
+ return result;
+ }
+ called = true;
+ result = fn.apply(this, arguments);
+ return result;
+ });
+ });
+
+ function _assertPromise(name, p) {
+ if (p == null || !_isFunction(p.then)) {
+ throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, []));
}
}
- return result;
-});
-/**
- * Returns the left-to-right Kleisli composition of the provided functions,
- * each of which must return a value of a type supported by [`chain`](#chain).
- *
- * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Function
- * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z)
- * @param {...Function}
- * @return {Function}
- * @see R.composeK
- * @example
- *
- * // parseJson :: String -> Maybe *
- * // get :: String -> Object -> Maybe *
- *
- * // getStateCode :: Maybe String -> Maybe String
- * const getStateCode = R.pipeK(
- * parseJson,
- * get('user'),
- * get('address'),
- * get('state'),
- * R.compose(Maybe.of, R.toUpper)
- * );
- *
- * getStateCode('{"user":{"address":{"state":"ny"}}}');
- * //=> Just('NY')
- * getStateCode('[Invalid JSON]');
- * //=> Nothing()
- * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a)))
- */
-function pipeK() {
- if (arguments.length === 0) {
- throw new Error('pipeK requires at least one argument');
+ /**
+ * Returns the result of applying the onFailure function to the value inside
+ * a failed promise. This is useful for handling rejected promises
+ * inside function compositions.
+ *
+ * @func
+ * @memberOf R
+ * @category Function
+ * @sig (e -> b) -> (Promise e a) -> (Promise e b)
+ * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b)
+ * @param {Function} onFailure The function to apply. Can return a value or a promise of a value.
+ * @param {Promise} p
+ * @return {Promise} The result of calling `p.then(null, onFailure)`
+ * @see R.then
+ * @example
+ *
+ * var failedFetch = (id) => Promise.reject('bad ID');
+ * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' })
+ *
+ * //recoverFromFailure :: String -> Promise ({firstName, lastName})
+ * var recoverFromFailure = R.pipe(
+ * failedFetch(12345),
+ * R.otherwise(useDefault),
+ * R.then(R.pick(['firstName', 'lastName']))
+ * );
+ */
+ const otherwise = _curry2(function otherwise(f, p) {
+ _assertPromise('otherwise', p);
+
+ return p.then(null, f);
+ });
+
+ // `Identity` is a functor that holds a single value, where `map` simply
+ // transforms the held value with the provided function.
+ var Identity = function (x) {
+ return {
+ value: x,
+ map: function (f) {
+ return Identity(f(x));
+ },
+ };
+ };
+
+ /**
+ * Returns the result of "setting" the portion of the given data structure
+ * focused by the given lens to the result of applying the given function to
+ * the focused value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig Lens s a -> (a -> a) -> s -> s
+ * @param {Lens} lens
+ * @param {*} v
+ * @param {*} x
+ * @return {*}
+ * @see R.prop, R.lensIndex, R.lensProp
+ * @example
+ *
+ * const headLens = R.lensIndex(0);
+ *
+ * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz']
+ */
+ var over = _curry3(function over(lens, f, x) {
+ // The value returned by the getter function is first transformed with `f`,
+ // then set as the value of an `Identity`. This is then mapped over with the
+ // setter function of the lens.
+ return lens(function (y) {
+ return Identity(f(y));
+ })(x).value;
+ });
+
+ /**
+ * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category List
+ * @sig a -> b -> (a,b)
+ * @param {*} fst
+ * @param {*} snd
+ * @return {Array}
+ * @see R.objOf, R.of
+ * @example
+ *
+ * R.pair('foo', 'bar'); //=> ['foo', 'bar']
+ */
+ var pair = _curry2(function pair(fst, snd) {
+ return [fst, snd];
+ });
+
+ function _createPartialApplicator(concat) {
+ return _curry2(function (fn, args) {
+ return _arity(Math.max(0, fn.length - args.length), function () {
+ return fn.apply(this, concat(args, arguments));
+ });
+ });
}
- return composeK.apply(this, reverse(arguments));
-}
-/**
- * Returns a new list with the given element at the front, followed by the
- * contents of the list.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig a -> [a] -> [a]
- * @param {*} el The item to add to the head of the output list.
- * @param {Array} list The array to add to the tail of the output list.
- * @return {Array} A new array.
- * @see R.append
- * @example
- *
- * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
- */
-var prepend = _curry2(function prepend(el, list) {
- return _concat([el], list);
-});
+ /**
+ * Takes a function `f` and a list of arguments, and returns a function `g`.
+ * When applied, `g` returns the result of applying `f` to the arguments
+ * provided initially followed by the arguments provided to `g`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Function
+ * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x)
+ * @param {Function} f
+ * @param {Array} args
+ * @return {Function}
+ * @see R.partialRight, R.curry
+ * @example
+ *
+ * const multiply2 = (a, b) => a * b;
+ * const double = R.partial(multiply2, [2]);
+ * double(2); //=> 4
+ *
+ * const greet = (salutation, title, firstName, lastName) =>
+ * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
+ *
+ * const sayHello = R.partial(greet, ['Hello']);
+ * const sayHelloToMs = R.partial(sayHello, ['Ms.']);
+ * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'
+ * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d)
+ */
+ var partial = _createPartialApplicator(_concat);
+
+ /**
+ * Takes a function `f` and a list of arguments, and returns a function `g`.
+ * When applied, `g` returns the result of applying `f` to the arguments
+ * provided to `g` followed by the arguments provided initially.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category Function
+ * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x)
+ * @param {Function} f
+ * @param {Array} args
+ * @return {Function}
+ * @see R.partial
+ * @example
+ *
+ * const greet = (salutation, title, firstName, lastName) =>
+ * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
+ *
+ * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);
+ *
+ * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
+ * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b)
+ */
+ var partialRight = _createPartialApplicator(flip(_concat));
+
+ /**
+ * Takes a predicate and a list or other `Filterable` object and returns the
+ * pair of filterable objects of the same type of elements which do and do not
+ * satisfy, the predicate, respectively. Filterable objects include plain objects or any object
+ * that has a filter method such as `Array`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.4
+ * @category List
+ * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a]
+ * @param {Function} pred A predicate to determine which side the element belongs to.
+ * @param {Array} filterable the list (or other filterable) to partition.
+ * @return {Array} An array, containing first the subset of elements that satisfy the
+ * predicate, and second the subset of elements that do not satisfy.
+ * @see R.filter, R.reject
+ * @example
+ *
+ * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
+ * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
+ *
+ * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
+ * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
+ */
+ var partition = juxt([filter, reject]);
+
+ /**
+ * Determines whether a nested path on an object has a specific value, in
+ * [`R.equals`](#equals) terms. Most likely used to filter a list.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category Relation
+ * @typedefn Idx = String | Int
+ * @sig [Idx] -> a -> {a} -> Boolean
+ * @param {Array} path The path of the nested property to use
+ * @param {*} val The value to compare the nested property with
+ * @param {Object} obj The object to check the nested property in
+ * @return {Boolean} `true` if the value equals the nested object property,
+ * `false` otherwise.
+ * @example
+ *
+ * const user1 = { address: { zipCode: 90210 } };
+ * const user2 = { address: { zipCode: 55555 } };
+ * const user3 = { name: 'Bob' };
+ * const users = [ user1, user2, user3 ];
+ * const isFamous = R.pathEq(['address', 'zipCode'], 90210);
+ * R.filter(isFamous, users); //=> [ user1 ]
+ */
+ var pathEq = _curry3(function pathEq(_path, val, obj) {
+ return equals(path(_path, obj), val);
+ });
-/**
- * Multiplies together all the elements of a list.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig [Number] -> Number
- * @param {Array} list An array of numbers
- * @return {Number} The product of all the numbers in the list.
- * @see R.reduce
- * @example
- *
- * R.product([2,4,6,8,100,1]); //=> 38400
- */
-var product = reduce(multiply, 1);
+ /**
+ * If the given, non-null object has a value at the given path, returns the
+ * value at that path. Otherwise returns the provided default value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category Object
+ * @typedefn Idx = String | Int
+ * @sig a -> [Idx] -> {a} -> a
+ * @param {*} d The default value.
+ * @param {Array} p The path to use.
+ * @param {Object} obj The object to retrieve the nested property from.
+ * @return {*} The data at `path` of the supplied object or the default value.
+ * @example
+ *
+ * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
+ * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
+ */
+ var pathOr = _curry3(function pathOr(d, p, obj) {
+ return defaultTo(d, path(p, obj));
+ });
-/**
- * Accepts a function `fn` and a list of transformer functions and returns a
- * new curried function. When the new function is invoked, it calls the
- * function `fn` with parameters consisting of the result of calling each
- * supplied handler on successive arguments to the new function.
- *
- * If more arguments are passed to the returned function than transformer
- * functions, those arguments are passed directly to `fn` as additional
- * parameters. If you expect additional arguments that don't need to be
- * transformed, although you can ignore them, it's best to pass an identity
- * function so that the new function reports the correct arity.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z)
- * @param {Function} fn The function to wrap.
- * @param {Array} transformers A list of transformer functions
- * @return {Function} The wrapped function.
- * @see R.converge
- * @example
- *
- * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81
- * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81
- * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
- * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32
- * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b))
- */
-var useWith = _curry2(function useWith(fn, transformers) {
- return curryN(transformers.length, function() {
- var args = [];
+ /**
+ * Returns `true` if the specified object property at given path satisfies the
+ * given predicate; `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Logic
+ * @typedefn Idx = String | Int
+ * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean
+ * @param {Function} pred
+ * @param {Array} propPath
+ * @param {*} obj
+ * @return {Boolean}
+ * @see R.propSatisfies, R.path
+ * @example
+ *
+ * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
+ */
+ var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) {
+ return propPath.length > 0 && pred(path(propPath, obj));
+ });
+
+ /**
+ * Returns a partial copy of an object containing only the keys specified. If
+ * the key does not exist, the property is ignored.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig [k] -> {k: v} -> {k: v}
+ * @param {Array} names an array of String property names to copy onto a new object
+ * @param {Object} obj The object to copy from
+ * @return {Object} A new object with only properties from `names` on it.
+ * @see R.omit, R.props
+ * @example
+ *
+ * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
+ * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
+ */
+ var pick = _curry2(function pick(names, obj) {
+ var result = {};
var idx = 0;
- while (idx < transformers.length) {
- args.push(transformers[idx].call(this, arguments[idx]));
+ while (idx < names.length) {
+ if (names[idx] in obj) {
+ result[names[idx]] = obj[names[idx]];
+ }
idx += 1;
}
- return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length)));
+ return result;
});
-});
-/**
- * Reasonable analog to SQL `select` statement.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @category Relation
- * @sig [k] -> [{k: v}] -> [{k: v}]
- * @param {Array} props The property names to project
- * @param {Array} objs The objects to query
- * @return {Array} An array of objects with just the `props` properties.
- * @example
- *
- * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
- * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
- * const kids = [abby, fred];
- * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
- */
-var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity
+ /**
+ * Similar to `pick` except that this one includes a `key: undefined` pair for
+ * properties that don't exist.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig [k] -> {k: v} -> {k: v}
+ * @param {Array} names an array of String property names to copy onto a new object
+ * @param {Object} obj The object to copy from
+ * @return {Object} A new object with only properties from `names` on it.
+ * @see R.pick
+ * @example
+ *
+ * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
+ * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}
+ */
+ var pickAll = _curry2(function pickAll(names, obj) {
+ var result = {};
+ var idx = 0;
+ var len = names.length;
+ while (idx < len) {
+ var name = names[idx];
+ result[name] = obj[name];
+ idx += 1;
+ }
+ return result;
+ });
-/**
- * Returns `true` if the specified object property is equal, in
- * [`R.equals`](#equals) terms, to the given value; `false` otherwise.
- * You can test multiple properties with [`R.whereEq`](#whereEq).
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig String -> a -> Object -> Boolean
- * @param {String} name
- * @param {*} val
- * @param {*} obj
- * @return {Boolean}
- * @see R.whereEq, R.propSatisfies, R.equals
- * @example
- *
- * const abby = {name: 'Abby', age: 7, hair: 'blond'};
- * const fred = {name: 'Fred', age: 12, hair: 'brown'};
- * const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
- * const alois = {name: 'Alois', age: 15, disposition: 'surly'};
- * const kids = [abby, fred, rusty, alois];
- * const hasBrownHair = R.propEq('hair', 'brown');
- * R.filter(hasBrownHair, kids); //=> [fred, rusty]
- */
-var propEq = _curry3(function propEq(name, val, obj) {
- return equals(val, obj[name]);
-});
+ /**
+ * Returns a partial copy of an object containing only the keys that satisfy
+ * the supplied predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Object
+ * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v}
+ * @param {Function} pred A predicate to determine whether or not a key
+ * should be included on the output object.
+ * @param {Object} obj The object to copy from
+ * @return {Object} A new object with only properties that satisfy `pred`
+ * on it.
+ * @see R.pick, R.filter
+ * @example
+ *
+ * const isUpperCase = (val, key) => key.toUpperCase() === key;
+ * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
+ */
+ var pickBy = _curry2(function pickBy(test, obj) {
+ var result = {};
+ for (var prop in obj) {
+ if (test(obj[prop], prop, obj)) {
+ result[prop] = obj[prop];
+ }
+ }
+ return result;
+ });
-/**
- * Returns `true` if the specified object property is of the given type;
- * `false` otherwise.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Type
- * @sig Type -> String -> Object -> Boolean
- * @param {Function} type
- * @param {String} name
- * @param {*} obj
- * @return {Boolean}
- * @see R.is, R.propSatisfies
- * @example
- *
- * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true
- * R.propIs(Number, 'x', {x: 'foo'}); //=> false
- * R.propIs(Number, 'x', {}); //=> false
- */
-var propIs = _curry3(function propIs(type, name, obj) {
- return is(type, obj[name]);
-});
+ /**
+ * Returns the left-to-right Kleisli composition of the provided functions,
+ * each of which must return a value of a type supported by [`chain`](#chain).
+ *
+ * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Function
+ * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z)
+ * @param {...Function}
+ * @return {Function}
+ * @see R.composeK
+ * @example
+ *
+ * // parseJson :: String -> Maybe *
+ * // get :: String -> Object -> Maybe *
+ *
+ * // getStateCode :: Maybe String -> Maybe String
+ * const getStateCode = R.pipeK(
+ * parseJson,
+ * get('user'),
+ * get('address'),
+ * get('state'),
+ * R.compose(Maybe.of, R.toUpper)
+ * );
+ *
+ * getStateCode('{"user":{"address":{"state":"ny"}}}');
+ * //=> Just('NY')
+ * getStateCode('[Invalid JSON]');
+ * //=> Nothing()
+ * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a)))
+ */
+ function pipeK() {
+ if (arguments.length === 0) {
+ throw new Error('pipeK requires at least one argument');
+ }
+ return composeK.apply(this, reverse(arguments));
+ }
+
+ /**
+ * Returns a new list with the given element at the front, followed by the
+ * contents of the list.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig a -> [a] -> [a]
+ * @param {*} el The item to add to the head of the output list.
+ * @param {Array} list The array to add to the tail of the output list.
+ * @return {Array} A new array.
+ * @see R.append
+ * @example
+ *
+ * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
+ */
+ var prepend = _curry2(function prepend(el, list) {
+ return _concat([el], list);
+ });
-/**
- * If the given, non-null object has an own property with the specified name,
- * returns the value of that property. Otherwise returns the provided default
- * value.
- *
- * @func
- * @memberOf R
- * @since v0.6.0
- * @category Object
- * @sig a -> String -> Object -> a
- * @param {*} val The default value.
- * @param {String} p The name of the property to return.
- * @param {Object} obj The object to query.
- * @return {*} The value of given property of the supplied object or the default value.
- * @example
- *
- * const alice = {
- * name: 'ALICE',
- * age: 101
- * };
- * const favorite = R.prop('favoriteLibrary');
- * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
- *
- * favorite(alice); //=> undefined
- * favoriteWithDefault(alice); //=> 'Ramda'
- */
-var propOr = _curry3(function propOr(val, p, obj) {
- return pathOr(val, [p], obj);
-});
+ /**
+ * Multiplies together all the elements of a list.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig [Number] -> Number
+ * @param {Array} list An array of numbers
+ * @return {Number} The product of all the numbers in the list.
+ * @see R.reduce
+ * @example
+ *
+ * R.product([2,4,6,8,100,1]); //=> 38400
+ */
+ var product = reduce(multiply, 1);
+
+ /**
+ * Accepts a function `fn` and a list of transformer functions and returns a
+ * new curried function. When the new function is invoked, it calls the
+ * function `fn` with parameters consisting of the result of calling each
+ * supplied handler on successive arguments to the new function.
+ *
+ * If more arguments are passed to the returned function than transformer
+ * functions, those arguments are passed directly to `fn` as additional
+ * parameters. If you expect additional arguments that don't need to be
+ * transformed, although you can ignore them, it's best to pass an identity
+ * function so that the new function reports the correct arity.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z)
+ * @param {Function} fn The function to wrap.
+ * @param {Array} transformers A list of transformer functions
+ * @return {Function} The wrapped function.
+ * @see R.converge
+ * @example
+ *
+ * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81
+ * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81
+ * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
+ * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32
+ * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b))
+ */
+ var useWith = _curry2(function useWith(fn, transformers) {
+ return curryN(transformers.length, function () {
+ var args = [];
+ var idx = 0;
+ while (idx < transformers.length) {
+ args.push(transformers[idx].call(this, arguments[idx]));
+ idx += 1;
+ }
+ return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length)));
+ });
+ });
-/**
- * Returns `true` if the specified object property satisfies the given
- * predicate; `false` otherwise. You can test multiple properties with
- * [`R.where`](#where).
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Logic
- * @sig (a -> Boolean) -> String -> {String: a} -> Boolean
- * @param {Function} pred
- * @param {String} name
- * @param {*} obj
- * @return {Boolean}
- * @see R.where, R.propEq, R.propIs
- * @example
- *
- * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true
- */
-var propSatisfies = _curry3(function propSatisfies(pred, name, obj) {
- return pred(obj[name]);
-});
+ /**
+ * Reasonable analog to SQL `select` statement.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @category Relation
+ * @sig [k] -> [{k: v}] -> [{k: v}]
+ * @param {Array} props The property names to project
+ * @param {Array} objs The objects to query
+ * @return {Array} An array of objects with just the `props` properties.
+ * @example
+ *
+ * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
+ * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
+ * const kids = [abby, fred];
+ * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
+ */
+ var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity
+
+ /**
+ * Returns `true` if the specified object property is equal, in
+ * [`R.equals`](#equals) terms, to the given value; `false` otherwise.
+ * You can test multiple properties with [`R.whereEq`](#whereEq).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig String -> a -> Object -> Boolean
+ * @param {String} name
+ * @param {*} val
+ * @param {*} obj
+ * @return {Boolean}
+ * @see R.whereEq, R.propSatisfies, R.equals
+ * @example
+ *
+ * const abby = {name: 'Abby', age: 7, hair: 'blond'};
+ * const fred = {name: 'Fred', age: 12, hair: 'brown'};
+ * const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
+ * const alois = {name: 'Alois', age: 15, disposition: 'surly'};
+ * const kids = [abby, fred, rusty, alois];
+ * const hasBrownHair = R.propEq('hair', 'brown');
+ * R.filter(hasBrownHair, kids); //=> [fred, rusty]
+ */
+ var propEq = _curry3(function propEq(name, val, obj) {
+ return equals(val, obj[name]);
+ });
-/**
- * Acts as multiple `prop`: array of keys in, array of values out. Preserves
- * order.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Object
- * @sig [k] -> {k: v} -> [v]
- * @param {Array} ps The property names to fetch
- * @param {Object} obj The object to query
- * @return {Array} The corresponding values or partially applied function.
- * @example
- *
- * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
- * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
- *
- * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
- * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
- */
-var props = _curry2(function props(ps, obj) {
- var len = ps.length;
- var out = [];
- var idx = 0;
-
- while (idx < len) {
- out[idx] = obj[ps[idx]];
- idx += 1;
- }
+ /**
+ * Returns `true` if the specified object property is of the given type;
+ * `false` otherwise.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Type
+ * @sig Type -> String -> Object -> Boolean
+ * @param {Function} type
+ * @param {String} name
+ * @param {*} obj
+ * @return {Boolean}
+ * @see R.is, R.propSatisfies
+ * @example
+ *
+ * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true
+ * R.propIs(Number, 'x', {x: 'foo'}); //=> false
+ * R.propIs(Number, 'x', {}); //=> false
+ */
+ var propIs = _curry3(function propIs(type, name, obj) {
+ return is(type, obj[name]);
+ });
- return out;
-});
+ /**
+ * If the given, non-null object has an own property with the specified name,
+ * returns the value of that property. Otherwise returns the provided default
+ * value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.6.0
+ * @category Object
+ * @sig a -> String -> Object -> a
+ * @param {*} val The default value.
+ * @param {String} p The name of the property to return.
+ * @param {Object} obj The object to query.
+ * @return {*} The value of given property of the supplied object or the default value.
+ * @example
+ *
+ * const alice = {
+ * name: 'ALICE',
+ * age: 101
+ * };
+ * const favorite = R.prop('favoriteLibrary');
+ * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
+ *
+ * favorite(alice); //=> undefined
+ * favoriteWithDefault(alice); //=> 'Ramda'
+ */
+ var propOr = _curry3(function propOr(val, p, obj) {
+ return pathOr(val, [p], obj);
+ });
-/**
- * Returns a list of numbers from `from` (inclusive) to `to` (exclusive).
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig Number -> Number -> [Number]
- * @param {Number} from The first number in the list.
- * @param {Number} to One more than the last number in the list.
- * @return {Array} The list of numbers in the set `[a, b)`.
- * @example
- *
- * R.range(1, 5); //=> [1, 2, 3, 4]
- * R.range(50, 53); //=> [50, 51, 52]
- */
-var range = _curry2(function range(from, to) {
- if (!(_isNumber(from) && _isNumber(to))) {
- throw new TypeError('Both arguments to range must be numbers');
- }
- var result = [];
- var n = from;
- while (n < to) {
- result.push(n);
- n += 1;
- }
- return result;
-});
+ /**
+ * Returns `true` if the specified object property satisfies the given
+ * predicate; `false` otherwise. You can test multiple properties with
+ * [`R.where`](#where).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Logic
+ * @sig (a -> Boolean) -> String -> {String: a} -> Boolean
+ * @param {Function} pred
+ * @param {String} name
+ * @param {*} obj
+ * @return {Boolean}
+ * @see R.where, R.propEq, R.propIs
+ * @example
+ *
+ * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true
+ */
+ var propSatisfies = _curry3(function propSatisfies(pred, name, obj) {
+ return pred(obj[name]);
+ });
-/**
- * Returns a single item by iterating through the list, successively calling
- * the iterator function and passing it an accumulator value and the current
- * value from the array, and then passing the result to the next call.
- *
- * Similar to [`reduce`](#reduce), except moves through the input list from the
- * right to the left.
- *
- * The iterator function receives two values: *(value, acc)*, while the arguments'
- * order of `reduce`'s iterator function is *(acc, value)*.
- *
- * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse
- * arrays), unlike the native `Array.prototype.reduceRight` method. For more details
- * on this behavior, see:
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig ((a, b) -> b) -> b -> [a] -> b
- * @param {Function} fn The iterator function. Receives two values, the current element from the array
- * and the accumulator.
- * @param {*} acc The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.reduce, R.addIndex
- * @example
- *
- * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2
- * // - -2
- * // / \ / \
- * // 1 - 1 3
- * // / \ / \
- * // 2 - ==> 2 -1
- * // / \ / \
- * // 3 - 3 4
- * // / \ / \
- * // 4 0 4 0
- *
- * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a)))
- */
-var reduceRight = _curry3(function reduceRight(fn, acc, list) {
- var idx = list.length - 1;
- while (idx >= 0) {
- acc = fn(list[idx], acc);
- idx -= 1;
- }
- return acc;
-});
+ /**
+ * Acts as multiple `prop`: array of keys in, array of values out. Preserves
+ * order.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Object
+ * @sig [k] -> {k: v} -> [v]
+ * @param {Array} ps The property names to fetch
+ * @param {Object} obj The object to query
+ * @return {Array} The corresponding values or partially applied function.
+ * @example
+ *
+ * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
+ * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
+ *
+ * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
+ * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
+ */
+ var props = _curry2(function props(ps, obj) {
+ var len = ps.length;
+ var out = [];
+ var idx = 0;
-/**
- * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating
- * through the list, successively calling the iterator function. `reduceWhile`
- * also takes a predicate that is evaluated before each step. If the predicate
- * returns `false`, it "short-circuits" the iteration and returns the current
- * value of the accumulator.
- *
- * @func
- * @memberOf R
- * @since v0.22.0
- * @category List
- * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a
- * @param {Function} pred The predicate. It is passed the accumulator and the
- * current element.
- * @param {Function} fn The iterator function. Receives two values, the
- * accumulator and the current element.
- * @param {*} a The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.reduce, R.reduced
- * @example
- *
- * const isOdd = (acc, x) => x % 2 === 1;
- * const xs = [1, 3, 5, 60, 777, 800];
- * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9
- *
- * const ys = [2, 4, 6]
- * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111
- */
-var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) {
- return _reduce(function(acc, x) {
- return pred(acc, x) ? fn(acc, x) : _reduced(acc);
- }, a, list);
-});
+ while (idx < len) {
+ out[idx] = obj[ps[idx]];
+ idx += 1;
+ }
-/**
- * Returns a value wrapped to indicate that it is the final value of the reduce
- * and transduce functions. The returned value should be considered a black
- * box: the internal structure is not guaranteed to be stable.
- *
- * Note: this optimization is only available to the below functions:
- * - [`reduce`](#reduce)
- * - [`reduceWhile`](#reduceWhile)
- * - [`transduce`](#transduce)
- *
- * @func
- * @memberOf R
- * @since v0.15.0
- * @category List
- * @sig a -> *
- * @param {*} x The final value of the reduce.
- * @return {*} The wrapped value.
- * @see R.reduce, R.reduceWhile, R.transduce
- * @example
- *
- * R.reduce(
- * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item),
- * [],
- * [1, 2, 3, 4, 5]) // [1, 2, 3]
- */
-var reduced = _curry1(_reduced);
+ return out;
+ });
-/**
- * Calls an input function `n` times, returning an array containing the results
- * of those function calls.
- *
- * `fn` is passed one argument: The current value of `n`, which begins at `0`
- * and is gradually incremented to `n - 1`.
- *
- * @func
- * @memberOf R
- * @since v0.2.3
- * @category List
- * @sig (Number -> a) -> Number -> [a]
- * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`.
- * @param {Number} n A value between `0` and `n - 1`. Increments after each function call.
- * @return {Array} An array containing the return values of all calls to `fn`.
- * @see R.repeat
- * @example
- *
- * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
- * @symb R.times(f, 0) = []
- * @symb R.times(f, 1) = [f(0)]
- * @symb R.times(f, 2) = [f(0), f(1)]
- */
-var times = _curry2(function times(fn, n) {
- var len = Number(n);
- var idx = 0;
- var list;
+ /**
+ * Returns a list of numbers from `from` (inclusive) to `to` (exclusive).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig Number -> Number -> [Number]
+ * @param {Number} from The first number in the list.
+ * @param {Number} to One more than the last number in the list.
+ * @return {Array} The list of numbers in the set `[a, b)`.
+ * @example
+ *
+ * R.range(1, 5); //=> [1, 2, 3, 4]
+ * R.range(50, 53); //=> [50, 51, 52]
+ */
+ var range = _curry2(function range(from, to) {
+ if (!(_isNumber(from) && _isNumber(to))) {
+ throw new TypeError('Both arguments to range must be numbers');
+ }
+ var result = [];
+ var n = from;
+ while (n < to) {
+ result.push(n);
+ n += 1;
+ }
+ return result;
+ });
- if (len < 0 || isNaN(len)) {
- throw new RangeError('n must be a non-negative number');
- }
- list = new Array(len);
- while (idx < len) {
- list[idx] = fn(idx);
- idx += 1;
- }
- return list;
-});
+ /**
+ * Returns a single item by iterating through the list, successively calling
+ * the iterator function and passing it an accumulator value and the current
+ * value from the array, and then passing the result to the next call.
+ *
+ * Similar to [`reduce`](#reduce), except moves through the input list from the
+ * right to the left.
+ *
+ * The iterator function receives two values: *(value, acc)*, while the arguments'
+ * order of `reduce`'s iterator function is *(acc, value)*.
+ *
+ * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse
+ * arrays), unlike the native `Array.prototype.reduceRight` method. For more details
+ * on this behavior, see:
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig ((a, b) -> b) -> b -> [a] -> b
+ * @param {Function} fn The iterator function. Receives two values, the current element from the array
+ * and the accumulator.
+ * @param {*} acc The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.reduce, R.addIndex
+ * @example
+ *
+ * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2
+ * // - -2
+ * // / \ / \
+ * // 1 - 1 3
+ * // / \ / \
+ * // 2 - ==> 2 -1
+ * // / \ / \
+ * // 3 - 3 4
+ * // / \ / \
+ * // 4 0 4 0
+ *
+ * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a)))
+ */
+ var reduceRight = _curry3(function reduceRight(fn, acc, list) {
+ var idx = list.length - 1;
+ while (idx >= 0) {
+ acc = fn(list[idx], acc);
+ idx -= 1;
+ }
+ return acc;
+ });
-/**
- * Returns a fixed list of size `n` containing a specified identical value.
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category List
- * @sig a -> n -> [a]
- * @param {*} value The value to repeat.
- * @param {Number} n The desired size of the output list.
- * @return {Array} A new array containing `n` `value`s.
- * @see R.times
- * @example
- *
- * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
- *
- * const obj = {};
- * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
- * repeatedObjs[0] === repeatedObjs[1]; //=> true
- * @symb R.repeat(a, 0) = []
- * @symb R.repeat(a, 1) = [a]
- * @symb R.repeat(a, 2) = [a, a]
- */
-var repeat = _curry2(function repeat(value, n) {
- return times(always(value), n);
-});
+ /**
+ * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating
+ * through the list, successively calling the iterator function. `reduceWhile`
+ * also takes a predicate that is evaluated before each step. If the predicate
+ * returns `false`, it "short-circuits" the iteration and returns the current
+ * value of the accumulator.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.22.0
+ * @category List
+ * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a
+ * @param {Function} pred The predicate. It is passed the accumulator and the
+ * current element.
+ * @param {Function} fn The iterator function. Receives two values, the
+ * accumulator and the current element.
+ * @param {*} a The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.reduce, R.reduced
+ * @example
+ *
+ * const isOdd = (acc, x) => x % 2 === 1;
+ * const xs = [1, 3, 5, 60, 777, 800];
+ * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9
+ *
+ * const ys = [2, 4, 6]
+ * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111
+ */
+ var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) {
+ return _reduce(
+ function (acc, x) {
+ return pred(acc, x) ? fn(acc, x) : _reduced(acc);
+ },
+ a,
+ list
+ );
+ });
-/**
- * Replace a substring or regex match in a string with a replacement.
- *
- * The first two parameters correspond to the parameters of the
- * `String.prototype.replace()` function, so the second parameter can also be a
- * function.
- *
- * @func
- * @memberOf R
- * @since v0.7.0
- * @category String
- * @sig RegExp|String -> String -> String -> String
- * @param {RegExp|String} pattern A regular expression or a substring to match.
- * @param {String} replacement The string to replace the matches with.
- * @param {String} str The String to do the search and replacement in.
- * @return {String} The result.
- * @example
- *
- * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
- * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
- *
- * // Use the "g" (global) flag to replace all occurrences:
- * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
- */
-var replace = _curry3(function replace(regex, replacement, str) {
- return str.replace(regex, replacement);
-});
+ /**
+ * Returns a value wrapped to indicate that it is the final value of the reduce
+ * and transduce functions. The returned value should be considered a black
+ * box: the internal structure is not guaranteed to be stable.
+ *
+ * Note: this optimization is only available to the below functions:
+ * - [`reduce`](#reduce)
+ * - [`reduceWhile`](#reduceWhile)
+ * - [`transduce`](#transduce)
+ *
+ * @func
+ * @memberOf R
+ * @since v0.15.0
+ * @category List
+ * @sig a -> *
+ * @param {*} x The final value of the reduce.
+ * @return {*} The wrapped value.
+ * @see R.reduce, R.reduceWhile, R.transduce
+ * @example
+ *
+ * R.reduce(
+ * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item),
+ * [],
+ * [1, 2, 3, 4, 5]) // [1, 2, 3]
+ */
+ var reduced = _curry1(_reduced);
+
+ /**
+ * Calls an input function `n` times, returning an array containing the results
+ * of those function calls.
+ *
+ * `fn` is passed one argument: The current value of `n`, which begins at `0`
+ * and is gradually incremented to `n - 1`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.3
+ * @category List
+ * @sig (Number -> a) -> Number -> [a]
+ * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`.
+ * @param {Number} n A value between `0` and `n - 1`. Increments after each function call.
+ * @return {Array} An array containing the return values of all calls to `fn`.
+ * @see R.repeat
+ * @example
+ *
+ * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
+ * @symb R.times(f, 0) = []
+ * @symb R.times(f, 1) = [f(0)]
+ * @symb R.times(f, 2) = [f(0), f(1)]
+ */
+ var times = _curry2(function times(fn, n) {
+ var len = Number(n);
+ var idx = 0;
+ var list;
-/**
- * Scan is similar to [`reduce`](#reduce), but returns a list of successively
- * reduced values from the left
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category List
- * @sig ((a, b) -> a) -> a -> [b] -> [a]
- * @param {Function} fn The iterator function. Receives two values, the accumulator and the
- * current element from the array
- * @param {*} acc The accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {Array} A list of all intermediately reduced values.
- * @see R.reduce, R.mapAccum
- * @example
- *
- * const numbers = [1, 2, 3, 4];
- * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24]
- * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)]
- */
-var scan = _curry3(function scan(fn, acc, list) {
- var idx = 0;
- var len = list.length;
- var result = [acc];
- while (idx < len) {
- acc = fn(acc, list[idx]);
- result[idx + 1] = acc;
- idx += 1;
- }
- return result;
-});
+ if (len < 0 || isNaN(len)) {
+ throw new RangeError('n must be a non-negative number');
+ }
+ list = new Array(len);
+ while (idx < len) {
+ list[idx] = fn(idx);
+ idx += 1;
+ }
+ return list;
+ });
-/**
- * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable)
- * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an
- * Applicative of Traversable.
- *
- * Dispatches to the `sequence` method of the second argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a)
- * @param {Function} of
- * @param {*} traversable
- * @return {*}
- * @see R.traverse
- * @example
- *
- * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3])
- * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing()
- *
- * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)]
- * R.sequence(R.of, Nothing()); //=> [Nothing()]
- */
-var sequence = _curry2(function sequence(of, traversable) {
- return typeof traversable.sequence === 'function' ?
- traversable.sequence(of) :
- reduceRight(function(x, acc) { return ap(map(prepend, x), acc); },
- of([]),
- traversable);
-});
+ /**
+ * Returns a fixed list of size `n` containing a specified identical value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category List
+ * @sig a -> n -> [a]
+ * @param {*} value The value to repeat.
+ * @param {Number} n The desired size of the output list.
+ * @return {Array} A new array containing `n` `value`s.
+ * @see R.times
+ * @example
+ *
+ * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
+ *
+ * const obj = {};
+ * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
+ * repeatedObjs[0] === repeatedObjs[1]; //=> true
+ * @symb R.repeat(a, 0) = []
+ * @symb R.repeat(a, 1) = [a]
+ * @symb R.repeat(a, 2) = [a, a]
+ */
+ var repeat = _curry2(function repeat(value, n) {
+ return times(always(value), n);
+ });
-/**
- * Returns the result of "setting" the portion of the given data structure
- * focused by the given lens to the given value.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig Lens s a -> a -> s -> s
- * @param {Lens} lens
- * @param {*} v
- * @param {*} x
- * @return {*}
- * @see R.prop, R.lensIndex, R.lensProp
- * @example
- *
- * const xLens = R.lensProp('x');
- *
- * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
- * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2}
- */
-var set = _curry3(function set(lens, v, x) {
- return over(lens, always(v), x);
-});
+ /**
+ * Replace a substring or regex match in a string with a replacement.
+ *
+ * The first two parameters correspond to the parameters of the
+ * `String.prototype.replace()` function, so the second parameter can also be a
+ * function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.7.0
+ * @category String
+ * @sig RegExp|String -> String -> String -> String
+ * @param {RegExp|String} pattern A regular expression or a substring to match.
+ * @param {String} replacement The string to replace the matches with.
+ * @param {String} str The String to do the search and replacement in.
+ * @return {String} The result.
+ * @example
+ *
+ * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
+ * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
+ *
+ * // Use the "g" (global) flag to replace all occurrences:
+ * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
+ */
+ var replace = _curry3(function replace(regex, replacement, str) {
+ return str.replace(regex, replacement);
+ });
+
+ /**
+ * Scan is similar to [`reduce`](#reduce), but returns a list of successively
+ * reduced values from the left
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category List
+ * @sig ((a, b) -> a) -> a -> [b] -> [a]
+ * @param {Function} fn The iterator function. Receives two values, the accumulator and the
+ * current element from the array
+ * @param {*} acc The accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {Array} A list of all intermediately reduced values.
+ * @see R.reduce, R.mapAccum
+ * @example
+ *
+ * const numbers = [1, 2, 3, 4];
+ * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24]
+ * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)]
+ */
+ var scan = _curry3(function scan(fn, acc, list) {
+ var idx = 0;
+ var len = list.length;
+ var result = [acc];
+ while (idx < len) {
+ acc = fn(acc, list[idx]);
+ result[idx + 1] = acc;
+ idx += 1;
+ }
+ return result;
+ });
+
+ /**
+ * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable)
+ * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an
+ * Applicative of Traversable.
+ *
+ * Dispatches to the `sequence` method of the second argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a)
+ * @param {Function} of
+ * @param {*} traversable
+ * @return {*}
+ * @see R.traverse
+ * @example
+ *
+ * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3])
+ * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing()
+ *
+ * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)]
+ * R.sequence(R.of, Nothing()); //=> [Nothing()]
+ */
+ var sequence = _curry2(function sequence(of, traversable) {
+ return typeof traversable.sequence === 'function'
+ ? traversable.sequence(of)
+ : reduceRight(
+ function (x, acc) {
+ return ap(map(prepend, x), acc);
+ },
+ of([]),
+ traversable
+ );
+ });
+
+ /**
+ * Returns the result of "setting" the portion of the given data structure
+ * focused by the given lens to the given value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig Lens s a -> a -> s -> s
+ * @param {Lens} lens
+ * @param {*} v
+ * @param {*} x
+ * @return {*}
+ * @see R.prop, R.lensIndex, R.lensProp
+ * @example
+ *
+ * const xLens = R.lensProp('x');
+ *
+ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
+ * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2}
+ */
+ var set = _curry3(function set(lens, v, x) {
+ return over(lens, always(v), x);
+ });
+
+ /**
+ * Returns a copy of the list, sorted according to the comparator function,
+ * which should accept two values at a time and return a negative number if the
+ * first value is smaller, a positive number if it's larger, and zero if they
+ * are equal. Please note that this is a **copy** of the list. It does not
+ * modify the original.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig ((a, a) -> Number) -> [a] -> [a]
+ * @param {Function} comparator A sorting function :: a -> b -> Int
+ * @param {Array} list The list to sort
+ * @return {Array} a new array with its elements sorted by the comparator function.
+ * @example
+ *
+ * const diff = function(a, b) { return a - b; };
+ * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]
+ */
+ var sort = _curry2(function sort(comparator, list) {
+ return Array.prototype.slice.call(list, 0).sort(comparator);
+ });
-/**
- * Returns a copy of the list, sorted according to the comparator function,
- * which should accept two values at a time and return a negative number if the
- * first value is smaller, a positive number if it's larger, and zero if they
- * are equal. Please note that this is a **copy** of the list. It does not
- * modify the original.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig ((a, a) -> Number) -> [a] -> [a]
- * @param {Function} comparator A sorting function :: a -> b -> Int
- * @param {Array} list The list to sort
- * @return {Array} a new array with its elements sorted by the comparator function.
- * @example
- *
- * const diff = function(a, b) { return a - b; };
- * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]
- */
-var sort = _curry2(function sort(comparator, list) {
- return Array.prototype.slice.call(list, 0).sort(comparator);
-});
+ /**
+ * Sorts the list according to the supplied function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig Ord b => (a -> b) -> [a] -> [a]
+ * @param {Function} fn
+ * @param {Array} list The list to sort.
+ * @return {Array} A new list sorted by the keys generated by `fn`.
+ * @example
+ *
+ * const sortByFirstItem = R.sortBy(R.prop(0));
+ * const pairs = [[-1, 1], [-2, 2], [-3, 3]];
+ * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
+ *
+ * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
+ * const alice = {
+ * name: 'ALICE',
+ * age: 101
+ * };
+ * const bob = {
+ * name: 'Bob',
+ * age: -10
+ * };
+ * const clara = {
+ * name: 'clara',
+ * age: 314.159
+ * };
+ * const people = [clara, bob, alice];
+ * sortByNameCaseInsensitive(people); //=> [alice, bob, clara]
+ */
+ var sortBy = _curry2(function sortBy(fn, list) {
+ return Array.prototype.slice.call(list, 0).sort(function (a, b) {
+ var aa = fn(a);
+ var bb = fn(b);
+ return aa < bb ? -1 : aa > bb ? 1 : 0;
+ });
+ });
-/**
- * Sorts the list according to the supplied function.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig Ord b => (a -> b) -> [a] -> [a]
- * @param {Function} fn
- * @param {Array} list The list to sort.
- * @return {Array} A new list sorted by the keys generated by `fn`.
- * @example
- *
- * const sortByFirstItem = R.sortBy(R.prop(0));
- * const pairs = [[-1, 1], [-2, 2], [-3, 3]];
- * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
- *
- * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
- * const alice = {
- * name: 'ALICE',
- * age: 101
- * };
- * const bob = {
- * name: 'Bob',
- * age: -10
- * };
- * const clara = {
- * name: 'clara',
- * age: 314.159
- * };
- * const people = [clara, bob, alice];
- * sortByNameCaseInsensitive(people); //=> [alice, bob, clara]
- */
-var sortBy = _curry2(function sortBy(fn, list) {
- return Array.prototype.slice.call(list, 0).sort(function(a, b) {
- var aa = fn(a);
- var bb = fn(b);
- return aa < bb ? -1 : aa > bb ? 1 : 0;
+ /**
+ * Sorts a list according to a list of comparators.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.23.0
+ * @category Relation
+ * @sig [(a, a) -> Number] -> [a] -> [a]
+ * @param {Array} functions A list of comparator functions.
+ * @param {Array} list The list to sort.
+ * @return {Array} A new list sorted according to the comarator functions.
+ * @example
+ *
+ * const alice = {
+ * name: 'alice',
+ * age: 40
+ * };
+ * const bob = {
+ * name: 'bob',
+ * age: 30
+ * };
+ * const clara = {
+ * name: 'clara',
+ * age: 40
+ * };
+ * const people = [clara, bob, alice];
+ * const ageNameSort = R.sortWith([
+ * R.descend(R.prop('age')),
+ * R.ascend(R.prop('name'))
+ * ]);
+ * ageNameSort(people); //=> [alice, clara, bob]
+ */
+ var sortWith = _curry2(function sortWith(fns, list) {
+ return Array.prototype.slice.call(list, 0).sort(function (a, b) {
+ var result = 0;
+ var i = 0;
+ while (result === 0 && i < fns.length) {
+ result = fns[i](a, b);
+ i += 1;
+ }
+ return result;
+ });
});
-});
-/**
- * Sorts a list according to a list of comparators.
- *
- * @func
- * @memberOf R
- * @since v0.23.0
- * @category Relation
- * @sig [(a, a) -> Number] -> [a] -> [a]
- * @param {Array} functions A list of comparator functions.
- * @param {Array} list The list to sort.
- * @return {Array} A new list sorted according to the comarator functions.
- * @example
- *
- * const alice = {
- * name: 'alice',
- * age: 40
- * };
- * const bob = {
- * name: 'bob',
- * age: 30
- * };
- * const clara = {
- * name: 'clara',
- * age: 40
- * };
- * const people = [clara, bob, alice];
- * const ageNameSort = R.sortWith([
- * R.descend(R.prop('age')),
- * R.ascend(R.prop('name'))
- * ]);
- * ageNameSort(people); //=> [alice, clara, bob]
- */
-var sortWith = _curry2(function sortWith(fns, list) {
- return Array.prototype.slice.call(list, 0).sort(function(a, b) {
- var result = 0;
- var i = 0;
- while (result === 0 && i < fns.length) {
- result = fns[i](a, b);
- i += 1;
+ /**
+ * Splits a string into an array of strings based on the given
+ * separator.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category String
+ * @sig (String | RegExp) -> String -> [String]
+ * @param {String|RegExp} sep The pattern.
+ * @param {String} str The string to separate into an array.
+ * @return {Array} The array of strings from `str` separated by `str`.
+ * @see R.join
+ * @example
+ *
+ * const pathComponents = R.split('/');
+ * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']
+ *
+ * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']
+ */
+ var split = invoker(1, 'split');
+
+ /**
+ * Splits a given list or string at a given index.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig Number -> [a] -> [[a], [a]]
+ * @sig Number -> String -> [String, String]
+ * @param {Number} index The index where the array/string is split.
+ * @param {Array|String} array The array/string to be split.
+ * @return {Array}
+ * @example
+ *
+ * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
+ * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
+ * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
+ */
+ var splitAt = _curry2(function splitAt(index, array) {
+ return [slice(0, index, array), slice(index, length(array), array)];
+ });
+
+ /**
+ * Splits a collection into slices of the specified length.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig Number -> [a] -> [[a]]
+ * @sig Number -> String -> [String]
+ * @param {Number} n
+ * @param {Array} list
+ * @return {Array}
+ * @example
+ *
+ * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]]
+ * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz']
+ */
+ var splitEvery = _curry2(function splitEvery(n, list) {
+ if (n <= 0) {
+ throw new Error('First argument to splitEvery must be a positive integer');
+ }
+ var result = [];
+ var idx = 0;
+ while (idx < list.length) {
+ result.push(slice(idx, (idx += n), list));
}
return result;
});
-});
-
-/**
- * Splits a string into an array of strings based on the given
- * separator.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category String
- * @sig (String | RegExp) -> String -> [String]
- * @param {String|RegExp} sep The pattern.
- * @param {String} str The string to separate into an array.
- * @return {Array} The array of strings from `str` separated by `str`.
- * @see R.join
- * @example
- *
- * const pathComponents = R.split('/');
- * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']
- *
- * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']
- */
-var split = invoker(1, 'split');
-/**
- * Splits a given list or string at a given index.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig Number -> [a] -> [[a], [a]]
- * @sig Number -> String -> [String, String]
- * @param {Number} index The index where the array/string is split.
- * @param {Array|String} array The array/string to be split.
- * @return {Array}
- * @example
- *
- * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
- * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
- * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
- */
-var splitAt = _curry2(function splitAt(index, array) {
- return [slice(0, index, array), slice(index, length(array), array)];
-});
+ /**
+ * Takes a list and a predicate and returns a pair of lists with the following properties:
+ *
+ * - the result of concatenating the two output lists is equivalent to the input list;
+ * - none of the elements of the first output list satisfies the predicate; and
+ * - if the second output list is non-empty, its first element satisfies the predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> [[a], [a]]
+ * @param {Function} pred The predicate that determines where the array is split.
+ * @param {Array} list The array to be split.
+ * @return {Array}
+ * @example
+ *
+ * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]]
+ */
+ var splitWhen = _curry2(function splitWhen(pred, list) {
+ var idx = 0;
+ var len = list.length;
+ var prefix = [];
-/**
- * Splits a collection into slices of the specified length.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig Number -> [a] -> [[a]]
- * @sig Number -> String -> [String]
- * @param {Number} n
- * @param {Array} list
- * @return {Array}
- * @example
- *
- * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]]
- * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz']
- */
-var splitEvery = _curry2(function splitEvery(n, list) {
- if (n <= 0) {
- throw new Error('First argument to splitEvery must be a positive integer');
- }
- var result = [];
- var idx = 0;
- while (idx < list.length) {
- result.push(slice(idx, idx += n, list));
- }
- return result;
-});
+ while (idx < len && !pred(list[idx])) {
+ prefix.push(list[idx]);
+ idx += 1;
+ }
-/**
- * Takes a list and a predicate and returns a pair of lists with the following properties:
- *
- * - the result of concatenating the two output lists is equivalent to the input list;
- * - none of the elements of the first output list satisfies the predicate; and
- * - if the second output list is non-empty, its first element satisfies the predicate.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> [[a], [a]]
- * @param {Function} pred The predicate that determines where the array is split.
- * @param {Array} list The array to be split.
- * @return {Array}
- * @example
- *
- * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]]
- */
-var splitWhen = _curry2(function splitWhen(pred, list) {
- var idx = 0;
- var len = list.length;
- var prefix = [];
-
- while (idx < len && !pred(list[idx])) {
- prefix.push(list[idx]);
- idx += 1;
- }
+ return [prefix, Array.prototype.slice.call(list, idx)];
+ });
- return [prefix, Array.prototype.slice.call(list, idx)];
-});
+ /**
+ * Checks if a list starts with the provided sublist.
+ *
+ * Similarly, checks if a string starts with the provided substring.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.24.0
+ * @category List
+ * @sig [a] -> [a] -> Boolean
+ * @sig String -> String -> Boolean
+ * @param {*} prefix
+ * @param {*} list
+ * @return {Boolean}
+ * @see R.endsWith
+ * @example
+ *
+ * R.startsWith('a', 'abc') //=> true
+ * R.startsWith('b', 'abc') //=> false
+ * R.startsWith(['a'], ['a', 'b', 'c']) //=> true
+ * R.startsWith(['b'], ['a', 'b', 'c']) //=> false
+ */
+ var startsWith = _curry2(function (prefix, list) {
+ return equals(take(prefix.length, list), prefix);
+ });
-/**
- * Checks if a list starts with the provided sublist.
- *
- * Similarly, checks if a string starts with the provided substring.
- *
- * @func
- * @memberOf R
- * @since v0.24.0
- * @category List
- * @sig [a] -> [a] -> Boolean
- * @sig String -> String -> Boolean
- * @param {*} prefix
- * @param {*} list
- * @return {Boolean}
- * @see R.endsWith
- * @example
- *
- * R.startsWith('a', 'abc') //=> true
- * R.startsWith('b', 'abc') //=> false
- * R.startsWith(['a'], ['a', 'b', 'c']) //=> true
- * R.startsWith(['b'], ['a', 'b', 'c']) //=> false
- */
-var startsWith = _curry2(function(prefix, list) {
- return equals(take(prefix.length, list), prefix);
-});
+ /**
+ * Subtracts its second argument from its first argument.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Math
+ * @sig Number -> Number -> Number
+ * @param {Number} a The first value.
+ * @param {Number} b The second value.
+ * @return {Number} The result of `a - b`.
+ * @see R.add
+ * @example
+ *
+ * R.subtract(10, 8); //=> 2
+ *
+ * const minus5 = R.subtract(R.__, 5);
+ * minus5(17); //=> 12
+ *
+ * const complementaryAngle = R.subtract(90);
+ * complementaryAngle(30); //=> 60
+ * complementaryAngle(72); //=> 18
+ */
+ var subtract = _curry2(function subtract(a, b) {
+ return Number(a) - Number(b);
+ });
-/**
- * Subtracts its second argument from its first argument.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Math
- * @sig Number -> Number -> Number
- * @param {Number} a The first value.
- * @param {Number} b The second value.
- * @return {Number} The result of `a - b`.
- * @see R.add
- * @example
- *
- * R.subtract(10, 8); //=> 2
- *
- * const minus5 = R.subtract(R.__, 5);
- * minus5(17); //=> 12
- *
- * const complementaryAngle = R.subtract(90);
- * complementaryAngle(30); //=> 60
- * complementaryAngle(72); //=> 18
- */
-var subtract = _curry2(function subtract(a, b) {
- return Number(a) - Number(b);
-});
+ /**
+ * Finds the set (i.e. no duplicates) of all elements contained in the first or
+ * second list, but not both.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Relation
+ * @sig [*] -> [*] -> [*]
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The elements in `list1` or `list2`, but not both.
+ * @see R.symmetricDifferenceWith, R.difference, R.differenceWith
+ * @example
+ *
+ * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
+ * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]
+ */
+ var symmetricDifference = _curry2(function symmetricDifference(list1, list2) {
+ return concat(difference(list1, list2), difference(list2, list1));
+ });
-/**
- * Finds the set (i.e. no duplicates) of all elements contained in the first or
- * second list, but not both.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Relation
- * @sig [*] -> [*] -> [*]
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The elements in `list1` or `list2`, but not both.
- * @see R.symmetricDifferenceWith, R.difference, R.differenceWith
- * @example
- *
- * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
- * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]
- */
-var symmetricDifference = _curry2(function symmetricDifference(list1, list2) {
- return concat(difference(list1, list2), difference(list2, list1));
-});
+ /**
+ * Finds the set (i.e. no duplicates) of all elements contained in the first or
+ * second list, but not both. Duplication is determined according to the value
+ * returned by applying the supplied predicate to two list elements.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category Relation
+ * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
+ * @param {Function} pred A predicate used to test whether two items are equal.
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The elements in `list1` or `list2`, but not both.
+ * @see R.symmetricDifference, R.difference, R.differenceWith
+ * @example
+ *
+ * const eqA = R.eqBy(R.prop('a'));
+ * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
+ * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
+ * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]
+ */
+ var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) {
+ return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1));
+ });
-/**
- * Finds the set (i.e. no duplicates) of all elements contained in the first or
- * second list, but not both. Duplication is determined according to the value
- * returned by applying the supplied predicate to two list elements.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category Relation
- * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
- * @param {Function} pred A predicate used to test whether two items are equal.
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The elements in `list1` or `list2`, but not both.
- * @see R.symmetricDifference, R.difference, R.differenceWith
- * @example
- *
- * const eqA = R.eqBy(R.prop('a'));
- * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
- * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
- * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]
- */
-var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) {
- return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1));
-});
+ /**
+ * Returns a new list containing the last `n` elements of a given list, passing
+ * each value to the supplied predicate function, and terminating when the
+ * predicate function returns `false`. Excludes the element that caused the
+ * predicate function to fail. The predicate function is passed one argument:
+ * *(value)*.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> [a]
+ * @sig (a -> Boolean) -> String -> String
+ * @param {Function} fn The function called per iteration.
+ * @param {Array} xs The collection to iterate over.
+ * @return {Array} A new array.
+ * @see R.dropLastWhile, R.addIndex
+ * @example
+ *
+ * const isNotOne = x => x !== 1;
+ *
+ * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4]
+ *
+ * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda'
+ */
+ var takeLastWhile = _curry2(function takeLastWhile(fn, xs) {
+ var idx = xs.length - 1;
+ while (idx >= 0 && fn(xs[idx])) {
+ idx -= 1;
+ }
+ return slice(idx + 1, Infinity, xs);
+ });
-/**
- * Returns a new list containing the last `n` elements of a given list, passing
- * each value to the supplied predicate function, and terminating when the
- * predicate function returns `false`. Excludes the element that caused the
- * predicate function to fail. The predicate function is passed one argument:
- * *(value)*.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> [a]
- * @sig (a -> Boolean) -> String -> String
- * @param {Function} fn The function called per iteration.
- * @param {Array} xs The collection to iterate over.
- * @return {Array} A new array.
- * @see R.dropLastWhile, R.addIndex
- * @example
- *
- * const isNotOne = x => x !== 1;
- *
- * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4]
- *
- * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda'
- */
-var takeLastWhile = _curry2(function takeLastWhile(fn, xs) {
- var idx = xs.length - 1;
- while (idx >= 0 && fn(xs[idx])) {
- idx -= 1;
+ function XTakeWhile(f, xf) {
+ this.xf = xf;
+ this.f = f;
}
- return slice(idx + 1, Infinity, xs);
-});
+ XTakeWhile.prototype['@@transducer/init'] = _xfBase.init;
+ XTakeWhile.prototype['@@transducer/result'] = _xfBase.result;
+ XTakeWhile.prototype['@@transducer/step'] = function (result, input) {
+ return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result);
+ };
-function XTakeWhile(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XTakeWhile.prototype['@@transducer/init'] = _xfBase.init;
-XTakeWhile.prototype['@@transducer/result'] = _xfBase.result;
-XTakeWhile.prototype['@@transducer/step'] = function(result, input) {
- return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result);
-};
-
-var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); });
-
-/**
- * Returns a new list containing the first `n` elements of a given list,
- * passing each value to the supplied predicate function, and terminating when
- * the predicate function returns `false`. Excludes the element that caused the
- * predicate function to fail. The predicate function is passed one argument:
- * *(value)*.
- *
- * Dispatches to the `takeWhile` method of the second argument, if present.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig (a -> Boolean) -> [a] -> [a]
- * @sig (a -> Boolean) -> String -> String
- * @param {Function} fn The function called per iteration.
- * @param {Array} xs The collection to iterate over.
- * @return {Array} A new array.
- * @see R.dropWhile, R.transduce, R.addIndex
- * @example
- *
- * const isNotFour = x => x !== 4;
- *
- * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]
- *
- * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram'
- */
-var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) {
- var idx = 0;
- var len = xs.length;
- while (idx < len && fn(xs[idx])) {
- idx += 1;
- }
- return slice(0, idx, xs);
-}));
-
-function XTap(f, xf) {
- this.xf = xf;
- this.f = f;
-}
-XTap.prototype['@@transducer/init'] = _xfBase.init;
-XTap.prototype['@@transducer/result'] = _xfBase.result;
-XTap.prototype['@@transducer/step'] = function(result, input) {
- this.f(input);
- return this.xf['@@transducer/step'](result, input);
-};
-
-var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); });
-
-/**
- * Runs the given function with the supplied object, then returns the object.
- *
- * Acts as a transducer if a transformer is given as second parameter.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Function
- * @sig (a -> *) -> a -> a
- * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away.
- * @param {*} x
- * @return {*} `x`.
- * @example
- *
- * const sayX = x => console.log('x is ' + x);
- * R.tap(sayX, 100); //=> 100
- * // logs 'x is 100'
- * @symb R.tap(f, a) = a
- */
-var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) {
- fn(x);
- return x;
-}));
+ var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) {
+ return new XTakeWhile(f, xf);
+ });
-function _isRegExp(x) {
- return Object.prototype.toString.call(x) === '[object RegExp]';
-}
+ /**
+ * Returns a new list containing the first `n` elements of a given list,
+ * passing each value to the supplied predicate function, and terminating when
+ * the predicate function returns `false`. Excludes the element that caused the
+ * predicate function to fail. The predicate function is passed one argument:
+ * *(value)*.
+ *
+ * Dispatches to the `takeWhile` method of the second argument, if present.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig (a -> Boolean) -> [a] -> [a]
+ * @sig (a -> Boolean) -> String -> String
+ * @param {Function} fn The function called per iteration.
+ * @param {Array} xs The collection to iterate over.
+ * @return {Array} A new array.
+ * @see R.dropWhile, R.transduce, R.addIndex
+ * @example
+ *
+ * const isNotFour = x => x !== 4;
+ *
+ * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]
+ *
+ * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram'
+ */
+ var takeWhile = _curry2(
+ _dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) {
+ var idx = 0;
+ var len = xs.length;
+ while (idx < len && fn(xs[idx])) {
+ idx += 1;
+ }
+ return slice(0, idx, xs);
+ })
+ );
-/**
- * Determines whether a given string matches a given regular expression.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category String
- * @sig RegExp -> String -> Boolean
- * @param {RegExp} pattern
- * @param {String} str
- * @return {Boolean}
- * @see R.match
- * @example
- *
- * R.test(/^x/, 'xyz'); //=> true
- * R.test(/^y/, 'xyz'); //=> false
- */
-var test = _curry2(function test(pattern, str) {
- if (!_isRegExp(pattern)) {
- throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern));
+ function XTap(f, xf) {
+ this.xf = xf;
+ this.f = f;
}
- return _cloneRegExp(pattern).test(str);
-});
-
-/**
- * Returns the result of applying the onSuccess function to the value inside
- * a successfully resolved promise. This is useful for working with promises
- * inside function compositions.
- *
- * @func
- * @memberOf R
- * @category Function
- * @sig (a -> b) -> (Promise e a) -> (Promise e b)
- * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b)
- * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value.
- * @param {Promise} p
- * @return {Promise} The result of calling `p.then(onSuccess)`
- * @see R.otherwise
- * @example
- *
- * var makeQuery = (email) => ({ query: { email }});
- *
- * //getMemberName :: String -> Promise ({firstName, lastName})
- * var getMemberName = R.pipe(
- * makeQuery,
- * fetchMember,
- * R.then(R.pick(['firstName', 'lastName']))
- * );
- */
-const then = _curry2(function then(f, p) {
- _assertPromise('then', p);
+ XTap.prototype['@@transducer/init'] = _xfBase.init;
+ XTap.prototype['@@transducer/result'] = _xfBase.result;
+ XTap.prototype['@@transducer/step'] = function (result, input) {
+ this.f(input);
+ return this.xf['@@transducer/step'](result, input);
+ };
- return p.then(f);
-});
+ var _xtap = _curry2(function _xtap(f, xf) {
+ return new XTap(f, xf);
+ });
-/**
- * The lower case version of a string.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category String
- * @sig String -> String
- * @param {String} str The string to lower case.
- * @return {String} The lower case version of `str`.
- * @see R.toUpper
- * @example
- *
- * R.toLower('XYZ'); //=> 'xyz'
- */
-var toLower = invoker(0, 'toLowerCase');
+ /**
+ * Runs the given function with the supplied object, then returns the object.
+ *
+ * Acts as a transducer if a transformer is given as second parameter.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Function
+ * @sig (a -> *) -> a -> a
+ * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away.
+ * @param {*} x
+ * @return {*} `x`.
+ * @example
+ *
+ * const sayX = x => console.log('x is ' + x);
+ * R.tap(sayX, 100); //=> 100
+ * // logs 'x is 100'
+ * @symb R.tap(f, a) = a
+ */
+ var tap = _curry2(
+ _dispatchable([], _xtap, function tap(fn, x) {
+ fn(x);
+ return x;
+ })
+ );
-/**
- * Converts an object into an array of key, value arrays. Only the object's
- * own properties are used.
- * Note that the order of the output array is not guaranteed to be consistent
- * across different JS platforms.
- *
- * @func
- * @memberOf R
- * @since v0.4.0
- * @category Object
- * @sig {String: *} -> [[String,*]]
- * @param {Object} obj The object to extract from
- * @return {Array} An array of key, value arrays from the object's own properties.
- * @see R.fromPairs
- * @example
- *
- * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
- */
-var toPairs = _curry1(function toPairs(obj) {
- var pairs = [];
- for (var prop in obj) {
- if (_has(prop, obj)) {
- pairs[pairs.length] = [prop, obj[prop]];
+ function _isRegExp(x) {
+ return Object.prototype.toString.call(x) === '[object RegExp]';
+ }
+
+ /**
+ * Determines whether a given string matches a given regular expression.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category String
+ * @sig RegExp -> String -> Boolean
+ * @param {RegExp} pattern
+ * @param {String} str
+ * @return {Boolean}
+ * @see R.match
+ * @example
+ *
+ * R.test(/^x/, 'xyz'); //=> true
+ * R.test(/^y/, 'xyz'); //=> false
+ */
+ var test = _curry2(function test(pattern, str) {
+ if (!_isRegExp(pattern)) {
+ throw new TypeError(
+ '‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)
+ );
}
- }
- return pairs;
-});
+ return _cloneRegExp(pattern).test(str);
+ });
-/**
- * Converts an object into an array of key, value arrays. The object's own
- * properties and prototype properties are used. Note that the order of the
- * output array is not guaranteed to be consistent across different JS
- * platforms.
- *
- * @func
- * @memberOf R
- * @since v0.4.0
- * @category Object
- * @sig {String: *} -> [[String,*]]
- * @param {Object} obj The object to extract from
- * @return {Array} An array of key, value arrays from the object's own
- * and prototype properties.
- * @example
- *
- * const F = function() { this.x = 'X'; };
- * F.prototype.y = 'Y';
- * const f = new F();
- * R.toPairsIn(f); //=> [['x','X'], ['y','Y']]
- */
-var toPairsIn = _curry1(function toPairsIn(obj) {
- var pairs = [];
- for (var prop in obj) {
- pairs[pairs.length] = [prop, obj[prop]];
- }
- return pairs;
-});
+ /**
+ * Returns the result of applying the onSuccess function to the value inside
+ * a successfully resolved promise. This is useful for working with promises
+ * inside function compositions.
+ *
+ * @func
+ * @memberOf R
+ * @category Function
+ * @sig (a -> b) -> (Promise e a) -> (Promise e b)
+ * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b)
+ * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value.
+ * @param {Promise} p
+ * @return {Promise} The result of calling `p.then(onSuccess)`
+ * @see R.otherwise
+ * @example
+ *
+ * var makeQuery = (email) => ({ query: { email }});
+ *
+ * //getMemberName :: String -> Promise ({firstName, lastName})
+ * var getMemberName = R.pipe(
+ * makeQuery,
+ * fetchMember,
+ * R.then(R.pick(['firstName', 'lastName']))
+ * );
+ */
+ const then = _curry2(function then(f, p) {
+ _assertPromise('then', p);
+
+ return p.then(f);
+ });
-/**
- * The upper case version of a string.
- *
- * @func
- * @memberOf R
- * @since v0.9.0
- * @category String
- * @sig String -> String
- * @param {String} str The string to upper case.
- * @return {String} The upper case version of `str`.
- * @see R.toLower
- * @example
- *
- * R.toUpper('abc'); //=> 'ABC'
- */
-var toUpper = invoker(0, 'toUpperCase');
+ /**
+ * The lower case version of a string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category String
+ * @sig String -> String
+ * @param {String} str The string to lower case.
+ * @return {String} The lower case version of `str`.
+ * @see R.toUpper
+ * @example
+ *
+ * R.toLower('XYZ'); //=> 'xyz'
+ */
+ var toLower = invoker(0, 'toLowerCase');
+
+ /**
+ * Converts an object into an array of key, value arrays. Only the object's
+ * own properties are used.
+ * Note that the order of the output array is not guaranteed to be consistent
+ * across different JS platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.4.0
+ * @category Object
+ * @sig {String: *} -> [[String,*]]
+ * @param {Object} obj The object to extract from
+ * @return {Array} An array of key, value arrays from the object's own properties.
+ * @see R.fromPairs
+ * @example
+ *
+ * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
+ */
+ var toPairs = _curry1(function toPairs(obj) {
+ var pairs = [];
+ for (var prop in obj) {
+ if (_has(prop, obj)) {
+ pairs[pairs.length] = [prop, obj[prop]];
+ }
+ }
+ return pairs;
+ });
-/**
- * Initializes a transducer using supplied iterator function. Returns a single
- * item by iterating through the list, successively calling the transformed
- * iterator function and passing it an accumulator value and the current value
- * from the array, and then passing the result to the next call.
- *
- * The iterator function receives two values: *(acc, value)*. It will be
- * wrapped as a transformer to initialize the transducer. A transformer can be
- * passed directly in place of an iterator function. In both cases, iteration
- * may be stopped early with the [`R.reduced`](#reduced) function.
- *
- * A transducer is a function that accepts a transformer and returns a
- * transformer and can be composed directly.
- *
- * A transformer is an an object that provides a 2-arity reducing iterator
- * function, step, 0-arity initial value function, init, and 1-arity result
- * extraction function, result. The step function is used as the iterator
- * function in reduce. The result function is used to convert the final
- * accumulator into the return type and in most cases is
- * [`R.identity`](#identity). The init function can be used to provide an
- * initial accumulator, but is ignored by transduce.
- *
- * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer.
- *
- * @func
- * @memberOf R
- * @since v0.12.0
- * @category List
- * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a
- * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
- * @param {Function} fn The iterator function. Receives two values, the accumulator and the
- * current element from the array. Wrapped as transformer, if necessary, and used to
- * initialize the transducer
- * @param {*} acc The initial accumulator value.
- * @param {Array} list The list to iterate over.
- * @return {*} The final, accumulated value.
- * @see R.reduce, R.reduced, R.into
- * @example
- *
- * const numbers = [1, 2, 3, 4];
- * const transducer = R.compose(R.map(R.add(1)), R.take(2));
- * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3]
- *
- * const isOdd = (x) => x % 2 === 1;
- * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1));
- * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1]
- */
-var transduce = curryN(4, function transduce(xf, fn, acc, list) {
- return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list);
-});
+ /**
+ * Converts an object into an array of key, value arrays. The object's own
+ * properties and prototype properties are used. Note that the order of the
+ * output array is not guaranteed to be consistent across different JS
+ * platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.4.0
+ * @category Object
+ * @sig {String: *} -> [[String,*]]
+ * @param {Object} obj The object to extract from
+ * @return {Array} An array of key, value arrays from the object's own
+ * and prototype properties.
+ * @example
+ *
+ * const F = function() { this.x = 'X'; };
+ * F.prototype.y = 'Y';
+ * const f = new F();
+ * R.toPairsIn(f); //=> [['x','X'], ['y','Y']]
+ */
+ var toPairsIn = _curry1(function toPairsIn(obj) {
+ var pairs = [];
+ for (var prop in obj) {
+ pairs[pairs.length] = [prop, obj[prop]];
+ }
+ return pairs;
+ });
-/**
- * Transposes the rows and columns of a 2D list.
- * When passed a list of `n` lists of length `x`,
- * returns a list of `x` lists of length `n`.
- *
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig [[a]] -> [[a]]
- * @param {Array} list A 2D list
- * @return {Array} A 2D list
- * @example
- *
- * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
- * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
- *
- * // If some of the rows are shorter than the following rows, their elements are skipped:
- * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
- * @symb R.transpose([[a], [b], [c]]) = [a, b, c]
- * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]]
- * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]]
- */
-var transpose = _curry1(function transpose(outerlist) {
- var i = 0;
- var result = [];
- while (i < outerlist.length) {
- var innerlist = outerlist[i];
- var j = 0;
- while (j < innerlist.length) {
- if (typeof result[j] === 'undefined') {
- result[j] = [];
+ /**
+ * The upper case version of a string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.9.0
+ * @category String
+ * @sig String -> String
+ * @param {String} str The string to upper case.
+ * @return {String} The upper case version of `str`.
+ * @see R.toLower
+ * @example
+ *
+ * R.toUpper('abc'); //=> 'ABC'
+ */
+ var toUpper = invoker(0, 'toUpperCase');
+
+ /**
+ * Initializes a transducer using supplied iterator function. Returns a single
+ * item by iterating through the list, successively calling the transformed
+ * iterator function and passing it an accumulator value and the current value
+ * from the array, and then passing the result to the next call.
+ *
+ * The iterator function receives two values: *(acc, value)*. It will be
+ * wrapped as a transformer to initialize the transducer. A transformer can be
+ * passed directly in place of an iterator function. In both cases, iteration
+ * may be stopped early with the [`R.reduced`](#reduced) function.
+ *
+ * A transducer is a function that accepts a transformer and returns a
+ * transformer and can be composed directly.
+ *
+ * A transformer is an an object that provides a 2-arity reducing iterator
+ * function, step, 0-arity initial value function, init, and 1-arity result
+ * extraction function, result. The step function is used as the iterator
+ * function in reduce. The result function is used to convert the final
+ * accumulator into the return type and in most cases is
+ * [`R.identity`](#identity). The init function can be used to provide an
+ * initial accumulator, but is ignored by transduce.
+ *
+ * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.12.0
+ * @category List
+ * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a
+ * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
+ * @param {Function} fn The iterator function. Receives two values, the accumulator and the
+ * current element from the array. Wrapped as transformer, if necessary, and used to
+ * initialize the transducer
+ * @param {*} acc The initial accumulator value.
+ * @param {Array} list The list to iterate over.
+ * @return {*} The final, accumulated value.
+ * @see R.reduce, R.reduced, R.into
+ * @example
+ *
+ * const numbers = [1, 2, 3, 4];
+ * const transducer = R.compose(R.map(R.add(1)), R.take(2));
+ * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3]
+ *
+ * const isOdd = (x) => x % 2 === 1;
+ * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1));
+ * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1]
+ */
+ var transduce = curryN(4, function transduce(xf, fn, acc, list) {
+ return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list);
+ });
+
+ /**
+ * Transposes the rows and columns of a 2D list.
+ * When passed a list of `n` lists of length `x`,
+ * returns a list of `x` lists of length `n`.
+ *
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig [[a]] -> [[a]]
+ * @param {Array} list A 2D list
+ * @return {Array} A 2D list
+ * @example
+ *
+ * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
+ * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
+ *
+ * // If some of the rows are shorter than the following rows, their elements are skipped:
+ * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
+ * @symb R.transpose([[a], [b], [c]]) = [a, b, c]
+ * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]]
+ * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]]
+ */
+ var transpose = _curry1(function transpose(outerlist) {
+ var i = 0;
+ var result = [];
+ while (i < outerlist.length) {
+ var innerlist = outerlist[i];
+ var j = 0;
+ while (j < innerlist.length) {
+ if (typeof result[j] === 'undefined') {
+ result[j] = [];
+ }
+ result[j].push(innerlist[j]);
+ j += 1;
}
- result[j].push(innerlist[j]);
- j += 1;
+ i += 1;
}
- i += 1;
- }
- return result;
-});
-
-/**
- * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning
- * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),
- * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative
- * into an Applicative of Traversable.
- *
- * Dispatches to the `traverse` method of the third argument, if present.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
- * @param {Function} of
- * @param {Function} f
- * @param {*} traversable
- * @return {*}
- * @see R.sequence
- * @example
- *
- * // Returns `Maybe.Nothing` if the given divisor is `0`
- * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d)
- *
- * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2])
- * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing
- */
-var traverse = _curry3(function traverse(of, f, traversable) {
- return typeof traversable['fantasy-land/traverse'] === 'function' ?
- traversable['fantasy-land/traverse'](f, of) :
- sequence(of, map(f, traversable));
-});
+ return result;
+ });
-var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
- '\u2029\uFEFF';
-var zeroWidth = '\u200b';
-var hasProtoTrim = (typeof String.prototype.trim === 'function');
-/**
- * Removes (strips) whitespace from both ends of the string.
- *
- * @func
- * @memberOf R
- * @since v0.6.0
- * @category String
- * @sig String -> String
- * @param {String} str The string to trim.
- * @return {String} Trimmed version of `str`.
- * @example
- *
- * R.trim(' xyz '); //=> 'xyz'
- * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
- */
-var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ?
- _curry1(function trim(str) {
- var beginRx = new RegExp('^[' + ws + '][' + ws + ']*');
- var endRx = new RegExp('[' + ws + '][' + ws + ']*$');
- return str.replace(beginRx, '').replace(endRx, '');
- }) :
- _curry1(function trim(str) {
- return str.trim();
+ /**
+ * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning
+ * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),
+ * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative
+ * into an Applicative of Traversable.
+ *
+ * Dispatches to the `traverse` method of the third argument, if present.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
+ * @param {Function} of
+ * @param {Function} f
+ * @param {*} traversable
+ * @return {*}
+ * @see R.sequence
+ * @example
+ *
+ * // Returns `Maybe.Nothing` if the given divisor is `0`
+ * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d)
+ *
+ * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2])
+ * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing
+ */
+ var traverse = _curry3(function traverse(of, f, traversable) {
+ return typeof traversable['fantasy-land/traverse'] === 'function'
+ ? traversable['fantasy-land/traverse'](f, of)
+ : sequence(of, map(f, traversable));
});
-/**
+ var ws =
+ '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
+ '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
+ '\u2029\uFEFF';
+ var zeroWidth = '\u200b';
+ var hasProtoTrim = typeof String.prototype.trim === 'function';
+ /**
+ * Removes (strips) whitespace from both ends of the string.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.6.0
+ * @category String
+ * @sig String -> String
+ * @param {String} str The string to trim.
+ * @return {String} Trimmed version of `str`.
+ * @example
+ *
+ * R.trim(' xyz '); //=> 'xyz'
+ * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
+ */
+ var trim =
+ !hasProtoTrim || ws.trim() || !zeroWidth.trim()
+ ? _curry1(function trim(str) {
+ var beginRx = new RegExp('^[' + ws + '][' + ws + ']*');
+ var endRx = new RegExp('[' + ws + '][' + ws + ']*$');
+ return str.replace(beginRx, '').replace(endRx, '');
+ })
+ : _curry1(function trim(str) {
+ return str.trim();
+ });
+
+ /**
* `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned
* function evaluates the `tryer`; if it does not throw, it simply returns the
* result. If the `tryer` *does* throw, the returned function evaluates the
@@ -8663,906 +9035,911 @@ var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ?
* R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched'
* R.tryCatch(R.times(R.identity), R.always([]))('s') // => []
`` */
-var tryCatch = _curry2(function _tryCatch(tryer, catcher) {
- return _arity(tryer.length, function() {
- try {
- return tryer.apply(this, arguments);
- } catch (e) {
- return catcher.apply(this, _concat([e], arguments));
- }
+ var tryCatch = _curry2(function _tryCatch(tryer, catcher) {
+ return _arity(tryer.length, function () {
+ try {
+ return tryer.apply(this, arguments);
+ } catch (e) {
+ return catcher.apply(this, _concat([e], arguments));
+ }
+ });
});
-});
-
-/**
- * Takes a function `fn`, which takes a single array argument, and returns a
- * function which:
- *
- * - takes any number of positional arguments;
- * - passes these arguments to `fn` as an array; and
- * - returns the result.
- *
- * In other words, `R.unapply` derives a variadic function from a function which
- * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply).
- *
- * @func
- * @memberOf R
- * @since v0.8.0
- * @category Function
- * @sig ([*...] -> a) -> (*... -> a)
- * @param {Function} fn
- * @return {Function}
- * @see R.apply
- * @example
- *
- * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
- * @symb R.unapply(f)(a, b) = f([a, b])
- */
-var unapply = _curry1(function unapply(fn) {
- return function() {
- return fn(Array.prototype.slice.call(arguments, 0));
- };
-});
-
-/**
- * Wraps a function of any arity (including nullary) in a function that accepts
- * exactly 1 parameter. Any extraneous parameters will not be passed to the
- * supplied function.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category Function
- * @sig (* -> b) -> (a -> b)
- * @param {Function} fn The function to wrap.
- * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
- * arity 1.
- * @see R.binary, R.nAry
- * @example
- *
- * const takesTwoArgs = function(a, b) {
- * return [a, b];
- * };
- * takesTwoArgs.length; //=> 2
- * takesTwoArgs(1, 2); //=> [1, 2]
- *
- * const takesOneArg = R.unary(takesTwoArgs);
- * takesOneArg.length; //=> 1
- * // Only 1 argument is passed to the wrapped function
- * takesOneArg(1, 2); //=> [1, undefined]
- * @symb R.unary(f)(a, b, c) = f(a)
- */
-var unary = _curry1(function unary(fn) {
- return nAry(1, fn);
-});
-/**
- * Returns a function of arity `n` from a (manually) curried function.
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Function
- * @sig Number -> (a -> b) -> (a -> c)
- * @param {Number} length The arity for the returned function.
- * @param {Function} fn The function to uncurry.
- * @return {Function} A new function.
- * @see R.curry
- * @example
- *
- * const addFour = a => b => c => d => a + b + c + d;
- *
- * const uncurriedAddFour = R.uncurryN(4, addFour);
- * uncurriedAddFour(1, 2, 3, 4); //=> 10
- */
-var uncurryN = _curry2(function uncurryN(depth, fn) {
- return curryN(depth, function() {
- var currentDepth = 1;
- var value = fn;
- var idx = 0;
- var endIdx;
- while (currentDepth <= depth && typeof value === 'function') {
- endIdx = currentDepth === depth ? arguments.length : idx + value.length;
- value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx));
- currentDepth += 1;
- idx = endIdx;
- }
- return value;
+ /**
+ * Takes a function `fn`, which takes a single array argument, and returns a
+ * function which:
+ *
+ * - takes any number of positional arguments;
+ * - passes these arguments to `fn` as an array; and
+ * - returns the result.
+ *
+ * In other words, `R.unapply` derives a variadic function from a function which
+ * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.8.0
+ * @category Function
+ * @sig ([*...] -> a) -> (*... -> a)
+ * @param {Function} fn
+ * @return {Function}
+ * @see R.apply
+ * @example
+ *
+ * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
+ * @symb R.unapply(f)(a, b) = f([a, b])
+ */
+ var unapply = _curry1(function unapply(fn) {
+ return function () {
+ return fn(Array.prototype.slice.call(arguments, 0));
+ };
});
-});
-/**
- * Builds a list from a seed value. Accepts an iterator function, which returns
- * either false to stop iteration or an array of length 2 containing the value
- * to add to the resulting list and the seed to be used in the next call to the
- * iterator function.
- *
- * The iterator function receives one argument: *(seed)*.
- *
- * @func
- * @memberOf R
- * @since v0.10.0
- * @category List
- * @sig (a -> [b]) -> * -> [b]
- * @param {Function} fn The iterator function. receives one argument, `seed`, and returns
- * either false to quit iteration or an array of length two to proceed. The element
- * at index 0 of this array will be added to the resulting array, and the element
- * at index 1 will be passed to the next call to `fn`.
- * @param {*} seed The seed value.
- * @return {Array} The final list.
- * @example
- *
- * const f = n => n > 50 ? false : [-n, n + 10];
- * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
- * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...]
- */
-var unfold = _curry2(function unfold(fn, seed) {
- var pair = fn(seed);
- var result = [];
- while (pair && pair.length) {
- result[result.length] = pair[0];
- pair = fn(pair[1]);
- }
- return result;
-});
+ /**
+ * Wraps a function of any arity (including nullary) in a function that accepts
+ * exactly 1 parameter. Any extraneous parameters will not be passed to the
+ * supplied function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category Function
+ * @sig (* -> b) -> (a -> b)
+ * @param {Function} fn The function to wrap.
+ * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
+ * arity 1.
+ * @see R.binary, R.nAry
+ * @example
+ *
+ * const takesTwoArgs = function(a, b) {
+ * return [a, b];
+ * };
+ * takesTwoArgs.length; //=> 2
+ * takesTwoArgs(1, 2); //=> [1, 2]
+ *
+ * const takesOneArg = R.unary(takesTwoArgs);
+ * takesOneArg.length; //=> 1
+ * // Only 1 argument is passed to the wrapped function
+ * takesOneArg(1, 2); //=> [1, undefined]
+ * @symb R.unary(f)(a, b, c) = f(a)
+ */
+ var unary = _curry1(function unary(fn) {
+ return nAry(1, fn);
+ });
-/**
- * Combines two lists into a set (i.e. no duplicates) composed of the elements
- * of each list.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig [*] -> [*] -> [*]
- * @param {Array} as The first list.
- * @param {Array} bs The second list.
- * @return {Array} The first and second lists concatenated, with
- * duplicates removed.
- * @example
- *
- * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4]
- */
-var union = _curry2(compose(uniq, _concat));
+ /**
+ * Returns a function of arity `n` from a (manually) curried function.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Function
+ * @sig Number -> (a -> b) -> (a -> c)
+ * @param {Number} length The arity for the returned function.
+ * @param {Function} fn The function to uncurry.
+ * @return {Function} A new function.
+ * @see R.curry
+ * @example
+ *
+ * const addFour = a => b => c => d => a + b + c + d;
+ *
+ * const uncurriedAddFour = R.uncurryN(4, addFour);
+ * uncurriedAddFour(1, 2, 3, 4); //=> 10
+ */
+ var uncurryN = _curry2(function uncurryN(depth, fn) {
+ return curryN(depth, function () {
+ var currentDepth = 1;
+ var value = fn;
+ var idx = 0;
+ var endIdx;
+ while (currentDepth <= depth && typeof value === 'function') {
+ endIdx = currentDepth === depth ? arguments.length : idx + value.length;
+ value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx));
+ currentDepth += 1;
+ idx = endIdx;
+ }
+ return value;
+ });
+ });
-/**
- * Returns a new list containing only one copy of each element in the original
- * list, based upon the value returned by applying the supplied predicate to
- * two list elements. Prefers the first item if two items compare equal based
- * on the predicate.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category List
- * @sig ((a, a) -> Boolean) -> [a] -> [a]
- * @param {Function} pred A predicate used to test whether two items are equal.
- * @param {Array} list The array to consider.
- * @return {Array} The list of unique items.
- * @example
- *
- * const strEq = R.eqBy(String);
- * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2]
- * R.uniqWith(strEq)([{}, {}]); //=> [{}]
- * R.uniqWith(strEq)([1, '1', 1]); //=> [1]
- * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1']
- */
-var uniqWith = _curry2(function uniqWith(pred, list) {
- var idx = 0;
- var len = list.length;
- var result = [];
- var item;
- while (idx < len) {
- item = list[idx];
- if (!_includesWith(pred, item, result)) {
- result[result.length] = item;
- }
- idx += 1;
- }
- return result;
-});
+ /**
+ * Builds a list from a seed value. Accepts an iterator function, which returns
+ * either false to stop iteration or an array of length 2 containing the value
+ * to add to the resulting list and the seed to be used in the next call to the
+ * iterator function.
+ *
+ * The iterator function receives one argument: *(seed)*.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.10.0
+ * @category List
+ * @sig (a -> [b]) -> * -> [b]
+ * @param {Function} fn The iterator function. receives one argument, `seed`, and returns
+ * either false to quit iteration or an array of length two to proceed. The element
+ * at index 0 of this array will be added to the resulting array, and the element
+ * at index 1 will be passed to the next call to `fn`.
+ * @param {*} seed The seed value.
+ * @return {Array} The final list.
+ * @example
+ *
+ * const f = n => n > 50 ? false : [-n, n + 10];
+ * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
+ * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...]
+ */
+ var unfold = _curry2(function unfold(fn, seed) {
+ var pair = fn(seed);
+ var result = [];
+ while (pair && pair.length) {
+ result[result.length] = pair[0];
+ pair = fn(pair[1]);
+ }
+ return result;
+ });
-/**
- * Combines two lists into a set (i.e. no duplicates) composed of the elements
- * of each list. Duplication is determined according to the value returned by
- * applying the supplied predicate to two list elements.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category Relation
- * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*]
- * @param {Function} pred A predicate used to test whether two items are equal.
- * @param {Array} list1 The first list.
- * @param {Array} list2 The second list.
- * @return {Array} The first and second lists concatenated, with
- * duplicates removed.
- * @see R.union
- * @example
- *
- * const l1 = [{a: 1}, {a: 2}];
- * const l2 = [{a: 1}, {a: 4}];
- * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
- */
-var unionWith = _curry3(function unionWith(pred, list1, list2) {
- return uniqWith(pred, _concat(list1, list2));
-});
+ /**
+ * Combines two lists into a set (i.e. no duplicates) composed of the elements
+ * of each list.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig [*] -> [*] -> [*]
+ * @param {Array} as The first list.
+ * @param {Array} bs The second list.
+ * @return {Array} The first and second lists concatenated, with
+ * duplicates removed.
+ * @example
+ *
+ * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4]
+ */
+ var union = _curry2(compose(uniq, _concat));
+
+ /**
+ * Returns a new list containing only one copy of each element in the original
+ * list, based upon the value returned by applying the supplied predicate to
+ * two list elements. Prefers the first item if two items compare equal based
+ * on the predicate.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category List
+ * @sig ((a, a) -> Boolean) -> [a] -> [a]
+ * @param {Function} pred A predicate used to test whether two items are equal.
+ * @param {Array} list The array to consider.
+ * @return {Array} The list of unique items.
+ * @example
+ *
+ * const strEq = R.eqBy(String);
+ * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2]
+ * R.uniqWith(strEq)([{}, {}]); //=> [{}]
+ * R.uniqWith(strEq)([1, '1', 1]); //=> [1]
+ * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1']
+ */
+ var uniqWith = _curry2(function uniqWith(pred, list) {
+ var idx = 0;
+ var len = list.length;
+ var result = [];
+ var item;
+ while (idx < len) {
+ item = list[idx];
+ if (!_includesWith(pred, item, result)) {
+ result[result.length] = item;
+ }
+ idx += 1;
+ }
+ return result;
+ });
-/**
- * Tests the final argument by passing it to the given predicate function. If
- * the predicate is not satisfied, the function will return the result of
- * calling the `whenFalseFn` function with the same argument. If the predicate
- * is satisfied, the argument is returned as is.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category Logic
- * @sig (a -> Boolean) -> (a -> a) -> a -> a
- * @param {Function} pred A predicate function
- * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates
- * to a falsy value.
- * @param {*} x An object to test with the `pred` function and
- * pass to `whenFalseFn` if necessary.
- * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`.
- * @see R.ifElse, R.when, R.cond
- * @example
- *
- * let safeInc = R.unless(R.isNil, R.inc);
- * safeInc(null); //=> null
- * safeInc(1); //=> 2
- */
-var unless = _curry3(function unless(pred, whenFalseFn, x) {
- return pred(x) ? x : whenFalseFn(x);
-});
+ /**
+ * Combines two lists into a set (i.e. no duplicates) composed of the elements
+ * of each list. Duplication is determined according to the value returned by
+ * applying the supplied predicate to two list elements.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category Relation
+ * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*]
+ * @param {Function} pred A predicate used to test whether two items are equal.
+ * @param {Array} list1 The first list.
+ * @param {Array} list2 The second list.
+ * @return {Array} The first and second lists concatenated, with
+ * duplicates removed.
+ * @see R.union
+ * @example
+ *
+ * const l1 = [{a: 1}, {a: 2}];
+ * const l2 = [{a: 1}, {a: 4}];
+ * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
+ */
+ var unionWith = _curry3(function unionWith(pred, list1, list2) {
+ return uniqWith(pred, _concat(list1, list2));
+ });
-/**
- * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from
- * any [Chain](https://github.com/fantasyland/fantasy-land#chain).
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category List
- * @sig Chain c => c (c a) -> c a
- * @param {*} list
- * @return {*}
- * @see R.flatten, R.chain
- * @example
- *
- * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]]
- * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6]
- */
-var unnest = chain(_identity);
+ /**
+ * Tests the final argument by passing it to the given predicate function. If
+ * the predicate is not satisfied, the function will return the result of
+ * calling the `whenFalseFn` function with the same argument. If the predicate
+ * is satisfied, the argument is returned as is.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category Logic
+ * @sig (a -> Boolean) -> (a -> a) -> a -> a
+ * @param {Function} pred A predicate function
+ * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates
+ * to a falsy value.
+ * @param {*} x An object to test with the `pred` function and
+ * pass to `whenFalseFn` if necessary.
+ * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`.
+ * @see R.ifElse, R.when, R.cond
+ * @example
+ *
+ * let safeInc = R.unless(R.isNil, R.inc);
+ * safeInc(null); //=> null
+ * safeInc(1); //=> 2
+ */
+ var unless = _curry3(function unless(pred, whenFalseFn, x) {
+ return pred(x) ? x : whenFalseFn(x);
+ });
-/**
- * Takes a predicate, a transformation function, and an initial value,
- * and returns a value of the same type as the initial value.
- * It does so by applying the transformation until the predicate is satisfied,
- * at which point it returns the satisfactory value.
- *
- * @func
- * @memberOf R
- * @since v0.20.0
- * @category Logic
- * @sig (a -> Boolean) -> (a -> a) -> a -> a
- * @param {Function} pred A predicate function
- * @param {Function} fn The iterator function
- * @param {*} init Initial value
- * @return {*} Final value that satisfies predicate
- * @example
- *
- * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
- */
-var until = _curry3(function until(pred, fn, init) {
- var val = init;
- while (!pred(val)) {
- val = fn(val);
- }
- return val;
-});
+ /**
+ * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from
+ * any [Chain](https://github.com/fantasyland/fantasy-land#chain).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category List
+ * @sig Chain c => c (c a) -> c a
+ * @param {*} list
+ * @return {*}
+ * @see R.flatten, R.chain
+ * @example
+ *
+ * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]]
+ * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6]
+ */
+ var unnest = chain(_identity);
+
+ /**
+ * Takes a predicate, a transformation function, and an initial value,
+ * and returns a value of the same type as the initial value.
+ * It does so by applying the transformation until the predicate is satisfied,
+ * at which point it returns the satisfactory value.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.20.0
+ * @category Logic
+ * @sig (a -> Boolean) -> (a -> a) -> a -> a
+ * @param {Function} pred A predicate function
+ * @param {Function} fn The iterator function
+ * @param {*} init Initial value
+ * @return {*} Final value that satisfies predicate
+ * @example
+ *
+ * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
+ */
+ var until = _curry3(function until(pred, fn, init) {
+ var val = init;
+ while (!pred(val)) {
+ val = fn(val);
+ }
+ return val;
+ });
-/**
- * Returns a list of all the properties, including prototype properties, of the
- * supplied object.
- * Note that the order of the output array is not guaranteed to be consistent
- * across different JS platforms.
- *
- * @func
- * @memberOf R
- * @since v0.2.0
- * @category Object
- * @sig {k: v} -> [v]
- * @param {Object} obj The object to extract values from
- * @return {Array} An array of the values of the object's own and prototype properties.
- * @see R.values, R.keysIn
- * @example
- *
- * const F = function() { this.x = 'X'; };
- * F.prototype.y = 'Y';
- * const f = new F();
- * R.valuesIn(f); //=> ['X', 'Y']
- */
-var valuesIn = _curry1(function valuesIn(obj) {
- var prop;
- var vs = [];
- for (prop in obj) {
- vs[vs.length] = obj[prop];
- }
- return vs;
-});
+ /**
+ * Returns a list of all the properties, including prototype properties, of the
+ * supplied object.
+ * Note that the order of the output array is not guaranteed to be consistent
+ * across different JS platforms.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.2.0
+ * @category Object
+ * @sig {k: v} -> [v]
+ * @param {Object} obj The object to extract values from
+ * @return {Array} An array of the values of the object's own and prototype properties.
+ * @see R.values, R.keysIn
+ * @example
+ *
+ * const F = function() { this.x = 'X'; };
+ * F.prototype.y = 'Y';
+ * const f = new F();
+ * R.valuesIn(f); //=> ['X', 'Y']
+ */
+ var valuesIn = _curry1(function valuesIn(obj) {
+ var prop;
+ var vs = [];
+ for (prop in obj) {
+ vs[vs.length] = obj[prop];
+ }
+ return vs;
+ });
-// `Const` is a functor that effectively ignores the function given to `map`.
-var Const = function(x) {
- return {value: x, 'fantasy-land/map': function() { return this; }};
-};
+ // `Const` is a functor that effectively ignores the function given to `map`.
+ var Const = function (x) {
+ return {
+ value: x,
+ 'fantasy-land/map': function () {
+ return this;
+ },
+ };
+ };
-/**
- * Returns a "view" of the given data structure, determined by the given lens.
- * The lens's focus determines which portion of the data structure is visible.
- *
- * @func
- * @memberOf R
- * @since v0.16.0
- * @category Object
- * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
- * @sig Lens s a -> s -> a
- * @param {Lens} lens
- * @param {*} x
- * @return {*}
- * @see R.prop, R.lensIndex, R.lensProp
- * @example
- *
- * const xLens = R.lensProp('x');
- *
- * R.view(xLens, {x: 1, y: 2}); //=> 1
- * R.view(xLens, {x: 4, y: 2}); //=> 4
- */
-var view = _curry2(function view(lens, x) {
- // Using `Const` effectively ignores the setter function of the `lens`,
- // leaving the value returned by the getter function unmodified.
- return lens(Const)(x).value;
-});
+ /**
+ * Returns a "view" of the given data structure, determined by the given lens.
+ * The lens's focus determines which portion of the data structure is visible.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.16.0
+ * @category Object
+ * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
+ * @sig Lens s a -> s -> a
+ * @param {Lens} lens
+ * @param {*} x
+ * @return {*}
+ * @see R.prop, R.lensIndex, R.lensProp
+ * @example
+ *
+ * const xLens = R.lensProp('x');
+ *
+ * R.view(xLens, {x: 1, y: 2}); //=> 1
+ * R.view(xLens, {x: 4, y: 2}); //=> 4
+ */
+ var view = _curry2(function view(lens, x) {
+ // Using `Const` effectively ignores the setter function of the `lens`,
+ // leaving the value returned by the getter function unmodified.
+ return lens(Const)(x).value;
+ });
-/**
- * Tests the final argument by passing it to the given predicate function. If
- * the predicate is satisfied, the function will return the result of calling
- * the `whenTrueFn` function with the same argument. If the predicate is not
- * satisfied, the argument is returned as is.
- *
- * @func
- * @memberOf R
- * @since v0.18.0
- * @category Logic
- * @sig (a -> Boolean) -> (a -> a) -> a -> a
- * @param {Function} pred A predicate function
- * @param {Function} whenTrueFn A function to invoke when the `condition`
- * evaluates to a truthy value.
- * @param {*} x An object to test with the `pred` function and
- * pass to `whenTrueFn` if necessary.
- * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`.
- * @see R.ifElse, R.unless, R.cond
- * @example
- *
- * // truncate :: String -> String
- * const truncate = R.when(
- * R.propSatisfies(R.gt(R.__, 10), 'length'),
- * R.pipe(R.take(10), R.append('…'), R.join(''))
- * );
- * truncate('12345'); //=> '12345'
- * truncate('0123456789ABC'); //=> '0123456789…'
- */
-var when = _curry3(function when(pred, whenTrueFn, x) {
- return pred(x) ? whenTrueFn(x) : x;
-});
+ /**
+ * Tests the final argument by passing it to the given predicate function. If
+ * the predicate is satisfied, the function will return the result of calling
+ * the `whenTrueFn` function with the same argument. If the predicate is not
+ * satisfied, the argument is returned as is.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.18.0
+ * @category Logic
+ * @sig (a -> Boolean) -> (a -> a) -> a -> a
+ * @param {Function} pred A predicate function
+ * @param {Function} whenTrueFn A function to invoke when the `condition`
+ * evaluates to a truthy value.
+ * @param {*} x An object to test with the `pred` function and
+ * pass to `whenTrueFn` if necessary.
+ * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`.
+ * @see R.ifElse, R.unless, R.cond
+ * @example
+ *
+ * // truncate :: String -> String
+ * const truncate = R.when(
+ * R.propSatisfies(R.gt(R.__, 10), 'length'),
+ * R.pipe(R.take(10), R.append('…'), R.join(''))
+ * );
+ * truncate('12345'); //=> '12345'
+ * truncate('0123456789ABC'); //=> '0123456789…'
+ */
+ var when = _curry3(function when(pred, whenTrueFn, x) {
+ return pred(x) ? whenTrueFn(x) : x;
+ });
-/**
- * Takes a spec object and a test object; returns true if the test satisfies
- * the spec. Each of the spec's own properties must be a predicate function.
- * Each predicate is applied to the value of the corresponding property of the
- * test object. `where` returns true if all the predicates return true, false
- * otherwise.
- *
- * `where` is well suited to declaratively expressing constraints for other
- * functions such as [`filter`](#filter) and [`find`](#find).
- *
- * @func
- * @memberOf R
- * @since v0.1.1
- * @category Object
- * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean
- * @param {Object} spec
- * @param {Object} testObj
- * @return {Boolean}
- * @see R.propSatisfies, R.whereEq
- * @example
- *
- * // pred :: Object -> Boolean
- * const pred = R.where({
- * a: R.equals('foo'),
- * b: R.complement(R.equals('bar')),
- * x: R.gt(R.__, 10),
- * y: R.lt(R.__, 20)
- * });
- *
- * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
- * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
- * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
- * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
- * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false
- */
-var where = _curry2(function where(spec, testObj) {
- for (var prop in spec) {
- if (_has(prop, spec) && !spec[prop](testObj[prop])) {
- return false;
+ /**
+ * Takes a spec object and a test object; returns true if the test satisfies
+ * the spec. Each of the spec's own properties must be a predicate function.
+ * Each predicate is applied to the value of the corresponding property of the
+ * test object. `where` returns true if all the predicates return true, false
+ * otherwise.
+ *
+ * `where` is well suited to declaratively expressing constraints for other
+ * functions such as [`filter`](#filter) and [`find`](#find).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.1
+ * @category Object
+ * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean
+ * @param {Object} spec
+ * @param {Object} testObj
+ * @return {Boolean}
+ * @see R.propSatisfies, R.whereEq
+ * @example
+ *
+ * // pred :: Object -> Boolean
+ * const pred = R.where({
+ * a: R.equals('foo'),
+ * b: R.complement(R.equals('bar')),
+ * x: R.gt(R.__, 10),
+ * y: R.lt(R.__, 20)
+ * });
+ *
+ * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
+ * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
+ * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
+ * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
+ * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false
+ */
+ var where = _curry2(function where(spec, testObj) {
+ for (var prop in spec) {
+ if (_has(prop, spec) && !spec[prop](testObj[prop])) {
+ return false;
+ }
}
- }
- return true;
-});
+ return true;
+ });
-/**
- * Takes a spec object and a test object; returns true if the test satisfies
- * the spec, false otherwise. An object satisfies the spec if, for each of the
- * spec's own properties, accessing that property of the object gives the same
- * value (in [`R.equals`](#equals) terms) as accessing that property of the
- * spec.
- *
- * `whereEq` is a specialization of [`where`](#where).
- *
- * @func
- * @memberOf R
- * @since v0.14.0
- * @category Object
- * @sig {String: *} -> {String: *} -> Boolean
- * @param {Object} spec
- * @param {Object} testObj
- * @return {Boolean}
- * @see R.propEq, R.where
- * @example
- *
- * // pred :: Object -> Boolean
- * const pred = R.whereEq({a: 1, b: 2});
- *
- * pred({a: 1}); //=> false
- * pred({a: 1, b: 2}); //=> true
- * pred({a: 1, b: 2, c: 3}); //=> true
- * pred({a: 1, b: 1}); //=> false
- */
-var whereEq = _curry2(function whereEq(spec, testObj) {
- return where(map(equals, spec), testObj);
-});
+ /**
+ * Takes a spec object and a test object; returns true if the test satisfies
+ * the spec, false otherwise. An object satisfies the spec if, for each of the
+ * spec's own properties, accessing that property of the object gives the same
+ * value (in [`R.equals`](#equals) terms) as accessing that property of the
+ * spec.
+ *
+ * `whereEq` is a specialization of [`where`](#where).
+ *
+ * @func
+ * @memberOf R
+ * @since v0.14.0
+ * @category Object
+ * @sig {String: *} -> {String: *} -> Boolean
+ * @param {Object} spec
+ * @param {Object} testObj
+ * @return {Boolean}
+ * @see R.propEq, R.where
+ * @example
+ *
+ * // pred :: Object -> Boolean
+ * const pred = R.whereEq({a: 1, b: 2});
+ *
+ * pred({a: 1}); //=> false
+ * pred({a: 1, b: 2}); //=> true
+ * pred({a: 1, b: 2, c: 3}); //=> true
+ * pred({a: 1, b: 1}); //=> false
+ */
+ var whereEq = _curry2(function whereEq(spec, testObj) {
+ return where(map(equals, spec), testObj);
+ });
-/**
- * Returns a new list without values in the first argument.
- * [`R.equals`](#equals) is used to determine equality.
- *
- * Acts as a transducer if a transformer is given in list position.
- *
- * @func
- * @memberOf R
- * @since v0.19.0
- * @category List
- * @sig [a] -> [a] -> [a]
- * @param {Array} list1 The values to be removed from `list2`.
- * @param {Array} list2 The array to remove values from.
- * @return {Array} The new array without values in `list1`.
- * @see R.transduce, R.difference, R.remove
- * @example
- *
- * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
- */
-var without = _curry2(function(xs, list) {
- return reject(flip(_includes)(xs), list);
-});
+ /**
+ * Returns a new list without values in the first argument.
+ * [`R.equals`](#equals) is used to determine equality.
+ *
+ * Acts as a transducer if a transformer is given in list position.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.19.0
+ * @category List
+ * @sig [a] -> [a] -> [a]
+ * @param {Array} list1 The values to be removed from `list2`.
+ * @param {Array} list2 The array to remove values from.
+ * @return {Array} The new array without values in `list1`.
+ * @see R.transduce, R.difference, R.remove
+ * @example
+ *
+ * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
+ */
+ var without = _curry2(function (xs, list) {
+ return reject(flip(_includes)(xs), list);
+ });
-/**
- * Creates a new list out of the two supplied by creating each possible pair
- * from the lists.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [b] -> [[a,b]]
- * @param {Array} as The first list.
- * @param {Array} bs The second list.
- * @return {Array} The list made by combining each possible pair from
- * `as` and `bs` into pairs (`[a, b]`).
- * @example
- *
- * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
- * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]]
- */
-var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...)
- var idx = 0;
- var ilen = a.length;
- var j;
- var jlen = b.length;
- var result = [];
- while (idx < ilen) {
- j = 0;
- while (j < jlen) {
- result[result.length] = [a[idx], b[j]];
- j += 1;
- }
- idx += 1;
- }
- return result;
-});
+ /**
+ * Creates a new list out of the two supplied by creating each possible pair
+ * from the lists.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [b] -> [[a,b]]
+ * @param {Array} as The first list.
+ * @param {Array} bs The second list.
+ * @return {Array} The list made by combining each possible pair from
+ * `as` and `bs` into pairs (`[a, b]`).
+ * @example
+ *
+ * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
+ * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]]
+ */
+ var xprod = _curry2(function xprod(a, b) {
+ // = xprodWith(prepend); (takes about 3 times as long...)
+ var idx = 0;
+ var ilen = a.length;
+ var j;
+ var jlen = b.length;
+ var result = [];
+ while (idx < ilen) {
+ j = 0;
+ while (j < jlen) {
+ result[result.length] = [a[idx], b[j]];
+ j += 1;
+ }
+ idx += 1;
+ }
+ return result;
+ });
-/**
- * Creates a new list out of the two supplied by pairing up equally-positioned
- * items from both lists. The returned list is truncated to the length of the
- * shorter of the two input lists.
- * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
- *
- * @func
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig [a] -> [b] -> [[a,b]]
- * @param {Array} list1 The first array to consider.
- * @param {Array} list2 The second array to consider.
- * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`.
- * @example
- *
- * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
- * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]]
- */
-var zip = _curry2(function zip(a, b) {
- var rv = [];
- var idx = 0;
- var len = Math.min(a.length, b.length);
- while (idx < len) {
- rv[idx] = [a[idx], b[idx]];
- idx += 1;
- }
- return rv;
-});
+ /**
+ * Creates a new list out of the two supplied by pairing up equally-positioned
+ * items from both lists. The returned list is truncated to the length of the
+ * shorter of the two input lists.
+ * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig [a] -> [b] -> [[a,b]]
+ * @param {Array} list1 The first array to consider.
+ * @param {Array} list2 The second array to consider.
+ * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`.
+ * @example
+ *
+ * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
+ * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]]
+ */
+ var zip = _curry2(function zip(a, b) {
+ var rv = [];
+ var idx = 0;
+ var len = Math.min(a.length, b.length);
+ while (idx < len) {
+ rv[idx] = [a[idx], b[idx]];
+ idx += 1;
+ }
+ return rv;
+ });
-/**
- * Creates a new object out of a list of keys and a list of values.
- * Key/value pairing is truncated to the length of the shorter of the two lists.
- * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`.
- *
- * @func
- * @memberOf R
- * @since v0.3.0
- * @category List
- * @sig [String] -> [*] -> {String: *}
- * @param {Array} keys The array that will be properties on the output object.
- * @param {Array} values The list of values on the output object.
- * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`.
- * @example
- *
- * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
- */
-var zipObj = _curry2(function zipObj(keys, values) {
- var idx = 0;
- var len = Math.min(keys.length, values.length);
- var out = {};
- while (idx < len) {
- out[keys[idx]] = values[idx];
- idx += 1;
- }
- return out;
-});
+ /**
+ * Creates a new object out of a list of keys and a list of values.
+ * Key/value pairing is truncated to the length of the shorter of the two lists.
+ * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`.
+ *
+ * @func
+ * @memberOf R
+ * @since v0.3.0
+ * @category List
+ * @sig [String] -> [*] -> {String: *}
+ * @param {Array} keys The array that will be properties on the output object.
+ * @param {Array} values The list of values on the output object.
+ * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`.
+ * @example
+ *
+ * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
+ */
+ var zipObj = _curry2(function zipObj(keys, values) {
+ var idx = 0;
+ var len = Math.min(keys.length, values.length);
+ var out = {};
+ while (idx < len) {
+ out[keys[idx]] = values[idx];
+ idx += 1;
+ }
+ return out;
+ });
-/**
- * Creates a new list out of the two supplied by applying the function to each
- * equally-positioned pair in the lists. The returned list is truncated to the
- * length of the shorter of the two input lists.
- *
- * @function
- * @memberOf R
- * @since v0.1.0
- * @category List
- * @sig ((a, b) -> c) -> [a] -> [b] -> [c]
- * @param {Function} fn The function used to combine the two elements into one value.
- * @param {Array} list1 The first array to consider.
- * @param {Array} list2 The second array to consider.
- * @return {Array} The list made by combining same-indexed elements of `list1` and `list2`
- * using `fn`.
- * @example
- *
- * const f = (x, y) => {
- * // ...
- * };
- * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
- * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]
- * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)]
- */
-var zipWith = _curry3(function zipWith(fn, a, b) {
- var rv = [];
- var idx = 0;
- var len = Math.min(a.length, b.length);
- while (idx < len) {
- rv[idx] = fn(a[idx], b[idx]);
- idx += 1;
- }
- return rv;
-});
+ /**
+ * Creates a new list out of the two supplied by applying the function to each
+ * equally-positioned pair in the lists. The returned list is truncated to the
+ * length of the shorter of the two input lists.
+ *
+ * @function
+ * @memberOf R
+ * @since v0.1.0
+ * @category List
+ * @sig ((a, b) -> c) -> [a] -> [b] -> [c]
+ * @param {Function} fn The function used to combine the two elements into one value.
+ * @param {Array} list1 The first array to consider.
+ * @param {Array} list2 The second array to consider.
+ * @return {Array} The list made by combining same-indexed elements of `list1` and `list2`
+ * using `fn`.
+ * @example
+ *
+ * const f = (x, y) => {
+ * // ...
+ * };
+ * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
+ * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]
+ * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)]
+ */
+ var zipWith = _curry3(function zipWith(fn, a, b) {
+ var rv = [];
+ var idx = 0;
+ var len = Math.min(a.length, b.length);
+ while (idx < len) {
+ rv[idx] = fn(a[idx], b[idx]);
+ idx += 1;
+ }
+ return rv;
+ });
-/**
- * Creates a thunk out of a function. A thunk delays a calculation until
- * its result is needed, providing lazy evaluation of arguments.
- *
- * @func
- * @memberOf R
- * @category Function
- * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k)
- * @param {Function} fn A function to wrap in a thunk
- * @return {Function} Expects arguments for `fn` and returns a new function
- * that, when called, applies those arguments to `fn`.
- * @see R.partial, R.partialRight
- * @example
- *
- * R.thunkify(R.identity)(42)(); //=> 42
- * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42
- */
-var thunkify = _curry1(function thunkify(fn) {
- return curryN(fn.length, function createThunk() {
- const fnArgs = arguments;
- return function invokeThunk() {
- return fn.apply(this, fnArgs);
- };
+ /**
+ * Creates a thunk out of a function. A thunk delays a calculation until
+ * its result is needed, providing lazy evaluation of arguments.
+ *
+ * @func
+ * @memberOf R
+ * @category Function
+ * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k)
+ * @param {Function} fn A function to wrap in a thunk
+ * @return {Function} Expects arguments for `fn` and returns a new function
+ * that, when called, applies those arguments to `fn`.
+ * @see R.partial, R.partialRight
+ * @example
+ *
+ * R.thunkify(R.identity)(42)(); //=> 42
+ * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42
+ */
+ var thunkify = _curry1(function thunkify(fn) {
+ return curryN(fn.length, function createThunk() {
+ const fnArgs = arguments;
+ return function invokeThunk() {
+ return fn.apply(this, fnArgs);
+ };
+ });
});
-});
-exports.F = F;
-exports.T = T;
-exports.__ = __;
-exports.add = add;
-exports.addIndex = addIndex;
-exports.adjust = adjust;
-exports.all = all;
-exports.allPass = allPass;
-exports.always = always;
-exports.and = and;
-exports.any = any;
-exports.anyPass = anyPass;
-exports.ap = ap;
-exports.aperture = aperture;
-exports.append = append;
-exports.apply = apply;
-exports.applySpec = applySpec;
-exports.applyTo = applyTo;
-exports.ascend = ascend;
-exports.assoc = assoc;
-exports.assocPath = assocPath;
-exports.binary = binary;
-exports.bind = bind;
-exports.both = both;
-exports.call = call;
-exports.chain = chain;
-exports.clamp = clamp;
-exports.clone = clone;
-exports.comparator = comparator;
-exports.complement = complement;
-exports.compose = compose;
-exports.composeK = composeK;
-exports.composeP = composeP;
-exports.composeWith = composeWith;
-exports.concat = concat;
-exports.cond = cond;
-exports.construct = construct;
-exports.constructN = constructN;
-exports.contains = contains$1;
-exports.converge = converge;
-exports.countBy = countBy;
-exports.curry = curry;
-exports.curryN = curryN;
-exports.dec = dec;
-exports.defaultTo = defaultTo;
-exports.descend = descend;
-exports.difference = difference;
-exports.differenceWith = differenceWith;
-exports.dissoc = dissoc;
-exports.dissocPath = dissocPath;
-exports.divide = divide;
-exports.drop = drop;
-exports.dropLast = dropLast;
-exports.dropLastWhile = dropLastWhile;
-exports.dropRepeats = dropRepeats;
-exports.dropRepeatsWith = dropRepeatsWith;
-exports.dropWhile = dropWhile;
-exports.either = either;
-exports.empty = empty;
-exports.endsWith = endsWith;
-exports.eqBy = eqBy;
-exports.eqProps = eqProps;
-exports.equals = equals;
-exports.evolve = evolve;
-exports.filter = filter;
-exports.find = find;
-exports.findIndex = findIndex;
-exports.findLast = findLast;
-exports.findLastIndex = findLastIndex;
-exports.flatten = flatten;
-exports.flip = flip;
-exports.forEach = forEach;
-exports.forEachObjIndexed = forEachObjIndexed;
-exports.fromPairs = fromPairs;
-exports.groupBy = groupBy;
-exports.groupWith = groupWith;
-exports.gt = gt;
-exports.gte = gte;
-exports.has = has;
-exports.hasIn = hasIn;
-exports.hasPath = hasPath;
-exports.head = head;
-exports.identical = identical;
-exports.identity = identity;
-exports.ifElse = ifElse;
-exports.inc = inc;
-exports.includes = includes;
-exports.indexBy = indexBy;
-exports.indexOf = indexOf;
-exports.init = init;
-exports.innerJoin = innerJoin;
-exports.insert = insert;
-exports.insertAll = insertAll;
-exports.intersection = intersection;
-exports.intersperse = intersperse;
-exports.into = into;
-exports.invert = invert;
-exports.invertObj = invertObj;
-exports.invoker = invoker;
-exports.is = is;
-exports.isEmpty = isEmpty;
-exports.isNil = isNil;
-exports.join = join;
-exports.juxt = juxt;
-exports.keys = keys;
-exports.keysIn = keysIn;
-exports.last = last;
-exports.lastIndexOf = lastIndexOf;
-exports.length = length;
-exports.lens = lens;
-exports.lensIndex = lensIndex;
-exports.lensPath = lensPath;
-exports.lensProp = lensProp;
-exports.lift = lift;
-exports.liftN = liftN;
-exports.lt = lt;
-exports.lte = lte;
-exports.map = map;
-exports.mapAccum = mapAccum;
-exports.mapAccumRight = mapAccumRight;
-exports.mapObjIndexed = mapObjIndexed;
-exports.match = match;
-exports.mathMod = mathMod;
-exports.max = max;
-exports.maxBy = maxBy;
-exports.mean = mean;
-exports.median = median;
-exports.memoizeWith = memoizeWith;
-exports.merge = merge;
-exports.mergeAll = mergeAll;
-exports.mergeDeepLeft = mergeDeepLeft;
-exports.mergeDeepRight = mergeDeepRight;
-exports.mergeDeepWith = mergeDeepWith;
-exports.mergeDeepWithKey = mergeDeepWithKey;
-exports.mergeLeft = mergeLeft;
-exports.mergeRight = mergeRight;
-exports.mergeWith = mergeWith;
-exports.mergeWithKey = mergeWithKey;
-exports.min = min;
-exports.minBy = minBy;
-exports.modulo = modulo;
-exports.multiply = multiply;
-exports.nAry = nAry;
-exports.negate = negate;
-exports.none = none;
-exports.not = not;
-exports.nth = nth;
-exports.nthArg = nthArg;
-exports.o = o;
-exports.objOf = objOf;
-exports.of = of;
-exports.omit = omit;
-exports.once = once;
-exports.or = or;
-exports.otherwise = otherwise;
-exports.over = over;
-exports.pair = pair;
-exports.partial = partial;
-exports.partialRight = partialRight;
-exports.partition = partition;
-exports.path = path;
-exports.pathEq = pathEq;
-exports.pathOr = pathOr;
-exports.pathSatisfies = pathSatisfies;
-exports.pick = pick;
-exports.pickAll = pickAll;
-exports.pickBy = pickBy;
-exports.pipe = pipe;
-exports.pipeK = pipeK;
-exports.pipeP = pipeP;
-exports.pipeWith = pipeWith;
-exports.pluck = pluck;
-exports.prepend = prepend;
-exports.product = product;
-exports.project = project;
-exports.prop = prop;
-exports.propEq = propEq;
-exports.propIs = propIs;
-exports.propOr = propOr;
-exports.propSatisfies = propSatisfies;
-exports.props = props;
-exports.range = range;
-exports.reduce = reduce;
-exports.reduceBy = reduceBy;
-exports.reduceRight = reduceRight;
-exports.reduceWhile = reduceWhile;
-exports.reduced = reduced;
-exports.reject = reject;
-exports.remove = remove;
-exports.repeat = repeat;
-exports.replace = replace;
-exports.reverse = reverse;
-exports.scan = scan;
-exports.sequence = sequence;
-exports.set = set;
-exports.slice = slice;
-exports.sort = sort;
-exports.sortBy = sortBy;
-exports.sortWith = sortWith;
-exports.split = split;
-exports.splitAt = splitAt;
-exports.splitEvery = splitEvery;
-exports.splitWhen = splitWhen;
-exports.startsWith = startsWith;
-exports.subtract = subtract;
-exports.sum = sum;
-exports.symmetricDifference = symmetricDifference;
-exports.symmetricDifferenceWith = symmetricDifferenceWith;
-exports.tail = tail;
-exports.take = take;
-exports.takeLast = takeLast;
-exports.takeLastWhile = takeLastWhile;
-exports.takeWhile = takeWhile;
-exports.tap = tap;
-exports.test = test;
-exports.then = then;
-exports.times = times;
-exports.toLower = toLower;
-exports.toPairs = toPairs;
-exports.toPairsIn = toPairsIn;
-exports.toString = toString$1;
-exports.toUpper = toUpper;
-exports.transduce = transduce;
-exports.transpose = transpose;
-exports.traverse = traverse;
-exports.trim = trim;
-exports.tryCatch = tryCatch;
-exports.type = type;
-exports.unapply = unapply;
-exports.unary = unary;
-exports.uncurryN = uncurryN;
-exports.unfold = unfold;
-exports.union = union;
-exports.unionWith = unionWith;
-exports.uniq = uniq;
-exports.uniqBy = uniqBy;
-exports.uniqWith = uniqWith;
-exports.unless = unless;
-exports.unnest = unnest;
-exports.until = until;
-exports.update = update;
-exports.useWith = useWith;
-exports.values = values;
-exports.valuesIn = valuesIn;
-exports.view = view;
-exports.when = when;
-exports.where = where;
-exports.whereEq = whereEq;
-exports.without = without;
-exports.xprod = xprod;
-exports.zip = zip;
-exports.zipObj = zipObj;
-exports.zipWith = zipWith;
-exports.thunkify = thunkify;
-
-Object.defineProperty(exports, '__esModule', { value: true });
-
-})));
+ exports.F = F;
+ exports.T = T;
+ exports.__ = __;
+ exports.add = add;
+ exports.addIndex = addIndex;
+ exports.adjust = adjust;
+ exports.all = all;
+ exports.allPass = allPass;
+ exports.always = always;
+ exports.and = and;
+ exports.any = any;
+ exports.anyPass = anyPass;
+ exports.ap = ap;
+ exports.aperture = aperture;
+ exports.append = append;
+ exports.apply = apply;
+ exports.applySpec = applySpec;
+ exports.applyTo = applyTo;
+ exports.ascend = ascend;
+ exports.assoc = assoc;
+ exports.assocPath = assocPath;
+ exports.binary = binary;
+ exports.bind = bind;
+ exports.both = both;
+ exports.call = call;
+ exports.chain = chain;
+ exports.clamp = clamp;
+ exports.clone = clone;
+ exports.comparator = comparator;
+ exports.complement = complement;
+ exports.compose = compose;
+ exports.composeK = composeK;
+ exports.composeP = composeP;
+ exports.composeWith = composeWith;
+ exports.concat = concat;
+ exports.cond = cond;
+ exports.construct = construct;
+ exports.constructN = constructN;
+ exports.contains = contains$1;
+ exports.converge = converge;
+ exports.countBy = countBy;
+ exports.curry = curry;
+ exports.curryN = curryN;
+ exports.dec = dec;
+ exports.defaultTo = defaultTo;
+ exports.descend = descend;
+ exports.difference = difference;
+ exports.differenceWith = differenceWith;
+ exports.dissoc = dissoc;
+ exports.dissocPath = dissocPath;
+ exports.divide = divide;
+ exports.drop = drop;
+ exports.dropLast = dropLast;
+ exports.dropLastWhile = dropLastWhile;
+ exports.dropRepeats = dropRepeats;
+ exports.dropRepeatsWith = dropRepeatsWith;
+ exports.dropWhile = dropWhile;
+ exports.either = either;
+ exports.empty = empty;
+ exports.endsWith = endsWith;
+ exports.eqBy = eqBy;
+ exports.eqProps = eqProps;
+ exports.equals = equals;
+ exports.evolve = evolve;
+ exports.filter = filter;
+ exports.find = find;
+ exports.findIndex = findIndex;
+ exports.findLast = findLast;
+ exports.findLastIndex = findLastIndex;
+ exports.flatten = flatten;
+ exports.flip = flip;
+ exports.forEach = forEach;
+ exports.forEachObjIndexed = forEachObjIndexed;
+ exports.fromPairs = fromPairs;
+ exports.groupBy = groupBy;
+ exports.groupWith = groupWith;
+ exports.gt = gt;
+ exports.gte = gte;
+ exports.has = has;
+ exports.hasIn = hasIn;
+ exports.hasPath = hasPath;
+ exports.head = head;
+ exports.identical = identical;
+ exports.identity = identity;
+ exports.ifElse = ifElse;
+ exports.inc = inc;
+ exports.includes = includes;
+ exports.indexBy = indexBy;
+ exports.indexOf = indexOf;
+ exports.init = init;
+ exports.innerJoin = innerJoin;
+ exports.insert = insert;
+ exports.insertAll = insertAll;
+ exports.intersection = intersection;
+ exports.intersperse = intersperse;
+ exports.into = into;
+ exports.invert = invert;
+ exports.invertObj = invertObj;
+ exports.invoker = invoker;
+ exports.is = is;
+ exports.isEmpty = isEmpty;
+ exports.isNil = isNil;
+ exports.join = join;
+ exports.juxt = juxt;
+ exports.keys = keys;
+ exports.keysIn = keysIn;
+ exports.last = last;
+ exports.lastIndexOf = lastIndexOf;
+ exports.length = length;
+ exports.lens = lens;
+ exports.lensIndex = lensIndex;
+ exports.lensPath = lensPath;
+ exports.lensProp = lensProp;
+ exports.lift = lift;
+ exports.liftN = liftN;
+ exports.lt = lt;
+ exports.lte = lte;
+ exports.map = map;
+ exports.mapAccum = mapAccum;
+ exports.mapAccumRight = mapAccumRight;
+ exports.mapObjIndexed = mapObjIndexed;
+ exports.match = match;
+ exports.mathMod = mathMod;
+ exports.max = max;
+ exports.maxBy = maxBy;
+ exports.mean = mean;
+ exports.median = median;
+ exports.memoizeWith = memoizeWith;
+ exports.merge = merge;
+ exports.mergeAll = mergeAll;
+ exports.mergeDeepLeft = mergeDeepLeft;
+ exports.mergeDeepRight = mergeDeepRight;
+ exports.mergeDeepWith = mergeDeepWith;
+ exports.mergeDeepWithKey = mergeDeepWithKey;
+ exports.mergeLeft = mergeLeft;
+ exports.mergeRight = mergeRight;
+ exports.mergeWith = mergeWith;
+ exports.mergeWithKey = mergeWithKey;
+ exports.min = min;
+ exports.minBy = minBy;
+ exports.modulo = modulo;
+ exports.multiply = multiply;
+ exports.nAry = nAry;
+ exports.negate = negate;
+ exports.none = none;
+ exports.not = not;
+ exports.nth = nth;
+ exports.nthArg = nthArg;
+ exports.o = o;
+ exports.objOf = objOf;
+ exports.of = of;
+ exports.omit = omit;
+ exports.once = once;
+ exports.or = or;
+ exports.otherwise = otherwise;
+ exports.over = over;
+ exports.pair = pair;
+ exports.partial = partial;
+ exports.partialRight = partialRight;
+ exports.partition = partition;
+ exports.path = path;
+ exports.pathEq = pathEq;
+ exports.pathOr = pathOr;
+ exports.pathSatisfies = pathSatisfies;
+ exports.pick = pick;
+ exports.pickAll = pickAll;
+ exports.pickBy = pickBy;
+ exports.pipe = pipe;
+ exports.pipeK = pipeK;
+ exports.pipeP = pipeP;
+ exports.pipeWith = pipeWith;
+ exports.pluck = pluck;
+ exports.prepend = prepend;
+ exports.product = product;
+ exports.project = project;
+ exports.prop = prop;
+ exports.propEq = propEq;
+ exports.propIs = propIs;
+ exports.propOr = propOr;
+ exports.propSatisfies = propSatisfies;
+ exports.props = props;
+ exports.range = range;
+ exports.reduce = reduce;
+ exports.reduceBy = reduceBy;
+ exports.reduceRight = reduceRight;
+ exports.reduceWhile = reduceWhile;
+ exports.reduced = reduced;
+ exports.reject = reject;
+ exports.remove = remove;
+ exports.repeat = repeat;
+ exports.replace = replace;
+ exports.reverse = reverse;
+ exports.scan = scan;
+ exports.sequence = sequence;
+ exports.set = set;
+ exports.slice = slice;
+ exports.sort = sort;
+ exports.sortBy = sortBy;
+ exports.sortWith = sortWith;
+ exports.split = split;
+ exports.splitAt = splitAt;
+ exports.splitEvery = splitEvery;
+ exports.splitWhen = splitWhen;
+ exports.startsWith = startsWith;
+ exports.subtract = subtract;
+ exports.sum = sum;
+ exports.symmetricDifference = symmetricDifference;
+ exports.symmetricDifferenceWith = symmetricDifferenceWith;
+ exports.tail = tail;
+ exports.take = take;
+ exports.takeLast = takeLast;
+ exports.takeLastWhile = takeLastWhile;
+ exports.takeWhile = takeWhile;
+ exports.tap = tap;
+ exports.test = test;
+ exports.then = then;
+ exports.times = times;
+ exports.toLower = toLower;
+ exports.toPairs = toPairs;
+ exports.toPairsIn = toPairsIn;
+ exports.toString = toString$1;
+ exports.toUpper = toUpper;
+ exports.transduce = transduce;
+ exports.transpose = transpose;
+ exports.traverse = traverse;
+ exports.trim = trim;
+ exports.tryCatch = tryCatch;
+ exports.type = type;
+ exports.unapply = unapply;
+ exports.unary = unary;
+ exports.uncurryN = uncurryN;
+ exports.unfold = unfold;
+ exports.union = union;
+ exports.unionWith = unionWith;
+ exports.uniq = uniq;
+ exports.uniqBy = uniqBy;
+ exports.uniqWith = uniqWith;
+ exports.unless = unless;
+ exports.unnest = unnest;
+ exports.until = until;
+ exports.update = update;
+ exports.useWith = useWith;
+ exports.values = values;
+ exports.valuesIn = valuesIn;
+ exports.view = view;
+ exports.when = when;
+ exports.where = where;
+ exports.whereEq = whereEq;
+ exports.without = without;
+ exports.xprod = xprod;
+ exports.zip = zip;
+ exports.zipObj = zipObj;
+ exports.zipWith = zipWith;
+ exports.thunkify = thunkify;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+});
diff --git a/shims/xml-js.js b/shims/xml-js.js
index 5a0baa3..641b2c7 100644
--- a/shims/xml-js.js
+++ b/shims/xml-js.js
@@ -1,392 +1,412 @@
-(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, {
-/******/ configurable: false,
-/******/ enumerable: true,
-/******/ get: getter
-/******/ });
-/******/ }
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 21);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// a duplex stream is just a stream that is both readable and writable.
-// Since JS doesn't have multiple prototypal inheritance, this class
-// prototypally inherits from Readable, and then parasitically from
-// Writable.
-
-
-
-/**/
-
-var processNextTick = __webpack_require__(6);
-/**/
-
-/**/
-var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- keys.push(key);
- }return keys;
-};
-/**/
-
-module.exports = Duplex;
-
-/**/
-var util = __webpack_require__(3);
-util.inherits = __webpack_require__(1);
-/**/
-
-var Readable = __webpack_require__(16);
-var Writable = __webpack_require__(10);
-
-util.inherits(Duplex, Readable);
-
-var keys = objectKeys(Writable.prototype);
-for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
-}
-
-function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
-
- Readable.call(this, options);
- Writable.call(this, options);
-
- if (options && options.readable === false) this.readable = false;
-
- if (options && options.writable === false) this.writable = false;
-
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
-
- this.once('end', onend);
-}
-
-// the no-half-open enforcer
-function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended) return;
-
- // no more data can be written.
- // But allow more writes to happen in this tick.
- processNextTick(onEndNT, this);
-}
-
-function onEndNT(self) {
- self.end();
-}
-
-Object.defineProperty(Duplex.prototype, 'destroyed', {
- get: function () {
- if (this._readableState === undefined || this._writableState === undefined) {
- return false;
- }
- return this._readableState.destroyed && this._writableState.destroyed;
- },
- set: function (value) {
- // we ignore the value if the stream
- // has not been initialized yet
- if (this._readableState === undefined || this._writableState === undefined) {
- return;
- }
-
- // backward compatibility, the user is explicitly
- // managing destroyed
- this._readableState.destroyed = value;
- this._writableState.destroyed = value;
- }
-});
-
-Duplex.prototype._destroy = function (err, cb) {
- this.push(null);
- this.end();
-
- processNextTick(cb, err);
-};
-
-function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
-}
-
-/***/ }),
-/* 1 */
-/***/ (function(module, exports) {
-
-if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
+(function (e, a) {
+ for (var i in a) e[i] = a[i];
+})(
+ window,
+ /******/ (function (modules) {
+ // webpackBootstrap
+ /******/ // The module cache
+ /******/ var installedModules = {};
+ /******/
+ /******/ // The require function
+ /******/ function __webpack_require__(moduleId) {
+ /******/
+ /******/ // Check if module is in cache
+ /******/ if (installedModules[moduleId]) {
+ /******/ return installedModules[moduleId].exports;
+ /******/
}
- });
- };
-} else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
-}
-
-
-/***/ }),
-/* 2 */
-/***/ (function(module, exports) {
-
-var g;
-
-// This works in non-strict mode
-g = (function() {
- return this;
-})();
-
-try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
-} catch(e) {
- // This works if the window reference is available
- if(typeof window === "object")
- g = window;
-}
-
-// g can still be undefined, but nothing to do about it...
-// We return undefined, instead of nothing here, so it's
-// easier to handle this case. if(!global) { ...}
-
-module.exports = g;
-
-
-/***/ }),
-/* 3 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// NOTE: These type checking functions intentionally don't use `instanceof`
-// because it is fragile and can be easily faked with `Object.create()`.
-
-function isArray(arg) {
- if (Array.isArray) {
- return Array.isArray(arg);
- }
- return objectToString(arg) === '[object Array]';
-}
-exports.isArray = isArray;
-
-function isBoolean(arg) {
- return typeof arg === 'boolean';
-}
-exports.isBoolean = isBoolean;
-
-function isNull(arg) {
- return arg === null;
-}
-exports.isNull = isNull;
-
-function isNullOrUndefined(arg) {
- return arg == null;
-}
-exports.isNullOrUndefined = isNullOrUndefined;
-
-function isNumber(arg) {
- return typeof arg === 'number';
-}
-exports.isNumber = isNumber;
-
-function isString(arg) {
- return typeof arg === 'string';
-}
-exports.isString = isString;
-
-function isSymbol(arg) {
- return typeof arg === 'symbol';
-}
-exports.isSymbol = isSymbol;
-
-function isUndefined(arg) {
- return arg === void 0;
-}
-exports.isUndefined = isUndefined;
-
-function isRegExp(re) {
- return objectToString(re) === '[object RegExp]';
-}
-exports.isRegExp = isRegExp;
-
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
-exports.isObject = isObject;
-
-function isDate(d) {
- return objectToString(d) === '[object Date]';
-}
-exports.isDate = isDate;
-
-function isError(e) {
- return (objectToString(e) === '[object Error]' || e instanceof Error);
-}
-exports.isError = isError;
-
-function isFunction(arg) {
- return typeof arg === 'function';
-}
-exports.isFunction = isFunction;
-
-function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
-}
-exports.isPrimitive = isPrimitive;
-
-exports.isBuffer = Buffer.isBuffer;
-
-function objectToString(o) {
- return Object.prototype.toString.call(o);
-}
-
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4).Buffer))
-
-/***/ }),
-/* 4 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(global) {/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh
- * @license MIT
- */
-/* eslint-disable no-proto */
+ /******/ // Create a new module (and put it into the cache)
+ /******/ var module = (installedModules[moduleId] = {
+ /******/ i: moduleId,
+ /******/ l: false,
+ /******/ exports: {},
+ /******/
+ });
+ /******/
+ /******/ // Execute the module function
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+ /******/
+ /******/ // Flag the module as loaded
+ /******/ module.l = true;
+ /******/
+ /******/ // Return the exports of the module
+ /******/ return module.exports;
+ /******/
+ }
+ /******/
+ /******/
+ /******/ // expose the modules object (__webpack_modules__)
+ /******/ __webpack_require__.m = modules;
+ /******/
+ /******/ // expose the module cache
+ /******/ __webpack_require__.c = installedModules;
+ /******/
+ /******/ // define getter function for harmony exports
+ /******/ __webpack_require__.d = function (exports, name, getter) {
+ /******/ if (!__webpack_require__.o(exports, name)) {
+ /******/ Object.defineProperty(exports, name, {
+ /******/ configurable: false,
+ /******/ enumerable: true,
+ /******/ get: getter,
+ /******/
+ });
+ /******/
+ }
+ /******/
+ };
+ /******/
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
+ /******/ __webpack_require__.n = function (module) {
+ /******/ var getter =
+ module && module.__esModule
+ ? /******/ function getDefault() {
+ return module['default'];
+ }
+ : /******/ function getModuleExports() {
+ return module;
+ };
+ /******/ __webpack_require__.d(getter, 'a', getter);
+ /******/ return getter;
+ /******/
+ };
+ /******/
+ /******/ // Object.prototype.hasOwnProperty.call
+ /******/ __webpack_require__.o = function (object, property) {
+ return Object.prototype.hasOwnProperty.call(object, property);
+ };
+ /******/
+ /******/ // __webpack_public_path__
+ /******/ __webpack_require__.p = '';
+ /******/
+ /******/ // Load entry module and return exports
+ /******/ return __webpack_require__((__webpack_require__.s = 21));
+ /******/
+ })(
+ /************************************************************************/
+ /******/ [
+ /* 0 */
+ /***/ function (module, exports, __webpack_require__) {
+ 'use strict';
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a
+ // copy of this software and associated documentation files (the
+ // "Software"), to deal in the Software without restriction, including
+ // without limitation the rights to use, copy, modify, merge, publish,
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
+ // persons to whom the Software is furnished to do so, subject to the
+ // following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included
+ // in all copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ // a duplex stream is just a stream that is both readable and writable.
+ // Since JS doesn't have multiple prototypal inheritance, this class
+ // prototypally inherits from Readable, and then parasitically from
+ // Writable.
+
+ /**/
+
+ var processNextTick = __webpack_require__(6);
+ /**/
+
+ /**/
+ var objectKeys =
+ Object.keys ||
+ function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ keys.push(key);
+ }
+ return keys;
+ };
+ /**/
+
+ module.exports = Duplex;
+
+ /**/
+ var util = __webpack_require__(3);
+ util.inherits = __webpack_require__(1);
+ /**/
+
+ var Readable = __webpack_require__(16);
+ var Writable = __webpack_require__(10);
+
+ util.inherits(Duplex, Readable);
+
+ var keys = objectKeys(Writable.prototype);
+ for (var v = 0; v < keys.length; v++) {
+ var method = keys[v];
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
+ }
+
+ function Duplex(options) {
+ if (!(this instanceof Duplex)) return new Duplex(options);
+
+ Readable.call(this, options);
+ Writable.call(this, options);
+
+ if (options && options.readable === false) this.readable = false;
+
+ if (options && options.writable === false) this.writable = false;
+
+ this.allowHalfOpen = true;
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
+
+ this.once('end', onend);
+ }
+
+ // the no-half-open enforcer
+ function onend() {
+ // if we allow half-open state, or if the writable side ended,
+ // then we're ok.
+ if (this.allowHalfOpen || this._writableState.ended) return;
+
+ // no more data can be written.
+ // But allow more writes to happen in this tick.
+ processNextTick(onEndNT, this);
+ }
+
+ function onEndNT(self) {
+ self.end();
+ }
+
+ Object.defineProperty(Duplex.prototype, 'destroyed', {
+ get: function () {
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return false;
+ }
+ return this._readableState.destroyed && this._writableState.destroyed;
+ },
+ set: function (value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._readableState.destroyed = value;
+ this._writableState.destroyed = value;
+ },
+ });
+
+ Duplex.prototype._destroy = function (err, cb) {
+ this.push(null);
+ this.end();
+
+ processNextTick(cb, err);
+ };
+
+ function forEach(xs, f) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ f(xs[i], i);
+ }
+ }
+
+ /***/
+ },
+ /* 1 */
+ /***/ function (module, exports) {
+ if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ },
+ });
+ };
+ } else {
+ // old school shim for old browsers
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ };
+ }
+
+ /***/
+ },
+ /* 2 */
+ /***/ function (module, exports) {
+ var g;
+
+ // This works in non-strict mode
+ g = (function () {
+ return this;
+ })();
+
+ try {
+ // This works if eval is allowed (see CSP)
+ g = g || Function('return this')() || (1, eval)('this');
+ } catch (e) {
+ // This works if the window reference is available
+ if (typeof window === 'object') g = window;
+ }
+
+ // g can still be undefined, but nothing to do about it...
+ // We return undefined, instead of nothing here, so it's
+ // easier to handle this case. if(!global) { ...}
+
+ module.exports = g;
+
+ /***/
+ },
+ /* 3 */
+ /***/ function (module, exports, __webpack_require__) {
+ /* WEBPACK VAR INJECTION */ (function (Buffer) {
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a
+ // copy of this software and associated documentation files (the
+ // "Software"), to deal in the Software without restriction, including
+ // without limitation the rights to use, copy, modify, merge, publish,
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
+ // persons to whom the Software is furnished to do so, subject to the
+ // following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included
+ // in all copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ // NOTE: These type checking functions intentionally don't use `instanceof`
+ // because it is fragile and can be easily faked with `Object.create()`.
+
+ function isArray(arg) {
+ if (Array.isArray) {
+ return Array.isArray(arg);
+ }
+ return objectToString(arg) === '[object Array]';
+ }
+ exports.isArray = isArray;
+
+ function isBoolean(arg) {
+ return typeof arg === 'boolean';
+ }
+ exports.isBoolean = isBoolean;
+
+ function isNull(arg) {
+ return arg === null;
+ }
+ exports.isNull = isNull;
+
+ function isNullOrUndefined(arg) {
+ return arg == null;
+ }
+ exports.isNullOrUndefined = isNullOrUndefined;
+
+ function isNumber(arg) {
+ return typeof arg === 'number';
+ }
+ exports.isNumber = isNumber;
+
+ function isString(arg) {
+ return typeof arg === 'string';
+ }
+ exports.isString = isString;
+
+ function isSymbol(arg) {
+ return typeof arg === 'symbol';
+ }
+ exports.isSymbol = isSymbol;
+
+ function isUndefined(arg) {
+ return arg === void 0;
+ }
+ exports.isUndefined = isUndefined;
+
+ function isRegExp(re) {
+ return objectToString(re) === '[object RegExp]';
+ }
+ exports.isRegExp = isRegExp;
+
+ function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+ }
+ exports.isObject = isObject;
+
+ function isDate(d) {
+ return objectToString(d) === '[object Date]';
+ }
+ exports.isDate = isDate;
+ function isError(e) {
+ return objectToString(e) === '[object Error]' || e instanceof Error;
+ }
+ exports.isError = isError;
+ function isFunction(arg) {
+ return typeof arg === 'function';
+ }
+ exports.isFunction = isFunction;
+
+ function isPrimitive(arg) {
+ return (
+ arg === null ||
+ typeof arg === 'boolean' ||
+ typeof arg === 'number' ||
+ typeof arg === 'string' ||
+ typeof arg === 'symbol' || // ES6 symbol
+ typeof arg === 'undefined'
+ );
+ }
+ exports.isPrimitive = isPrimitive;
-var base64 = __webpack_require__(23)
-var ieee754 = __webpack_require__(24)
-var isArray = __webpack_require__(15)
+ exports.isBuffer = Buffer.isBuffer;
-exports.Buffer = Buffer
-exports.SlowBuffer = SlowBuffer
-exports.INSPECT_MAX_BYTES = 50
+ function objectToString(o) {
+ return Object.prototype.toString.call(o);
+ }
-/**
+ /* WEBPACK VAR INJECTION */
+ }.call(exports, __webpack_require__(4).Buffer));
+
+ /***/
+ },
+ /* 4 */
+ /***/ function (module, exports, __webpack_require__) {
+ 'use strict';
+ /* WEBPACK VAR INJECTION */ (function (global) {
+ /*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+ /* eslint-disable no-proto */
+
+ var base64 = __webpack_require__(23);
+ var ieee754 = __webpack_require__(24);
+ var isArray = __webpack_require__(15);
+
+ exports.Buffer = Buffer;
+ exports.SlowBuffer = SlowBuffer;
+ exports.INSPECT_MAX_BYTES = 50;
+
+ /**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Use Object implementation (most compatible, even IE6)
@@ -410,7901 +430,8044 @@ exports.INSPECT_MAX_BYTES = 50
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
* get the Object implementation, which is slower but behaves correctly.
*/
-Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
- ? global.TYPED_ARRAY_SUPPORT
- : typedArraySupport()
-
-/*
- * Export kMaxLength after typed array support is determined.
- */
-exports.kMaxLength = kMaxLength()
-
-function typedArraySupport () {
- try {
- var arr = new Uint8Array(1)
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
- return arr.foo() === 42 && // typed array instances can be augmented
- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
- arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
- } catch (e) {
- return false
- }
-}
-
-function kMaxLength () {
- return Buffer.TYPED_ARRAY_SUPPORT
- ? 0x7fffffff
- : 0x3fffffff
-}
-
-function createBuffer (that, length) {
- if (kMaxLength() < length) {
- throw new RangeError('Invalid typed array length')
- }
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- // Return an augmented `Uint8Array` instance, for best performance
- that = new Uint8Array(length)
- that.__proto__ = Buffer.prototype
- } else {
- // Fallback: Return an object instance of the Buffer class
- if (that === null) {
- that = new Buffer(length)
- }
- that.length = length
- }
-
- return that
-}
-
-/**
- * The Buffer constructor returns instances of `Uint8Array` that have their
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
- * returns a single octet.
- *
- * The `Uint8Array` prototype remains unmodified.
- */
+ Buffer.TYPED_ARRAY_SUPPORT =
+ global.TYPED_ARRAY_SUPPORT !== undefined ? global.TYPED_ARRAY_SUPPORT : typedArraySupport();
+
+ /*
+ * Export kMaxLength after typed array support is determined.
+ */
+ exports.kMaxLength = kMaxLength();
+
+ function typedArraySupport() {
+ try {
+ var arr = new Uint8Array(1);
+ arr.__proto__ = {
+ __proto__: Uint8Array.prototype,
+ foo: function () {
+ return 42;
+ },
+ };
+ return (
+ arr.foo() === 42 && // typed array instances can be augmented
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
+ arr.subarray(1, 1).byteLength === 0
+ ); // ie10 has broken `subarray`
+ } catch (e) {
+ return false;
+ }
+ }
-function Buffer (arg, encodingOrOffset, length) {
- if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
- return new Buffer(arg, encodingOrOffset, length)
- }
-
- // Common case.
- if (typeof arg === 'number') {
- if (typeof encodingOrOffset === 'string') {
- throw new Error(
- 'If encoding is specified then the first argument must be a string'
- )
- }
- return allocUnsafe(this, arg)
- }
- return from(this, arg, encodingOrOffset, length)
-}
-
-Buffer.poolSize = 8192 // not used by this implementation
-
-// TODO: Legacy, not needed anymore. Remove in next major version.
-Buffer._augment = function (arr) {
- arr.__proto__ = Buffer.prototype
- return arr
-}
-
-function from (that, value, encodingOrOffset, length) {
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number')
- }
-
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
- return fromArrayBuffer(that, value, encodingOrOffset, length)
- }
-
- if (typeof value === 'string') {
- return fromString(that, value, encodingOrOffset)
- }
-
- return fromObject(that, value)
-}
-
-/**
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
- * if value is a number.
- * Buffer.from(str[, encoding])
- * Buffer.from(array)
- * Buffer.from(buffer)
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
- **/
-Buffer.from = function (value, encodingOrOffset, length) {
- return from(null, value, encodingOrOffset, length)
-}
-
-if (Buffer.TYPED_ARRAY_SUPPORT) {
- Buffer.prototype.__proto__ = Uint8Array.prototype
- Buffer.__proto__ = Uint8Array
- if (typeof Symbol !== 'undefined' && Symbol.species &&
- Buffer[Symbol.species] === Buffer) {
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
- Object.defineProperty(Buffer, Symbol.species, {
- value: null,
- configurable: true
- })
- }
-}
-
-function assertSize (size) {
- if (typeof size !== 'number') {
- throw new TypeError('"size" argument must be a number')
- } else if (size < 0) {
- throw new RangeError('"size" argument must not be negative')
- }
-}
-
-function alloc (that, size, fill, encoding) {
- assertSize(size)
- if (size <= 0) {
- return createBuffer(that, size)
- }
- if (fill !== undefined) {
- // Only pay attention to encoding if it's a string. This
- // prevents accidentally sending in a number that would
- // be interpretted as a start offset.
- return typeof encoding === 'string'
- ? createBuffer(that, size).fill(fill, encoding)
- : createBuffer(that, size).fill(fill)
- }
- return createBuffer(that, size)
-}
-
-/**
- * Creates a new filled Buffer instance.
- * alloc(size[, fill[, encoding]])
- **/
-Buffer.alloc = function (size, fill, encoding) {
- return alloc(null, size, fill, encoding)
-}
-
-function allocUnsafe (that, size) {
- assertSize(size)
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
- if (!Buffer.TYPED_ARRAY_SUPPORT) {
- for (var i = 0; i < size; ++i) {
- that[i] = 0
- }
- }
- return that
-}
-
-/**
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
- * */
-Buffer.allocUnsafe = function (size) {
- return allocUnsafe(null, size)
-}
-/**
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
- */
-Buffer.allocUnsafeSlow = function (size) {
- return allocUnsafe(null, size)
-}
-
-function fromString (that, string, encoding) {
- if (typeof encoding !== 'string' || encoding === '') {
- encoding = 'utf8'
- }
-
- if (!Buffer.isEncoding(encoding)) {
- throw new TypeError('"encoding" must be a valid string encoding')
- }
-
- var length = byteLength(string, encoding) | 0
- that = createBuffer(that, length)
-
- var actual = that.write(string, encoding)
-
- if (actual !== length) {
- // Writing a hex string, for example, that contains invalid characters will
- // cause everything after the first invalid character to be ignored. (e.g.
- // 'abxxcd' will be treated as 'ab')
- that = that.slice(0, actual)
- }
-
- return that
-}
-
-function fromArrayLike (that, array) {
- var length = array.length < 0 ? 0 : checked(array.length) | 0
- that = createBuffer(that, length)
- for (var i = 0; i < length; i += 1) {
- that[i] = array[i] & 255
- }
- return that
-}
-
-function fromArrayBuffer (that, array, byteOffset, length) {
- array.byteLength // this throws if `array` is not a valid ArrayBuffer
-
- if (byteOffset < 0 || array.byteLength < byteOffset) {
- throw new RangeError('\'offset\' is out of bounds')
- }
-
- if (array.byteLength < byteOffset + (length || 0)) {
- throw new RangeError('\'length\' is out of bounds')
- }
-
- if (byteOffset === undefined && length === undefined) {
- array = new Uint8Array(array)
- } else if (length === undefined) {
- array = new Uint8Array(array, byteOffset)
- } else {
- array = new Uint8Array(array, byteOffset, length)
- }
-
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- // Return an augmented `Uint8Array` instance, for best performance
- that = array
- that.__proto__ = Buffer.prototype
- } else {
- // Fallback: Return an object instance of the Buffer class
- that = fromArrayLike(that, array)
- }
- return that
-}
-
-function fromObject (that, obj) {
- if (Buffer.isBuffer(obj)) {
- var len = checked(obj.length) | 0
- that = createBuffer(that, len)
-
- if (that.length === 0) {
- return that
- }
+ function kMaxLength() {
+ return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff;
+ }
- obj.copy(that, 0, 0, len)
- return that
- }
+ function createBuffer(that, length) {
+ if (kMaxLength() < length) {
+ throw new RangeError('Invalid typed array length');
+ }
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ // Return an augmented `Uint8Array` instance, for best performance
+ that = new Uint8Array(length);
+ that.__proto__ = Buffer.prototype;
+ } else {
+ // Fallback: Return an object instance of the Buffer class
+ if (that === null) {
+ that = new Buffer(length);
+ }
+ that.length = length;
+ }
- if (obj) {
- if ((typeof ArrayBuffer !== 'undefined' &&
- obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
- return createBuffer(that, 0)
- }
- return fromArrayLike(that, obj)
- }
+ return that;
+ }
- if (obj.type === 'Buffer' && isArray(obj.data)) {
- return fromArrayLike(that, obj.data)
- }
- }
-
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
-}
-
-function checked (length) {
- // Note: cannot use `length < kMaxLength()` here because that fails when
- // length is NaN (which is otherwise coerced to zero.)
- if (length >= kMaxLength()) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + kMaxLength().toString(16) + ' bytes')
- }
- return length | 0
-}
-
-function SlowBuffer (length) {
- if (+length != length) { // eslint-disable-line eqeqeq
- length = 0
- }
- return Buffer.alloc(+length)
-}
-
-Buffer.isBuffer = function isBuffer (b) {
- return !!(b != null && b._isBuffer)
-}
-
-Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
-
- if (a === b) return 0
-
- var x = a.length
- var y = b.length
-
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i]
- y = b[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
-}
-
-Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'latin1':
- case 'binary':
- case 'base64':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
-}
-
-Buffer.concat = function concat (list, length) {
- if (!isArray(list)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
-
- if (list.length === 0) {
- return Buffer.alloc(0)
- }
-
- var i
- if (length === undefined) {
- length = 0
- for (i = 0; i < list.length; ++i) {
- length += list[i].length
- }
- }
-
- var buffer = Buffer.allocUnsafe(length)
- var pos = 0
- for (i = 0; i < list.length; ++i) {
- var buf = list[i]
- if (!Buffer.isBuffer(buf)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- buf.copy(buffer, pos)
- pos += buf.length
- }
- return buffer
-}
-
-function byteLength (string, encoding) {
- if (Buffer.isBuffer(string)) {
- return string.length
- }
- if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
- (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
- return string.byteLength
- }
- if (typeof string !== 'string') {
- string = '' + string
- }
-
- var len = string.length
- if (len === 0) return 0
-
- // Use a for loop to avoid recursion
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'ascii':
- case 'latin1':
- case 'binary':
- return len
- case 'utf8':
- case 'utf-8':
- case undefined:
- return utf8ToBytes(string).length
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return len * 2
- case 'hex':
- return len >>> 1
- case 'base64':
- return base64ToBytes(string).length
- default:
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
-}
-Buffer.byteLength = byteLength
-
-function slowToString (encoding, start, end) {
- var loweredCase = false
-
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
- // property of a typed array.
-
- // This behaves neither like String nor Uint8Array in that we set start/end
- // to their upper/lower bounds if the value passed is out of range.
- // undefined is handled specially as per ECMA-262 6th Edition,
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
- if (start === undefined || start < 0) {
- start = 0
- }
- // Return early if start > this.length. Done here to prevent potential uint32
- // coercion fail below.
- if (start > this.length) {
- return ''
- }
-
- if (end === undefined || end > this.length) {
- end = this.length
- }
-
- if (end <= 0) {
- return ''
- }
-
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
- end >>>= 0
- start >>>= 0
-
- if (end <= start) {
- return ''
- }
-
- if (!encoding) encoding = 'utf8'
-
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
-
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
-
- case 'ascii':
- return asciiSlice(this, start, end)
-
- case 'latin1':
- case 'binary':
- return latin1Slice(this, start, end)
-
- case 'base64':
- return base64Slice(this, start, end)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
-}
-
-// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
-// Buffer instances.
-Buffer.prototype._isBuffer = true
-
-function swap (b, n, m) {
- var i = b[n]
- b[n] = b[m]
- b[m] = i
-}
-
-Buffer.prototype.swap16 = function swap16 () {
- var len = this.length
- if (len % 2 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 16-bits')
- }
- for (var i = 0; i < len; i += 2) {
- swap(this, i, i + 1)
- }
- return this
-}
-
-Buffer.prototype.swap32 = function swap32 () {
- var len = this.length
- if (len % 4 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 32-bits')
- }
- for (var i = 0; i < len; i += 4) {
- swap(this, i, i + 3)
- swap(this, i + 1, i + 2)
- }
- return this
-}
-
-Buffer.prototype.swap64 = function swap64 () {
- var len = this.length
- if (len % 8 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 64-bits')
- }
- for (var i = 0; i < len; i += 8) {
- swap(this, i, i + 7)
- swap(this, i + 1, i + 6)
- swap(this, i + 2, i + 5)
- swap(this, i + 3, i + 4)
- }
- return this
-}
-
-Buffer.prototype.toString = function toString () {
- var length = this.length | 0
- if (length === 0) return ''
- if (arguments.length === 0) return utf8Slice(this, 0, length)
- return slowToString.apply(this, arguments)
-}
-
-Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
-}
-
-Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return ''
-}
-
-Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
- if (!Buffer.isBuffer(target)) {
- throw new TypeError('Argument must be a Buffer')
- }
-
- if (start === undefined) {
- start = 0
- }
- if (end === undefined) {
- end = target ? target.length : 0
- }
- if (thisStart === undefined) {
- thisStart = 0
- }
- if (thisEnd === undefined) {
- thisEnd = this.length
- }
-
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
- throw new RangeError('out of range index')
- }
-
- if (thisStart >= thisEnd && start >= end) {
- return 0
- }
- if (thisStart >= thisEnd) {
- return -1
- }
- if (start >= end) {
- return 1
- }
-
- start >>>= 0
- end >>>= 0
- thisStart >>>= 0
- thisEnd >>>= 0
-
- if (this === target) return 0
-
- var x = thisEnd - thisStart
- var y = end - start
- var len = Math.min(x, y)
-
- var thisCopy = this.slice(thisStart, thisEnd)
- var targetCopy = target.slice(start, end)
-
- for (var i = 0; i < len; ++i) {
- if (thisCopy[i] !== targetCopy[i]) {
- x = thisCopy[i]
- y = targetCopy[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
-}
-
-// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
-// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
-//
-// Arguments:
-// - buffer - a Buffer to search
-// - val - a string, Buffer, or number
-// - byteOffset - an index into `buffer`; will be clamped to an int32
-// - encoding - an optional encoding, relevant is val is a string
-// - dir - true for indexOf, false for lastIndexOf
-function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
- // Empty buffer means no match
- if (buffer.length === 0) return -1
-
- // Normalize byteOffset
- if (typeof byteOffset === 'string') {
- encoding = byteOffset
- byteOffset = 0
- } else if (byteOffset > 0x7fffffff) {
- byteOffset = 0x7fffffff
- } else if (byteOffset < -0x80000000) {
- byteOffset = -0x80000000
- }
- byteOffset = +byteOffset // Coerce to Number.
- if (isNaN(byteOffset)) {
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
- byteOffset = dir ? 0 : (buffer.length - 1)
- }
-
- // Normalize byteOffset: negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset
- if (byteOffset >= buffer.length) {
- if (dir) return -1
- else byteOffset = buffer.length - 1
- } else if (byteOffset < 0) {
- if (dir) byteOffset = 0
- else return -1
- }
-
- // Normalize val
- if (typeof val === 'string') {
- val = Buffer.from(val, encoding)
- }
-
- // Finally, search either indexOf (if dir is true) or lastIndexOf
- if (Buffer.isBuffer(val)) {
- // Special case: looking for empty string/buffer always fails
- if (val.length === 0) {
- return -1
- }
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
- } else if (typeof val === 'number') {
- val = val & 0xFF // Search for a byte value [0-255]
- if (Buffer.TYPED_ARRAY_SUPPORT &&
- typeof Uint8Array.prototype.indexOf === 'function') {
- if (dir) {
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
- } else {
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
- }
- }
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
- }
-
- throw new TypeError('val must be string, number or Buffer')
-}
-
-function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
- var indexSize = 1
- var arrLength = arr.length
- var valLength = val.length
-
- if (encoding !== undefined) {
- encoding = String(encoding).toLowerCase()
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
- encoding === 'utf16le' || encoding === 'utf-16le') {
- if (arr.length < 2 || val.length < 2) {
- return -1
- }
- indexSize = 2
- arrLength /= 2
- valLength /= 2
- byteOffset /= 2
- }
- }
+ /**
+ * The Buffer constructor returns instances of `Uint8Array` that have their
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
+ * returns a single octet.
+ *
+ * The `Uint8Array` prototype remains unmodified.
+ */
+
+ function Buffer(arg, encodingOrOffset, length) {
+ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
+ return new Buffer(arg, encodingOrOffset, length);
+ }
- function read (buf, i) {
- if (indexSize === 1) {
- return buf[i]
- } else {
- return buf.readUInt16BE(i * indexSize)
- }
- }
-
- var i
- if (dir) {
- var foundIndex = -1
- for (i = byteOffset; i < arrLength; i++) {
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
- } else {
- if (foundIndex !== -1) i -= i - foundIndex
- foundIndex = -1
- }
- }
- } else {
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
- for (i = byteOffset; i >= 0; i--) {
- var found = true
- for (var j = 0; j < valLength; j++) {
- if (read(arr, i + j) !== read(val, j)) {
- found = false
- break
- }
- }
- if (found) return i
- }
- }
-
- return -1
-}
-
-Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
- return this.indexOf(val, byteOffset, encoding) !== -1
-}
-
-Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
-}
-
-Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
-}
-
-function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
-
- // must be an even number of digits
- var strLen = string.length
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
-
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; ++i) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (isNaN(parsed)) return i
- buf[offset + i] = parsed
- }
- return i
-}
-
-function utf8Write (buf, string, offset, length) {
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
-}
-
-function asciiWrite (buf, string, offset, length) {
- return blitBuffer(asciiToBytes(string), buf, offset, length)
-}
-
-function latin1Write (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
-}
-
-function base64Write (buf, string, offset, length) {
- return blitBuffer(base64ToBytes(string), buf, offset, length)
-}
-
-function ucs2Write (buf, string, offset, length) {
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
-}
-
-Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Buffer#write(string)
- if (offset === undefined) {
- encoding = 'utf8'
- length = this.length
- offset = 0
- // Buffer#write(string, encoding)
- } else if (length === undefined && typeof offset === 'string') {
- encoding = offset
- length = this.length
- offset = 0
- // Buffer#write(string, offset[, length][, encoding])
- } else if (isFinite(offset)) {
- offset = offset | 0
- if (isFinite(length)) {
- length = length | 0
- if (encoding === undefined) encoding = 'utf8'
- } else {
- encoding = length
- length = undefined
- }
- // legacy write(string, encoding, offset, length) - remove in v0.13
- } else {
- throw new Error(
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
- )
- }
-
- var remaining = this.length - offset
- if (length === undefined || length > remaining) length = remaining
-
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
- throw new RangeError('Attempt to write outside buffer bounds')
- }
-
- if (!encoding) encoding = 'utf8'
-
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'hex':
- return hexWrite(this, string, offset, length)
-
- case 'utf8':
- case 'utf-8':
- return utf8Write(this, string, offset, length)
-
- case 'ascii':
- return asciiWrite(this, string, offset, length)
-
- case 'latin1':
- case 'binary':
- return latin1Write(this, string, offset, length)
-
- case 'base64':
- // Warning: maxLength not taken into account in base64Write
- return base64Write(this, string, offset, length)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return ucs2Write(this, string, offset, length)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
-}
-
-Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
-}
-
-function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
-}
-
-function utf8Slice (buf, start, end) {
- end = Math.min(buf.length, end)
- var res = []
-
- var i = start
- while (i < end) {
- var firstByte = buf[i]
- var codePoint = null
- var bytesPerSequence = (firstByte > 0xEF) ? 4
- : (firstByte > 0xDF) ? 3
- : (firstByte > 0xBF) ? 2
- : 1
-
- if (i + bytesPerSequence <= end) {
- var secondByte, thirdByte, fourthByte, tempCodePoint
-
- switch (bytesPerSequence) {
- case 1:
- if (firstByte < 0x80) {
- codePoint = firstByte
- }
- break
- case 2:
- secondByte = buf[i + 1]
- if ((secondByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
- if (tempCodePoint > 0x7F) {
- codePoint = tempCodePoint
- }
- }
- break
- case 3:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
- codePoint = tempCodePoint
- }
- }
- break
- case 4:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- fourthByte = buf[i + 3]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
- codePoint = tempCodePoint
+ // Common case.
+ if (typeof arg === 'number') {
+ if (typeof encodingOrOffset === 'string') {
+ throw new Error('If encoding is specified then the first argument must be a string');
+ }
+ return allocUnsafe(this, arg);
}
+ return from(this, arg, encodingOrOffset, length);
}
- }
- }
-
- if (codePoint === null) {
- // we did not generate a valid codePoint so insert a
- // replacement char (U+FFFD) and advance only 1 byte
- codePoint = 0xFFFD
- bytesPerSequence = 1
- } else if (codePoint > 0xFFFF) {
- // encode to utf16 (surrogate pair dance)
- codePoint -= 0x10000
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
- codePoint = 0xDC00 | codePoint & 0x3FF
- }
- res.push(codePoint)
- i += bytesPerSequence
- }
-
- return decodeCodePointsArray(res)
-}
-
-// Based on http://stackoverflow.com/a/22747272/680742, the browser with
-// the lowest limit is Chrome, with 0x10000 args.
-// We go 1 magnitude less, for safety
-var MAX_ARGUMENTS_LENGTH = 0x1000
-
-function decodeCodePointsArray (codePoints) {
- var len = codePoints.length
- if (len <= MAX_ARGUMENTS_LENGTH) {
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
- }
-
- // Decode in chunks to avoid "call stack size exceeded".
- var res = ''
- var i = 0
- while (i < len) {
- res += String.fromCharCode.apply(
- String,
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
- )
- }
- return res
-}
-
-function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
-}
-
-function latin1Slice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
-}
-
-function hexSlice (buf, start, end) {
- var len = buf.length
-
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
-
- var out = ''
- for (var i = start; i < end; ++i) {
- out += toHex(buf[i])
- }
- return out
-}
-
-function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
- }
- return res
-}
-
-Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
-
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
-
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
-
- if (end < start) end = start
-
- var newBuf
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- newBuf = this.subarray(start, end)
- newBuf.__proto__ = Buffer.prototype
- } else {
- var sliceLen = end - start
- newBuf = new Buffer(sliceLen, undefined)
- for (var i = 0; i < sliceLen; ++i) {
- newBuf[i] = this[i + start]
- }
- }
+ Buffer.poolSize = 8192; // not used by this implementation
- return newBuf
-}
+ // TODO: Legacy, not needed anymore. Remove in next major version.
+ Buffer._augment = function (arr) {
+ arr.__proto__ = Buffer.prototype;
+ return arr;
+ };
-/*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
-function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
-}
-
-Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
-
- return val
-}
-
-Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
-
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
-
- return val
-}
-
-Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
-}
-
-Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
-}
-
-Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
-}
-
-Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
-}
-
-Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
-}
-
-Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
-}
-
-Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
-}
-
-Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
-}
-
-Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
-}
-
-Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
-}
-
-Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
-}
-
-Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
-}
-
-Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
-}
-
-Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
-}
-
-Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
-}
-
-Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
-}
-
-function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
-}
-
-Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
-}
-
-Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
-}
-
-Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- this[offset] = (value & 0xff)
- return offset + 1
-}
-
-function objectWriteUInt16 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
- (littleEndian ? i : 1 - i) * 8
- }
-}
-
-Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
-}
-
-Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
-}
-
-function objectWriteUInt32 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffffffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
- }
-}
-
-Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
-}
-
-Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
-}
-
-Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) {
- var limit = Math.pow(2, 8 * byteLength - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = 0
- var mul = 1
- var sub = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
-}
-
-Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) {
- var limit = Math.pow(2, 8 * byteLength - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = byteLength - 1
- var mul = 1
- var sub = 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
-}
-
-Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- if (value < 0) value = 0xff + value + 1
- this[offset] = (value & 0xff)
- return offset + 1
-}
-
-Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
-}
-
-Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
-}
-
-Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
-}
-
-Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
-}
-
-function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- if (offset < 0) throw new RangeError('Index out of range')
-}
-
-function writeFloat (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
-}
-
-Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
-}
-
-Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
-}
-
-function writeDouble (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
-}
-
-Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
-}
-
-Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
-}
-
-// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
-Buffer.prototype.copy = function copy (target, targetStart, start, end) {
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (targetStart >= target.length) targetStart = target.length
- if (!targetStart) targetStart = 0
- if (end > 0 && end < start) end = start
-
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
-
- // Fatal error conditions
- if (targetStart < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
-
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - targetStart < end - start) {
- end = target.length - targetStart + start
- }
-
- var len = end - start
- var i
-
- if (this === target && start < targetStart && targetStart < end) {
- // descending copy from end
- for (i = len - 1; i >= 0; --i) {
- target[i + targetStart] = this[i + start]
- }
- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
- // ascending copy from start
- for (i = 0; i < len; ++i) {
- target[i + targetStart] = this[i + start]
- }
- } else {
- Uint8Array.prototype.set.call(
- target,
- this.subarray(start, start + len),
- targetStart
- )
- }
-
- return len
-}
-
-// Usage:
-// buffer.fill(number[, offset[, end]])
-// buffer.fill(buffer[, offset[, end]])
-// buffer.fill(string[, offset[, end]][, encoding])
-Buffer.prototype.fill = function fill (val, start, end, encoding) {
- // Handle string cases:
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = this.length
- } else if (typeof end === 'string') {
- encoding = end
- end = this.length
- }
- if (val.length === 1) {
- var code = val.charCodeAt(0)
- if (code < 256) {
- val = code
- }
- }
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- } else if (typeof val === 'number') {
- val = val & 255
- }
+ function from(that, value, encodingOrOffset, length) {
+ if (typeof value === 'number') {
+ throw new TypeError('"value" argument must not be a number');
+ }
- // Invalid ranges are not set to a default, so can range check early.
- if (start < 0 || this.length < start || this.length < end) {
- throw new RangeError('Out of range index')
- }
+ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
+ return fromArrayBuffer(that, value, encodingOrOffset, length);
+ }
- if (end <= start) {
- return this
- }
+ if (typeof value === 'string') {
+ return fromString(that, value, encodingOrOffset);
+ }
- start = start >>> 0
- end = end === undefined ? this.length : end >>> 0
+ return fromObject(that, value);
+ }
- if (!val) val = 0
+ /**
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
+ * if value is a number.
+ * Buffer.from(str[, encoding])
+ * Buffer.from(array)
+ * Buffer.from(buffer)
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
+ **/
+ Buffer.from = function (value, encodingOrOffset, length) {
+ return from(null, value, encodingOrOffset, length);
+ };
+
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ Buffer.prototype.__proto__ = Uint8Array.prototype;
+ Buffer.__proto__ = Uint8Array;
+ if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) {
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
+ Object.defineProperty(Buffer, Symbol.species, {
+ value: null,
+ configurable: true,
+ });
+ }
+ }
- var i
- if (typeof val === 'number') {
- for (i = start; i < end; ++i) {
- this[i] = val
- }
- } else {
- var bytes = Buffer.isBuffer(val)
- ? val
- : utf8ToBytes(new Buffer(val, encoding).toString())
- var len = bytes.length
- for (i = 0; i < end - start; ++i) {
- this[i + start] = bytes[i % len]
- }
- }
-
- return this
-}
-
-// HELPER FUNCTIONS
-// ================
-
-var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
-
-function base64clean (str) {
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = stringtrim(str).replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
-}
-
-function stringtrim (str) {
- if (str.trim) return str.trim()
- return str.replace(/^\s+|\s+$/g, '')
-}
-
-function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
-}
-
-function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
-
- for (var i = 0; i < length; ++i) {
- codePoint = string.charCodeAt(i)
-
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (!leadSurrogate) {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- }
+ function assertSize(size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('"size" argument must be a number');
+ } else if (size < 0) {
+ throw new RangeError('"size" argument must not be negative');
+ }
+ }
- // valid lead
- leadSurrogate = codePoint
+ function alloc(that, size, fill, encoding) {
+ assertSize(size);
+ if (size <= 0) {
+ return createBuffer(that, size);
+ }
+ if (fill !== undefined) {
+ // Only pay attention to encoding if it's a string. This
+ // prevents accidentally sending in a number that would
+ // be interpretted as a start offset.
+ return typeof encoding === 'string'
+ ? createBuffer(that, size).fill(fill, encoding)
+ : createBuffer(that, size).fill(fill);
+ }
+ return createBuffer(that, size);
+ }
- continue
- }
+ /**
+ * Creates a new filled Buffer instance.
+ * alloc(size[, fill[, encoding]])
+ **/
+ Buffer.alloc = function (size, fill, encoding) {
+ return alloc(null, size, fill, encoding);
+ };
+
+ function allocUnsafe(that, size) {
+ assertSize(size);
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
+ if (!Buffer.TYPED_ARRAY_SUPPORT) {
+ for (var i = 0; i < size; ++i) {
+ that[i] = 0;
+ }
+ }
+ return that;
+ }
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- }
+ /**
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
+ * */
+ Buffer.allocUnsafe = function (size) {
+ return allocUnsafe(null, size);
+ };
+ /**
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
+ */
+ Buffer.allocUnsafeSlow = function (size) {
+ return allocUnsafe(null, size);
+ };
+
+ function fromString(that, string, encoding) {
+ if (typeof encoding !== 'string' || encoding === '') {
+ encoding = 'utf8';
+ }
- // valid surrogate pair
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- }
+ if (!Buffer.isEncoding(encoding)) {
+ throw new TypeError('"encoding" must be a valid string encoding');
+ }
- leadSurrogate = null
-
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x110000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
-
- return bytes
-}
-
-function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
-}
-
-function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- if ((units -= 2) < 0) break
-
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
-
- return byteArray
-}
-
-function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
-}
-
-function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; ++i) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
-}
-
-function isnan (val) {
- return val !== val // eslint-disable-line no-self-compare
-}
-
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
-
-/***/ }),
-/* 5 */
-/***/ (function(module, exports) {
-
-// shim for using process in browser
-var process = module.exports = {};
-
-// cached from whatever global is present so that test runners that stub it
-// don't break things. But we need to wrap it in a try catch in case it is
-// wrapped in strict mode code which doesn't define any globals. It's inside a
-// function because try/catches deoptimize in certain engines.
-
-var cachedSetTimeout;
-var cachedClearTimeout;
-
-function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
-}
-function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
-}
-(function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
-} ())
-function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
+ var length = byteLength(string, encoding) | 0;
+ that = createBuffer(that, length);
+ var actual = that.write(string, encoding);
-}
-function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
+ if (actual !== length) {
+ // Writing a hex string, for example, that contains invalid characters will
+ // cause everything after the first invalid character to be ignored. (e.g.
+ // 'abxxcd' will be treated as 'ab')
+ that = that.slice(0, actual);
+ }
+ return that;
+ }
+ function fromArrayLike(that, array) {
+ var length = array.length < 0 ? 0 : checked(array.length) | 0;
+ that = createBuffer(that, length);
+ for (var i = 0; i < length; i += 1) {
+ that[i] = array[i] & 255;
+ }
+ return that;
+ }
-}
-var queue = [];
-var draining = false;
-var currentQueue;
-var queueIndex = -1;
+ function fromArrayBuffer(that, array, byteOffset, length) {
+ array.byteLength; // this throws if `array` is not a valid ArrayBuffer
-function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
-}
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
+ throw new RangeError("'offset' is out of bounds");
+ }
-function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError("'length' is out of bounds");
}
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
-}
-
-process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
-};
-
-// v8 likes predictible objects
-function Item(fun, array) {
- this.fun = fun;
- this.array = array;
-}
-Item.prototype.run = function () {
- this.fun.apply(null, this.array);
-};
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-process.versions = {};
-
-function noop() {}
-
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
-process.prependListener = noop;
-process.prependOnceListener = noop;
-
-process.listeners = function (name) { return [] }
-
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
-
-process.cwd = function () { return '/' };
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function() { return 0; };
-
-
-/***/ }),
-/* 6 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(process) {
-
-if (!process.version ||
- process.version.indexOf('v0.') === 0 ||
- process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
- module.exports = nextTick;
-} else {
- module.exports = process.nextTick;
-}
-
-function nextTick(fn, arg1, arg2, arg3) {
- if (typeof fn !== 'function') {
- throw new TypeError('"callback" argument must be a function');
- }
- var len = arguments.length;
- var args, i;
- switch (len) {
- case 0:
- case 1:
- return process.nextTick(fn);
- case 2:
- return process.nextTick(function afterTickOne() {
- fn.call(null, arg1);
- });
- case 3:
- return process.nextTick(function afterTickTwo() {
- fn.call(null, arg1, arg2);
- });
- case 4:
- return process.nextTick(function afterTickThree() {
- fn.call(null, arg1, arg2, arg3);
- });
- default:
- args = new Array(len - 1);
- i = 0;
- while (i < args.length) {
- args[i++] = arguments[i];
- }
- return process.nextTick(function afterTick() {
- fn.apply(null, args);
- });
- }
-}
-
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
-
-/***/ }),
-/* 7 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/* eslint-disable node/no-deprecated-api */
-var buffer = __webpack_require__(4)
-var Buffer = buffer.Buffer
-
-// alternative to using Object.keys for old browsers
-function copyProps (src, dst) {
- for (var key in src) {
- dst[key] = src[key]
- }
-}
-if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
- module.exports = buffer
-} else {
- // Copy properties from require('buffer')
- copyProps(buffer, exports)
- exports.Buffer = SafeBuffer
-}
-
-function SafeBuffer (arg, encodingOrOffset, length) {
- return Buffer(arg, encodingOrOffset, length)
-}
-
-// Copy static methods from Buffer
-copyProps(Buffer, SafeBuffer)
-
-SafeBuffer.from = function (arg, encodingOrOffset, length) {
- if (typeof arg === 'number') {
- throw new TypeError('Argument must not be a number')
- }
- return Buffer(arg, encodingOrOffset, length)
-}
-
-SafeBuffer.alloc = function (size, fill, encoding) {
- if (typeof size !== 'number') {
- throw new TypeError('Argument must be a number')
- }
- var buf = Buffer(size)
- if (fill !== undefined) {
- if (typeof encoding === 'string') {
- buf.fill(fill, encoding)
- } else {
- buf.fill(fill)
- }
- } else {
- buf.fill(0)
- }
- return buf
-}
-
-SafeBuffer.allocUnsafe = function (size) {
- if (typeof size !== 'number') {
- throw new TypeError('Argument must be a number')
- }
- return Buffer(size)
-}
-
-SafeBuffer.allocUnsafeSlow = function (size) {
- if (typeof size !== 'number') {
- throw new TypeError('Argument must be a number')
- }
- return buffer.SlowBuffer(size)
-}
-
-
-/***/ }),
-/* 8 */
-/***/ (function(module, exports) {
-
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
-}
-module.exports = EventEmitter;
-
-// Backwards-compat with node 0.10.x
-EventEmitter.EventEmitter = EventEmitter;
-
-EventEmitter.prototype._events = undefined;
-EventEmitter.prototype._maxListeners = undefined;
-
-// By default EventEmitters will print a warning if more than 10 listeners are
-// added to it. This is a useful default which helps finding memory leaks.
-EventEmitter.defaultMaxListeners = 10;
-
-// Obviously not all Emitters should be limited to 10. This function allows
-// that to be increased. Set to zero for unlimited.
-EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
-};
-
-EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
-
- if (!this._events)
- this._events = {};
-
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- } else {
- // At least give some kind of context to the user
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
- err.context = er;
- throw err;
- }
- }
- }
-
- handler = this._events[type];
-
- if (isUndefined(handler))
- return false;
-
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- args = Array.prototype.slice.call(arguments, 1);
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- args = Array.prototype.slice.call(arguments, 1);
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
-
- return true;
-};
-
-EventEmitter.prototype.addListener = function(type, listener) {
- var m;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events)
- this._events = {};
-
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
-
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
-
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
+ if (byteOffset === undefined && length === undefined) {
+ array = new Uint8Array(array);
+ } else if (length === undefined) {
+ array = new Uint8Array(array, byteOffset);
+ } else {
+ array = new Uint8Array(array, byteOffset, length);
+ }
- return this;
-};
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ // Return an augmented `Uint8Array` instance, for best performance
+ that = array;
+ that.__proto__ = Buffer.prototype;
+ } else {
+ // Fallback: Return an object instance of the Buffer class
+ that = fromArrayLike(that, array);
+ }
+ return that;
+ }
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+ function fromObject(that, obj) {
+ if (Buffer.isBuffer(obj)) {
+ var len = checked(obj.length) | 0;
+ that = createBuffer(that, len);
-EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
+ if (that.length === 0) {
+ return that;
+ }
- var fired = false;
+ obj.copy(that, 0, 0, len);
+ return that;
+ }
- function g() {
- this.removeListener(type, g);
+ if (obj) {
+ if ((typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
+ if (typeof obj.length !== 'number' || isnan(obj.length)) {
+ return createBuffer(that, 0);
+ }
+ return fromArrayLike(that, obj);
+ }
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
+ if (obj.type === 'Buffer' && isArray(obj.data)) {
+ return fromArrayLike(that, obj.data);
+ }
+ }
- g.listener = listener;
- this.on(type, g);
+ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.');
+ }
- return this;
-};
+ function checked(length) {
+ // Note: cannot use `length < kMaxLength()` here because that fails when
+ // length is NaN (which is otherwise coerced to zero.)
+ if (length >= kMaxLength()) {
+ throw new RangeError(
+ 'Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes'
+ );
+ }
+ return length | 0;
+ }
-// emits a 'removeListener' event iff the listener was removed
-EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
+ function SlowBuffer(length) {
+ if (+length != length) {
+ // eslint-disable-line eqeqeq
+ length = 0;
+ }
+ return Buffer.alloc(+length);
+ }
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
+ Buffer.isBuffer = function isBuffer(b) {
+ return !!(b != null && b._isBuffer);
+ };
- if (!this._events || !this._events[type])
- return this;
+ Buffer.compare = function compare(a, b) {
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError('Arguments must be Buffers');
+ }
- list = this._events[type];
- length = list.length;
- position = -1;
+ if (a === b) return 0;
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
+ var x = a.length;
+ var y = b.length;
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
+ if (a[i] !== b[i]) {
+ x = a[i];
+ y = b[i];
+ break;
+ }
+ }
- if (position < 0)
- return this;
+ if (x < y) return -1;
+ if (y < x) return 1;
+ return 0;
+ };
+
+ Buffer.isEncoding = function isEncoding(encoding) {
+ switch (String(encoding).toLowerCase()) {
+ case 'hex':
+ case 'utf8':
+ case 'utf-8':
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ case 'base64':
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return true;
+ default:
+ return false;
+ }
+ };
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
+ Buffer.concat = function concat(list, length) {
+ if (!isArray(list)) {
+ throw new TypeError('"list" argument must be an Array of Buffers');
+ }
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
-
- return this;
-};
-
-EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
-
- if (!this._events)
- return this;
-
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
-
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
-
- listeners = this._events[type];
-
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else if (listeners) {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
-
- return this;
-};
-
-EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
-};
-
-EventEmitter.prototype.listenerCount = function(type) {
- if (this._events) {
- var evlistener = this._events[type];
-
- if (isFunction(evlistener))
- return 1;
- else if (evlistener)
- return evlistener.length;
- }
- return 0;
-};
-
-EventEmitter.listenerCount = function(emitter, type) {
- return emitter.listenerCount(type);
-};
-
-function isFunction(arg) {
- return typeof arg === 'function';
-}
-
-function isNumber(arg) {
- return typeof arg === 'number';
-}
-
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
-
-function isUndefined(arg) {
- return arg === void 0;
-}
-
-
-/***/ }),
-/* 9 */
-/***/ (function(module, exports, __webpack_require__) {
-
-exports = module.exports = __webpack_require__(16);
-exports.Stream = exports;
-exports.Readable = exports;
-exports.Writable = __webpack_require__(10);
-exports.Duplex = __webpack_require__(0);
-exports.Transform = __webpack_require__(19);
-exports.PassThrough = __webpack_require__(31);
-
-
-/***/ }),
-/* 10 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// A bit simpler than readable streams.
-// Implement an async ._write(chunk, encoding, cb), and it'll handle all
-// the drain event emission and buffering.
-
-
-
-/**/
-
-var processNextTick = __webpack_require__(6);
-/**/
-
-module.exports = Writable;
-
-/* */
-function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- this.next = null;
-}
-
-// It seems a linked list but it is not
-// there will be only 2 of these for each stream
-function CorkedRequest(state) {
- var _this = this;
-
- this.next = null;
- this.entry = null;
- this.finish = function () {
- onCorkedFinish(_this, state);
- };
-}
-/* */
-
-/**/
-var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
-/**/
-
-/**/
-var Duplex;
-/**/
-
-Writable.WritableState = WritableState;
-
-/**/
-var util = __webpack_require__(3);
-util.inherits = __webpack_require__(1);
-/**/
-
-/**/
-var internalUtil = {
- deprecate: __webpack_require__(30)
-};
-/**/
-
-/**/
-var Stream = __webpack_require__(17);
-/**/
-
-/**/
-var Buffer = __webpack_require__(7).Buffer;
-var OurUint8Array = global.Uint8Array || function () {};
-function _uint8ArrayToBuffer(chunk) {
- return Buffer.from(chunk);
-}
-function _isUint8Array(obj) {
- return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
-}
-/**/
-
-var destroyImpl = __webpack_require__(18);
-
-util.inherits(Writable, Stream);
-
-function nop() {}
-
-function WritableState(options, stream) {
- Duplex = Duplex || __webpack_require__(0);
-
- options = options || {};
-
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
-
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
-
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
-
- // cast to ints.
- this.highWaterMark = Math.floor(this.highWaterMark);
-
- // if _final has been called
- this.finalCalled = false;
-
- // drain event flag.
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
-
- // has it been destroyed
- this.destroyed = false;
-
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
-
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
-
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
-
- // a flag to see when we're in the middle of a write.
- this.writing = false;
-
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
-
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
-
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
-
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function (er) {
- onwrite(stream, er);
- };
-
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
-
- // the amount that is being written when _write is called.
- this.writelen = 0;
-
- this.bufferedRequest = null;
- this.lastBufferedRequest = null;
-
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
-
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
-
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
-
- // count buffered requests
- this.bufferedRequestCount = 0;
-
- // allocate the first CorkedRequest, there is always
- // one allocated and free to use, and we maintain at most two
- this.corkedRequestsFree = new CorkedRequest(this);
-}
-
-WritableState.prototype.getBuffer = function getBuffer() {
- var current = this.bufferedRequest;
- var out = [];
- while (current) {
- out.push(current);
- current = current.next;
- }
- return out;
-};
-
-(function () {
- try {
- Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function () {
- return this.getBuffer();
- }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
- });
- } catch (_) {}
-})();
-
-// Test _writableState for inheritance to account for Duplex streams,
-// whose prototype chain only points to Readable.
-var realHasInstance;
-if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
- realHasInstance = Function.prototype[Symbol.hasInstance];
- Object.defineProperty(Writable, Symbol.hasInstance, {
- value: function (object) {
- if (realHasInstance.call(this, object)) return true;
-
- return object && object._writableState instanceof WritableState;
- }
- });
-} else {
- realHasInstance = function (object) {
- return object instanceof this;
- };
-}
-
-function Writable(options) {
- Duplex = Duplex || __webpack_require__(0);
-
- // Writable ctor is applied to Duplexes, too.
- // `realHasInstance` is necessary because using plain `instanceof`
- // would return false, as no `_writableState` property is attached.
-
- // Trying to use the custom `instanceof` for Writable here will also break the
- // Node.js LazyTransform implementation, which has a non-trivial getter for
- // `_writableState` that would lead to infinite recursion.
- if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
- return new Writable(options);
- }
-
- this._writableState = new WritableState(options, this);
-
- // legacy.
- this.writable = true;
-
- if (options) {
- if (typeof options.write === 'function') this._write = options.write;
-
- if (typeof options.writev === 'function') this._writev = options.writev;
-
- if (typeof options.destroy === 'function') this._destroy = options.destroy;
-
- if (typeof options.final === 'function') this._final = options.final;
- }
-
- Stream.call(this);
-}
-
-// Otherwise people can pipe Writable streams, which is just wrong.
-Writable.prototype.pipe = function () {
- this.emit('error', new Error('Cannot pipe, not readable'));
-};
-
-function writeAfterEnd(stream, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- processNextTick(cb, er);
-}
-
-// Checks that a user-supplied chunk is valid, especially for the particular
-// mode the stream is in. Currently this means that `null` is never accepted
-// and undefined/non-string values are only allowed in object mode.
-function validChunk(stream, state, chunk, cb) {
- var valid = true;
- var er = false;
-
- if (chunk === null) {
- er = new TypeError('May not write null values to stream');
- } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- if (er) {
- stream.emit('error', er);
- processNextTick(cb, er);
- valid = false;
- }
- return valid;
-}
-
-Writable.prototype.write = function (chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- var isBuf = _isUint8Array(chunk) && !state.objectMode;
-
- if (isBuf && !Buffer.isBuffer(chunk)) {
- chunk = _uint8ArrayToBuffer(chunk);
- }
-
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
-
- if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
-
- if (typeof cb !== 'function') cb = nop;
-
- if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
- }
-
- return ret;
-};
-
-Writable.prototype.cork = function () {
- var state = this._writableState;
-
- state.corked++;
-};
-
-Writable.prototype.uncork = function () {
- var state = this._writableState;
-
- if (state.corked) {
- state.corked--;
-
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
- }
-};
-
-Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
- // node::ParseEncoding() requires lower case.
- if (typeof encoding === 'string') encoding = encoding.toLowerCase();
- if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
- this._writableState.defaultEncoding = encoding;
- return this;
-};
-
-function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
- chunk = Buffer.from(chunk, encoding);
- }
- return chunk;
-}
-
-// if we're already writing something, then just put this
-// in the queue, and wait our turn. Otherwise, call _write
-// If we return false, then we need a drain event, so set that flag.
-function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
- if (!isBuf) {
- var newChunk = decodeChunk(state, chunk, encoding);
- if (chunk !== newChunk) {
- isBuf = true;
- encoding = 'buffer';
- chunk = newChunk;
- }
- }
- var len = state.objectMode ? 1 : chunk.length;
-
- state.length += len;
-
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret) state.needDrain = true;
-
- if (state.writing || state.corked) {
- var last = state.lastBufferedRequest;
- state.lastBufferedRequest = {
- chunk: chunk,
- encoding: encoding,
- isBuf: isBuf,
- callback: cb,
- next: null
- };
- if (last) {
- last.next = state.lastBufferedRequest;
- } else {
- state.bufferedRequest = state.lastBufferedRequest;
- }
- state.bufferedRequestCount += 1;
- } else {
- doWrite(stream, state, false, len, chunk, encoding, cb);
- }
-
- return ret;
-}
-
-function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
-}
-
-function onwriteError(stream, state, sync, er, cb) {
- --state.pendingcb;
-
- if (sync) {
- // defer the callback if we are being called synchronously
- // to avoid piling up things on the stack
- processNextTick(cb, er);
- // this can emit finish, and it will always happen
- // after error
- processNextTick(finishMaybe, stream, state);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- } else {
- // the caller expect this to happen before if
- // it is async
- cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- // this can emit finish, but finish must
- // always follow error
- finishMaybe(stream, state);
- }
-}
-
-function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
-}
-
-function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
-
- onwriteStateUpdate(state);
-
- if (er) onwriteError(stream, state, sync, er, cb);else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(state);
-
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
- clearBuffer(stream, state);
- }
+ if (list.length === 0) {
+ return Buffer.alloc(0);
+ }
- if (sync) {
- /**/
- asyncWrite(afterWrite, stream, state, finished, cb);
- /**/
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
-}
-
-function afterWrite(stream, state, finished, cb) {
- if (!finished) onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
-}
-
-// Must force callback to be called on nextTick, so that we don't
-// emit 'drain' before the write() consumer gets the 'false' return
-// value, and has a chance to attach a 'drain' listener.
-function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
-}
-
-// if there's something in the buffer waiting, then process it
-function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- var entry = state.bufferedRequest;
-
- if (stream._writev && entry && entry.next) {
- // Fast case, write everything using _writev()
- var l = state.bufferedRequestCount;
- var buffer = new Array(l);
- var holder = state.corkedRequestsFree;
- holder.entry = entry;
-
- var count = 0;
- var allBuffers = true;
- while (entry) {
- buffer[count] = entry;
- if (!entry.isBuf) allBuffers = false;
- entry = entry.next;
- count += 1;
- }
- buffer.allBuffers = allBuffers;
-
- doWrite(stream, state, true, state.length, buffer, '', holder.finish);
-
- // doWrite is almost always async, defer these to save a bit of time
- // as the hot path ends with doWrite
- state.pendingcb++;
- state.lastBufferedRequest = null;
- if (holder.next) {
- state.corkedRequestsFree = holder.next;
- holder.next = null;
- } else {
- state.corkedRequestsFree = new CorkedRequest(state);
- }
- } else {
- // Slow case, write chunks one-by-one
- while (entry) {
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
-
- doWrite(stream, state, false, len, chunk, encoding, cb);
- entry = entry.next;
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- break;
- }
- }
+ var i;
+ if (length === undefined) {
+ length = 0;
+ for (i = 0; i < list.length; ++i) {
+ length += list[i].length;
+ }
+ }
- if (entry === null) state.lastBufferedRequest = null;
- }
-
- state.bufferedRequestCount = 0;
- state.bufferedRequest = entry;
- state.bufferProcessing = false;
-}
-
-Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('_write() is not implemented'));
-};
-
-Writable.prototype._writev = null;
-
-Writable.prototype.end = function (chunk, encoding, cb) {
- var state = this._writableState;
-
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
-
- if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
-
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
-
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished) endWritable(this, state, cb);
-};
-
-function needFinish(state) {
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
-}
-function callFinal(stream, state) {
- stream._final(function (err) {
- state.pendingcb--;
- if (err) {
- stream.emit('error', err);
- }
- state.prefinished = true;
- stream.emit('prefinish');
- finishMaybe(stream, state);
- });
-}
-function prefinish(stream, state) {
- if (!state.prefinished && !state.finalCalled) {
- if (typeof stream._final === 'function') {
- state.pendingcb++;
- state.finalCalled = true;
- processNextTick(callFinal, stream, state);
- } else {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
-}
-
-function finishMaybe(stream, state) {
- var need = needFinish(state);
- if (need) {
- prefinish(stream, state);
- if (state.pendingcb === 0) {
- state.finished = true;
- stream.emit('finish');
- }
- }
- return need;
-}
-
-function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished) processNextTick(cb);else stream.once('finish', cb);
- }
- state.ended = true;
- stream.writable = false;
-}
-
-function onCorkedFinish(corkReq, state, err) {
- var entry = corkReq.entry;
- corkReq.entry = null;
- while (entry) {
- var cb = entry.callback;
- state.pendingcb--;
- cb(err);
- entry = entry.next;
- }
- if (state.corkedRequestsFree) {
- state.corkedRequestsFree.next = corkReq;
- } else {
- state.corkedRequestsFree = corkReq;
- }
-}
-
-Object.defineProperty(Writable.prototype, 'destroyed', {
- get: function () {
- if (this._writableState === undefined) {
- return false;
- }
- return this._writableState.destroyed;
- },
- set: function (value) {
- // we ignore the value if the stream
- // has not been initialized yet
- if (!this._writableState) {
- return;
- }
+ var buffer = Buffer.allocUnsafe(length);
+ var pos = 0;
+ for (i = 0; i < list.length; ++i) {
+ var buf = list[i];
+ if (!Buffer.isBuffer(buf)) {
+ throw new TypeError('"list" argument must be an Array of Buffers');
+ }
+ buf.copy(buffer, pos);
+ pos += buf.length;
+ }
+ return buffer;
+ };
- // backward compatibility, the user is explicitly
- // managing destroyed
- this._writableState.destroyed = value;
- }
-});
-
-Writable.prototype.destroy = destroyImpl.destroy;
-Writable.prototype._undestroy = destroyImpl.undestroy;
-Writable.prototype._destroy = function (err, cb) {
- this.end();
- cb(err);
-};
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5), __webpack_require__(28).setImmediate, __webpack_require__(2)))
-
-/***/ }),
-/* 11 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-var Buffer = __webpack_require__(7).Buffer;
-
-var isEncoding = Buffer.isEncoding || function (encoding) {
- encoding = '' + encoding;
- switch (encoding && encoding.toLowerCase()) {
- case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
- return true;
- default:
- return false;
- }
-};
-
-function _normalizeEncoding(enc) {
- if (!enc) return 'utf8';
- var retried;
- while (true) {
- switch (enc) {
- case 'utf8':
- case 'utf-8':
- return 'utf8';
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return 'utf16le';
- case 'latin1':
- case 'binary':
- return 'latin1';
- case 'base64':
- case 'ascii':
- case 'hex':
- return enc;
- default:
- if (retried) return; // undefined
- enc = ('' + enc).toLowerCase();
- retried = true;
- }
- }
-};
-
-// Do not cache `Buffer.isEncoding` when checking encoding names as some
-// modules monkey-patch it to support additional encodings
-function normalizeEncoding(enc) {
- var nenc = _normalizeEncoding(enc);
- if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
- return nenc || enc;
-}
-
-// StringDecoder provides an interface for efficiently splitting a series of
-// buffers into a series of JS strings without breaking apart multi-byte
-// characters.
-exports.StringDecoder = StringDecoder;
-function StringDecoder(encoding) {
- this.encoding = normalizeEncoding(encoding);
- var nb;
- switch (this.encoding) {
- case 'utf16le':
- this.text = utf16Text;
- this.end = utf16End;
- nb = 4;
- break;
- case 'utf8':
- this.fillLast = utf8FillLast;
- nb = 4;
- break;
- case 'base64':
- this.text = base64Text;
- this.end = base64End;
- nb = 3;
- break;
- default:
- this.write = simpleWrite;
- this.end = simpleEnd;
- return;
- }
- this.lastNeed = 0;
- this.lastTotal = 0;
- this.lastChar = Buffer.allocUnsafe(nb);
-}
-
-StringDecoder.prototype.write = function (buf) {
- if (buf.length === 0) return '';
- var r;
- var i;
- if (this.lastNeed) {
- r = this.fillLast(buf);
- if (r === undefined) return '';
- i = this.lastNeed;
- this.lastNeed = 0;
- } else {
- i = 0;
- }
- if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
- return r || '';
-};
-
-StringDecoder.prototype.end = utf8End;
-
-// Returns only complete characters in a Buffer
-StringDecoder.prototype.text = utf8Text;
-
-// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
-StringDecoder.prototype.fillLast = function (buf) {
- if (this.lastNeed <= buf.length) {
- buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
- return this.lastChar.toString(this.encoding, 0, this.lastTotal);
- }
- buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
- this.lastNeed -= buf.length;
-};
-
-// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
-// continuation byte.
-function utf8CheckByte(byte) {
- if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
- return -1;
-}
-
-// Checks at most 3 bytes at the end of a Buffer in order to detect an
-// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
-// needed to complete the UTF-8 character (if applicable) are returned.
-function utf8CheckIncomplete(self, buf, i) {
- var j = buf.length - 1;
- if (j < i) return 0;
- var nb = utf8CheckByte(buf[j]);
- if (nb >= 0) {
- if (nb > 0) self.lastNeed = nb - 1;
- return nb;
- }
- if (--j < i) return 0;
- nb = utf8CheckByte(buf[j]);
- if (nb >= 0) {
- if (nb > 0) self.lastNeed = nb - 2;
- return nb;
- }
- if (--j < i) return 0;
- nb = utf8CheckByte(buf[j]);
- if (nb >= 0) {
- if (nb > 0) {
- if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
- }
- return nb;
- }
- return 0;
-}
-
-// Validates as many continuation bytes for a multi-byte UTF-8 character as
-// needed or are available. If we see a non-continuation byte where we expect
-// one, we "replace" the validated continuation bytes we've seen so far with
-// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
-// behavior. The continuation byte check is included three times in the case
-// where all of the continuation bytes for a character exist in the same buffer.
-// It is also done this way as a slight performance increase instead of using a
-// loop.
-function utf8CheckExtraBytes(self, buf, p) {
- if ((buf[0] & 0xC0) !== 0x80) {
- self.lastNeed = 0;
- return '\ufffd'.repeat(p);
- }
- if (self.lastNeed > 1 && buf.length > 1) {
- if ((buf[1] & 0xC0) !== 0x80) {
- self.lastNeed = 1;
- return '\ufffd'.repeat(p + 1);
- }
- if (self.lastNeed > 2 && buf.length > 2) {
- if ((buf[2] & 0xC0) !== 0x80) {
- self.lastNeed = 2;
- return '\ufffd'.repeat(p + 2);
- }
- }
- }
-}
-
-// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
-function utf8FillLast(buf) {
- var p = this.lastTotal - this.lastNeed;
- var r = utf8CheckExtraBytes(this, buf, p);
- if (r !== undefined) return r;
- if (this.lastNeed <= buf.length) {
- buf.copy(this.lastChar, p, 0, this.lastNeed);
- return this.lastChar.toString(this.encoding, 0, this.lastTotal);
- }
- buf.copy(this.lastChar, p, 0, buf.length);
- this.lastNeed -= buf.length;
-}
-
-// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
-// partial character, the character's bytes are buffered until the required
-// number of bytes are available.
-function utf8Text(buf, i) {
- var total = utf8CheckIncomplete(this, buf, i);
- if (!this.lastNeed) return buf.toString('utf8', i);
- this.lastTotal = total;
- var end = buf.length - (total - this.lastNeed);
- buf.copy(this.lastChar, 0, end);
- return buf.toString('utf8', i, end);
-}
-
-// For UTF-8, a replacement character for each buffered byte of a (partial)
-// character needs to be added to the output.
-function utf8End(buf) {
- var r = buf && buf.length ? this.write(buf) : '';
- if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
- return r;
-}
-
-// UTF-16LE typically needs two bytes per character, but even if we have an even
-// number of bytes available, we need to check if we end on a leading/high
-// surrogate. In that case, we need to wait for the next two bytes in order to
-// decode the last character properly.
-function utf16Text(buf, i) {
- if ((buf.length - i) % 2 === 0) {
- var r = buf.toString('utf16le', i);
- if (r) {
- var c = r.charCodeAt(r.length - 1);
- if (c >= 0xD800 && c <= 0xDBFF) {
- this.lastNeed = 2;
- this.lastTotal = 4;
- this.lastChar[0] = buf[buf.length - 2];
- this.lastChar[1] = buf[buf.length - 1];
- return r.slice(0, -1);
- }
- }
- return r;
- }
- this.lastNeed = 1;
- this.lastTotal = 2;
- this.lastChar[0] = buf[buf.length - 1];
- return buf.toString('utf16le', i, buf.length - 1);
-}
-
-// For UTF-16LE we do not explicitly append special replacement characters if we
-// end on a partial character, we simply let v8 handle that.
-function utf16End(buf) {
- var r = buf && buf.length ? this.write(buf) : '';
- if (this.lastNeed) {
- var end = this.lastTotal - this.lastNeed;
- return r + this.lastChar.toString('utf16le', 0, end);
- }
- return r;
-}
-
-function base64Text(buf, i) {
- var n = (buf.length - i) % 3;
- if (n === 0) return buf.toString('base64', i);
- this.lastNeed = 3 - n;
- this.lastTotal = 3;
- if (n === 1) {
- this.lastChar[0] = buf[buf.length - 1];
- } else {
- this.lastChar[0] = buf[buf.length - 2];
- this.lastChar[1] = buf[buf.length - 1];
- }
- return buf.toString('base64', i, buf.length - n);
-}
-
-function base64End(buf) {
- var r = buf && buf.length ? this.write(buf) : '';
- if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
- return r;
-}
-
-// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
-function simpleWrite(buf) {
- return buf.toString(this.encoding);
-}
-
-function simpleEnd(buf) {
- return buf && buf.length ? this.write(buf) : '';
-}
-
-/***/ }),
-/* 12 */
-/***/ (function(module, exports, __webpack_require__) {
-
-var isArray = __webpack_require__(13).isArray;
-
-module.exports = {
-
- copyOptions: function (options) {
- var key, copy = {};
- for (key in options) {
- if (options.hasOwnProperty(key)) {
- copy[key] = options[key];
- }
- }
- return copy;
- },
+ function byteLength(string, encoding) {
+ if (Buffer.isBuffer(string)) {
+ return string.length;
+ }
+ if (
+ typeof ArrayBuffer !== 'undefined' &&
+ typeof ArrayBuffer.isView === 'function' &&
+ (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)
+ ) {
+ return string.byteLength;
+ }
+ if (typeof string !== 'string') {
+ string = '' + string;
+ }
- ensureFlagExists: function (item, options) {
- if (!(item in options) || typeof options[item] !== 'boolean') {
- options[item] = false;
- }
- },
+ var len = string.length;
+ if (len === 0) return 0;
+
+ // Use a for loop to avoid recursion
+ var loweredCase = false;
+ for (;;) {
+ switch (encoding) {
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ return len;
+ case 'utf8':
+ case 'utf-8':
+ case undefined:
+ return utf8ToBytes(string).length;
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return len * 2;
+ case 'hex':
+ return len >>> 1;
+ case 'base64':
+ return base64ToBytes(string).length;
+ default:
+ if (loweredCase) return utf8ToBytes(string).length; // assume utf8
+ encoding = ('' + encoding).toLowerCase();
+ loweredCase = true;
+ }
+ }
+ }
+ Buffer.byteLength = byteLength;
- ensureSpacesExists: function (options) {
- if (!('spaces' in options) || (typeof options.spaces !== 'number' && typeof options.spaces !== 'string')) {
- options.spaces = 0;
- }
- },
+ function slowToString(encoding, start, end) {
+ var loweredCase = false;
- ensureAlwaysArrayExists: function (options) {
- if (!('alwaysArray' in options) || (typeof options.alwaysArray !== 'boolean' && !isArray(options.alwaysArray))) {
- options.alwaysArray = false;
- }
- },
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
+ // property of a typed array.
- ensureKeyExists: function (key, options) {
- if (!(key + 'Key' in options) || typeof options[key + 'Key'] !== 'string') {
- options[key + 'Key'] = options.compact ? '_' + key : key;
- }
- },
+ // This behaves neither like String nor Uint8Array in that we set start/end
+ // to their upper/lower bounds if the value passed is out of range.
+ // undefined is handled specially as per ECMA-262 6th Edition,
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
+ if (start === undefined || start < 0) {
+ start = 0;
+ }
+ // Return early if start > this.length. Done here to prevent potential uint32
+ // coercion fail below.
+ if (start > this.length) {
+ return '';
+ }
- checkFnExists: function (key, options) {
- return key + 'Fn' in options;
- }
+ if (end === undefined || end > this.length) {
+ end = this.length;
+ }
-};
+ if (end <= 0) {
+ return '';
+ }
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
+ end >>>= 0;
+ start >>>= 0;
-/***/ }),
-/* 13 */
-/***/ (function(module, exports) {
+ if (end <= start) {
+ return '';
+ }
-module.exports = {
+ if (!encoding) encoding = 'utf8';
- isArray: function(value) {
- if (Array.isArray) {
- return Array.isArray(value);
- }
- // fallback for older browsers like IE 8
- return Object.prototype.toString.call( value ) === '[object Array]';
- }
-
-};
-
-
-/***/ }),
-/* 14 */
-/***/ (function(module, exports, __webpack_require__) {
-
-var sax = __webpack_require__(22);
-var expat /*= require('node-expat');*/ = { on: function () { }, parse: function () { } };
-var helper = __webpack_require__(12);
-var isArray = __webpack_require__(13).isArray;
-
-var options;
-var pureJsParser = true;
-var currentElement;
-
-function validateOptions(userOptions) {
- options = helper.copyOptions(userOptions);
- helper.ensureFlagExists('ignoreDeclaration', options);
- helper.ensureFlagExists('ignoreInstruction', options);
- helper.ensureFlagExists('ignoreAttributes', options);
- helper.ensureFlagExists('ignoreText', options);
- helper.ensureFlagExists('ignoreComment', options);
- helper.ensureFlagExists('ignoreCdata', options);
- helper.ensureFlagExists('ignoreDoctype', options);
- helper.ensureFlagExists('compact', options);
- helper.ensureFlagExists('alwaysChildren', options);
- helper.ensureFlagExists('addParent', options);
- helper.ensureFlagExists('trim', options);
- helper.ensureFlagExists('nativeType', options);
- helper.ensureFlagExists('sanitize', options);
- helper.ensureFlagExists('instructionHasAttributes', options);
- helper.ensureFlagExists('captureSpacesBetweenElements', options);
- helper.ensureAlwaysArrayExists(options);
- helper.ensureKeyExists('declaration', options);
- helper.ensureKeyExists('instruction', options);
- helper.ensureKeyExists('attributes', options);
- helper.ensureKeyExists('text', options);
- helper.ensureKeyExists('comment', options);
- helper.ensureKeyExists('cdata', options);
- helper.ensureKeyExists('doctype', options);
- helper.ensureKeyExists('type', options);
- helper.ensureKeyExists('name', options);
- helper.ensureKeyExists('elements', options);
- helper.ensureKeyExists('parent', options);
- helper.checkFnExists('doctype', options);
- helper.checkFnExists('instruction', options);
- helper.checkFnExists('cdata', options);
- helper.checkFnExists('comment', options);
- helper.checkFnExists('text', options);
- helper.checkFnExists('instructionName', options);
- helper.checkFnExists('elementName', options);
- helper.checkFnExists('attributeName', options);
- helper.checkFnExists('attributeValue', options);
- helper.checkFnExists('attributes', options);
- return options;
-}
-
-function nativeType(value) {
- var nValue = Number(value);
- if (!isNaN(nValue)) {
- return nValue;
- }
- var bValue = value.toLowerCase();
- if (bValue === 'true') {
- return true;
- } else if (bValue === 'false') {
- return false;
- }
- return value;
-}
-
-function addField(type, value) {
- var key;
- if (options.compact) {
- if (
- !currentElement[options[type + 'Key']] &&
- (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(options[type + 'Key']) !== -1 : options.alwaysArray)
- ) {
- currentElement[options[type + 'Key']] = [];
- }
- if (currentElement[options[type + 'Key']] && !isArray(currentElement[options[type + 'Key']])) {
- currentElement[options[type + 'Key']] = [currentElement[options[type + 'Key']]];
- }
- if (type + 'Fn' in options && typeof value === 'string') {
- value = options[type + 'Fn'](value, currentElement);
- }
- if (type === 'instruction' && ('instructionFn' in options || 'instructionNameFn' in options)) {
- for (key in value) {
- if (value.hasOwnProperty(key)) {
- if ('instructionFn' in options) {
- value[key] = options.instructionFn(value[key], key, currentElement);
- } else {
- var temp = value[key];
- delete value[key];
- value[options.instructionNameFn(key, temp, currentElement)] = temp;
+ while (true) {
+ switch (encoding) {
+ case 'hex':
+ return hexSlice(this, start, end);
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Slice(this, start, end);
+
+ case 'ascii':
+ return asciiSlice(this, start, end);
+
+ case 'latin1':
+ case 'binary':
+ return latin1Slice(this, start, end);
+
+ case 'base64':
+ return base64Slice(this, start, end);
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return utf16leSlice(this, start, end);
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
+ encoding = (encoding + '').toLowerCase();
+ loweredCase = true;
+ }
+ }
}
- }
- }
- }
- if (isArray(currentElement[options[type + 'Key']])) {
- currentElement[options[type + 'Key']].push(value);
- } else {
- currentElement[options[type + 'Key']] = value;
- }
- } else {
- if (!currentElement[options.elementsKey]) {
- currentElement[options.elementsKey] = [];
- }
- var element = {};
- element[options.typeKey] = type;
- if (type === 'instruction') {
- for (key in value) {
- if (value.hasOwnProperty(key)) {
- break;
- }
- }
- element[options.nameKey] = 'instructionNameFn' in options ? options.instructionNameFn(key, value, currentElement) : key;
- if (options.instructionHasAttributes) {
- element[options.attributesKey] = value[key][options.attributesKey];
- if ('instructionFn' in options) {
- element[options.attributesKey] = options.instructionFn(element[options.attributesKey], key, currentElement);
- }
- } else {
- if ('instructionFn' in options) {
- value[key] = options.instructionFn(value[key], key, currentElement);
- }
- element[options.instructionKey] = value[key];
- }
- } else {
- if (type + 'Fn' in options) {
- value = options[type + 'Fn'](value, currentElement);
- }
- element[options[type + 'Key']] = value;
- }
- if (options.addParent) {
- element[options.parentKey] = currentElement;
- }
- currentElement[options.elementsKey].push(element);
- }
-}
-
-function manipulateAttributes(attributes) {
- if ('attributesFn' in options && attributes) {
- attributes = options.attributesFn(attributes, currentElement);
- }
- if ((options.trim || 'attributeValueFn' in options || 'attributeNameFn' in options) && attributes) {
- var key;
- for (key in attributes) {
- if (attributes.hasOwnProperty(key)) {
- if (options.trim) attributes[key] = attributes[key].trim();
- if ('attributeValueFn' in options) attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
- if ('attributeNameFn' in options) {
- var temp = attributes[key];
- delete attributes[key];
- attributes[options.attributeNameFn(key, attributes[key], currentElement)] = temp;
- }
- }
- }
- }
- return attributes;
-}
-
-function onInstruction(instruction) {
- var attributes = {};
- if (instruction.body && (instruction.name.toLowerCase() === 'xml' || options.instructionHasAttributes)) {
- var attrsRegExp = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;
- var match;
- while ((match = attrsRegExp.exec(instruction.body)) !== null) {
- attributes[match[1]] = match[2] || match[3] || match[4];
- }
- attributes = manipulateAttributes(attributes);
- }
- if (instruction.name.toLowerCase() === 'xml') {
- if (options.ignoreDeclaration) {
- return;
- }
- currentElement[options.declarationKey] = {};
- if (Object.keys(attributes).length) {
- currentElement[options.declarationKey][options.attributesKey] = attributes;
- }
- if (options.addParent) {
- currentElement[options.declarationKey][options.parentKey] = currentElement;
- }
- } else {
- if (options.ignoreInstruction) {
- return;
- }
- if (options.trim) {
- instruction.body = instruction.body.trim();
- }
- var value = {};
- if (options.instructionHasAttributes && Object.keys(attributes).length) {
- value[instruction.name] = {};
- value[instruction.name][options.attributesKey] = attributes;
- } else {
- value[instruction.name] = instruction.body;
- }
- addField('instruction', value);
- }
-}
-
-function onStartElement(name, attributes) {
- var element;
- if (typeof name === 'object') {
- attributes = name.attributes;
- name = name.name;
- }
- attributes = manipulateAttributes(attributes);
- if ('elementNameFn' in options) {
- name = options.elementNameFn(name, currentElement);
- }
- if (options.compact) {
- element = {};
- if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
- element[options.attributesKey] = {};
- var key;
- for (key in attributes) {
- if (attributes.hasOwnProperty(key)) {
- element[options.attributesKey][key] = attributes[key];
- }
- }
- }
- if (
- !(name in currentElement) &&
- (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(name) !== -1 : options.alwaysArray)
- ) {
- currentElement[name] = [];
- }
- if (currentElement[name] && !isArray(currentElement[name])) {
- currentElement[name] = [currentElement[name]];
- }
- if (isArray(currentElement[name])) {
- currentElement[name].push(element);
- } else {
- currentElement[name] = element;
- }
- } else {
- if (!currentElement[options.elementsKey]) {
- currentElement[options.elementsKey] = [];
- }
- element = {};
- element[options.typeKey] = 'element';
- element[options.nameKey] = name;
- if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
- element[options.attributesKey] = attributes;
- }
- if (options.alwaysChildren) {
- element[options.elementsKey] = [];
- }
- currentElement[options.elementsKey].push(element);
- }
- element[options.parentKey] = currentElement; // will be deleted in onEndElement() if !options.addParent
- currentElement = element;
-}
-
-function onText(text) {
- if (options.ignoreText) {
- return;
- }
- if (!text.trim() && !options.captureSpacesBetweenElements) {
- return;
- }
- if (options.trim) {
- text = text.trim();
- }
- if (options.nativeType) {
- text = nativeType(text);
- }
- if (options.sanitize) {
- text = text.replace(/&/g, '&').replace(//g, '>');
- }
- addField('text', text);
-}
-
-function onComment(comment) {
- if (options.ignoreComment) {
- return;
- }
- if (options.trim) {
- comment = comment.trim();
- }
- addField('comment', comment);
-}
-
-function onEndElement(name) {
- var parentElement = currentElement[options.parentKey];
- if (!options.addParent) {
- delete currentElement[options.parentKey];
- }
- currentElement = parentElement;
-}
-
-function onCdata(cdata) {
- if (options.ignoreCdata) {
- return;
- }
- if (options.trim) {
- cdata = cdata.trim();
- }
- addField('cdata', cdata);
-}
-
-function onDoctype(doctype) {
- if (options.ignoreDoctype) {
- return;
- }
- doctype = doctype.replace(/^ /, '');
- if (options.trim) {
- doctype = doctype.trim();
- }
- addField('doctype', doctype);
-}
-
-function onError(error) {
- error.note = error; //console.error(error);
-}
-
-module.exports = function (xml, userOptions) {
-
- var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser('UTF-8');
- var result = {};
- currentElement = result;
-
- options = validateOptions(userOptions);
-
- if (pureJsParser) {
- parser.opt = {strictEntities: true};
- parser.onopentag = onStartElement;
- parser.ontext = onText;
- parser.oncomment = onComment;
- parser.onclosetag = onEndElement;
- parser.onerror = onError;
- parser.oncdata = onCdata;
- parser.ondoctype = onDoctype;
- parser.onprocessinginstruction = onInstruction;
- } else {
- parser.on('startElement', onStartElement);
- parser.on('text', onText);
- parser.on('comment', onComment);
- parser.on('endElement', onEndElement);
- parser.on('error', onError);
- //parser.on('startCdata', onStartCdata);
- //parser.on('endCdata', onEndCdata);
- //parser.on('entityDecl', onEntityDecl);
- }
-
- if (pureJsParser) {
- parser.write(xml).close();
- } else {
- if (!parser.parse(xml)) {
- throw new Error('XML parsing error: ' + parser.getError());
- }
- }
-
- if (result[options.elementsKey]) {
- var temp = result[options.elementsKey];
- delete result[options.elementsKey];
- result[options.elementsKey] = temp;
- delete result.text;
- }
-
- return result;
-
-};
-
-
-/***/ }),
-/* 15 */
-/***/ (function(module, exports) {
-
-var toString = {}.toString;
-
-module.exports = Array.isArray || function (arr) {
- return toString.call(arr) == '[object Array]';
-};
-
-
-/***/ }),
-/* 16 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-/**/
-
-var processNextTick = __webpack_require__(6);
-/**/
-
-module.exports = Readable;
-
-/**/
-var isArray = __webpack_require__(15);
-/**/
-
-/**/
-var Duplex;
-/**/
-
-Readable.ReadableState = ReadableState;
-
-/**/
-var EE = __webpack_require__(8).EventEmitter;
-
-var EElistenerCount = function (emitter, type) {
- return emitter.listeners(type).length;
-};
-/**/
-
-/**/
-var Stream = __webpack_require__(17);
-/**/
-
-// TODO(bmeurer): Change this back to const once hole checks are
-// properly optimized away early in Ignition+TurboFan.
-/**/
-var Buffer = __webpack_require__(7).Buffer;
-var OurUint8Array = global.Uint8Array || function () {};
-function _uint8ArrayToBuffer(chunk) {
- return Buffer.from(chunk);
-}
-function _isUint8Array(obj) {
- return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
-}
-/**/
-
-/**/
-var util = __webpack_require__(3);
-util.inherits = __webpack_require__(1);
-/**/
-
-/**/
-var debugUtil = __webpack_require__(26);
-var debug = void 0;
-if (debugUtil && debugUtil.debuglog) {
- debug = debugUtil.debuglog('stream');
-} else {
- debug = function () {};
-}
-/**/
-
-var BufferList = __webpack_require__(27);
-var destroyImpl = __webpack_require__(18);
-var StringDecoder;
-
-util.inherits(Readable, Stream);
-
-var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
-
-function prependListener(emitter, event, fn) {
- // Sadly this is not cacheable as some libraries bundle their own
- // event emitter implementation with them.
- if (typeof emitter.prependListener === 'function') {
- return emitter.prependListener(event, fn);
- } else {
- // This is a hack to make sure that our error handler is attached before any
- // userland ones. NEVER DO THIS. This is here only because this code needs
- // to continue to work with older versions of Node.js that do not include
- // the prependListener() method. The goal is to eventually remove this hack.
- if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
- }
-}
-
-function ReadableState(options, stream) {
- Duplex = Duplex || __webpack_require__(0);
-
- options = options || {};
-
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
-
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
-
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
-
- // cast to ints.
- this.highWaterMark = Math.floor(this.highWaterMark);
-
- // A linked list is used to store data chunks instead of an array because the
- // linked list can remove elements from the beginning faster than
- // array.shift()
- this.buffer = new BufferList();
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
-
- // a flag to be able to tell if the event 'readable'/'data' is emitted
- // immediately, or on a later tick. We set this to true at first, because
- // any actions that shouldn't happen until "later" should generally also
- // not happen before the first read call.
- this.sync = true;
-
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- this.resumeScheduled = false;
-
- // has it been destroyed
- this.destroyed = false;
-
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
-
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
-
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
-
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder) StringDecoder = __webpack_require__(11).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
-}
-
-function Readable(options) {
- Duplex = Duplex || __webpack_require__(0);
-
- if (!(this instanceof Readable)) return new Readable(options);
-
- this._readableState = new ReadableState(options, this);
-
- // legacy
- this.readable = true;
-
- if (options) {
- if (typeof options.read === 'function') this._read = options.read;
-
- if (typeof options.destroy === 'function') this._destroy = options.destroy;
- }
-
- Stream.call(this);
-}
-
-Object.defineProperty(Readable.prototype, 'destroyed', {
- get: function () {
- if (this._readableState === undefined) {
- return false;
- }
- return this._readableState.destroyed;
- },
- set: function (value) {
- // we ignore the value if the stream
- // has not been initialized yet
- if (!this._readableState) {
- return;
- }
- // backward compatibility, the user is explicitly
- // managing destroyed
- this._readableState.destroyed = value;
- }
-});
-
-Readable.prototype.destroy = destroyImpl.destroy;
-Readable.prototype._undestroy = destroyImpl.undestroy;
-Readable.prototype._destroy = function (err, cb) {
- this.push(null);
- cb(err);
-};
-
-// Manually shove something into the read() buffer.
-// This returns true if the highWaterMark has not been hit yet,
-// similar to how Writable.write() returns true if you should
-// write() some more.
-Readable.prototype.push = function (chunk, encoding) {
- var state = this._readableState;
- var skipChunkCheck;
-
- if (!state.objectMode) {
- if (typeof chunk === 'string') {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = Buffer.from(chunk, encoding);
- encoding = '';
- }
- skipChunkCheck = true;
- }
- } else {
- skipChunkCheck = true;
- }
-
- return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
-};
-
-// Unshift should *always* be something directly out of read()
-Readable.prototype.unshift = function (chunk) {
- return readableAddChunk(this, chunk, null, true, false);
-};
-
-function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
- var state = stream._readableState;
- if (chunk === null) {
- state.reading = false;
- onEofChunk(stream, state);
- } else {
- var er;
- if (!skipChunkCheck) er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
- chunk = _uint8ArrayToBuffer(chunk);
- }
+ // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
+ // Buffer instances.
+ Buffer.prototype._isBuffer = true;
- if (addToFront) {
- if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
- } else if (state.ended) {
- stream.emit('error', new Error('stream.push() after EOF'));
- } else {
- state.reading = false;
- if (state.decoder && !encoding) {
- chunk = state.decoder.write(chunk);
- if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
- } else {
- addChunk(stream, state, chunk, false);
- }
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- }
-
- return needMoreData(state);
-}
-
-function addChunk(stream, state, chunk, addToFront) {
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
-
- if (state.needReadable) emitReadable(stream);
- }
- maybeReadMore(stream, state);
-}
-
-function chunkInvalid(state, chunk) {
- var er;
- if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
-}
-
-// if it's past the high water mark, we can push in some more.
-// Also, if we have no data yet, we can stand some
-// more bytes. This is to work around cases where hwm=0,
-// such as the repl. Also, if the push() triggered a
-// readable event, and the user called read(largeNumber) such that
-// needReadable was set, then we ought to push more, so that another
-// 'readable' event will be triggered.
-function needMoreData(state) {
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
-}
-
-Readable.prototype.isPaused = function () {
- return this._readableState.flowing === false;
-};
-
-// backwards compatibility.
-Readable.prototype.setEncoding = function (enc) {
- if (!StringDecoder) StringDecoder = __webpack_require__(11).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
-};
-
-// Don't raise the hwm > 8MB
-var MAX_HWM = 0x800000;
-function computeNewHighWaterMark(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2 to prevent increasing hwm excessively in
- // tiny amounts
- n--;
- n |= n >>> 1;
- n |= n >>> 2;
- n |= n >>> 4;
- n |= n >>> 8;
- n |= n >>> 16;
- n++;
- }
- return n;
-}
-
-// This function is designed to be inlinable, so please take care when making
-// changes to the function body.
-function howMuchToRead(n, state) {
- if (n <= 0 || state.length === 0 && state.ended) return 0;
- if (state.objectMode) return 1;
- if (n !== n) {
- // Only flow one buffer at a time
- if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
- }
- // If we're asking for more than the current hwm, then raise the hwm.
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
- if (n <= state.length) return n;
- // Don't have enough
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- }
- return state.length;
-}
-
-// you can override either this method, or the async _read(n) below.
-Readable.prototype.read = function (n) {
- debug('read', n);
- n = parseInt(n, 10);
- var state = this._readableState;
- var nOrig = n;
-
- if (n !== 0) state.emittedReadable = false;
-
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
- return null;
- }
-
- n = howMuchToRead(n, state);
-
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0) endReadable(this);
- return null;
- }
-
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
-
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
-
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
-
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- } else if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0) state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (!state.reading) n = howMuchToRead(nOrig, state);
- }
-
- var ret;
- if (n > 0) ret = fromList(n, state);else ret = null;
-
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- } else {
- state.length -= n;
- }
-
- if (state.length === 0) {
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (!state.ended) state.needReadable = true;
-
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended) endReadable(this);
- }
-
- if (ret !== null) this.emit('data', ret);
-
- return ret;
-};
-
-function onEofChunk(stream, state) {
- if (state.ended) return;
- if (state.decoder) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
-
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
-}
-
-// Don't emit readable right away in sync mode, because this can trigger
-// another read() call => stack overflow. This way, it might trigger
-// a nextTick recursion warning, but that's not so bad.
-function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
- }
-}
-
-function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
-}
-
-// at this point, the user has presumably seen the 'readable' event,
-// and called read() to consume some data. that may have triggered
-// in turn another _read(n) call, in which case reading = true if
-// it's in progress.
-// However, if we're not ended, or reading, and the length < hwm,
-// then go ahead and try to read some more preemptively.
-function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- processNextTick(maybeReadMore_, stream, state);
- }
-}
-
-function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;else len = state.length;
- }
- state.readingMore = false;
-}
-
-// abstract method. to be overridden in specific implementation classes.
-// call cb(er, data) where data is <= n in length.
-// for virtual (non-string, non-buffer) streams, "length" is somewhat
-// arbitrary, and perhaps not very meaningful.
-Readable.prototype._read = function (n) {
- this.emit('error', new Error('_read() is not implemented'));
-};
-
-Readable.prototype.pipe = function (dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
-
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
-
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
-
- var endFn = doEnd ? onend : unpipe;
- if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
-
- dest.on('unpipe', onunpipe);
- function onunpipe(readable, unpipeInfo) {
- debug('onunpipe');
- if (readable === src) {
- if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
- unpipeInfo.hasUnpiped = true;
- cleanup();
- }
- }
- }
-
- function onend() {
- debug('onend');
- dest.end();
- }
-
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
-
- var cleanedUp = false;
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', unpipe);
- src.removeListener('data', ondata);
-
- cleanedUp = true;
-
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
- }
-
- // If the user pushes more data while we're writing to dest then we'll end up
- // in ondata again. However, we only want to increase awaitDrain once because
- // dest will only emit one 'drain' event for the multiple writes.
- // => Introduce a guard on increasing awaitDrain.
- var increasedAwaitDrain = false;
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- increasedAwaitDrain = false;
- var ret = dest.write(chunk);
- if (false === ret && !increasedAwaitDrain) {
- // If the user unpiped during `dest.write()`, it is possible
- // to get stuck in a permanently paused state if that write
- // also returned false.
- // => Check whether `dest` is still a piping destination.
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
- debug('false write response, pause', src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- increasedAwaitDrain = true;
- }
- src.pause();
- }
- }
-
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
- }
-
- // Make sure our error handler is attached before userland ones.
- prependListener(dest, 'error', onerror);
-
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
-
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
-
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
-
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
-
- return dest;
-};
-
-function pipeOnDrain(src) {
- return function () {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain) state.awaitDrain--;
- if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
-}
-
-Readable.prototype.unpipe = function (dest) {
- var state = this._readableState;
- var unpipeInfo = { hasUnpiped: false };
-
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0) return this;
-
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes) return this;
-
- if (!dest) dest = state.pipes;
-
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest) dest.emit('unpipe', this, unpipeInfo);
- return this;
- }
-
- // slow case. multiple pipe destinations.
-
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
-
- for (var i = 0; i < len; i++) {
- dests[i].emit('unpipe', this, unpipeInfo);
- }return this;
- }
-
- // try to find the right one.
- var index = indexOf(state.pipes, dest);
- if (index === -1) return this;
-
- state.pipes.splice(index, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
-
- dest.emit('unpipe', this, unpipeInfo);
-
- return this;
-};
-
-// set up data events if they are asked for
-// Ensure readable listeners eventually get something
-Readable.prototype.on = function (ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
-
- if (ev === 'data') {
- // Start flowing on next tick if stream isn't explicitly paused
- if (this._readableState.flowing !== false) this.resume();
- } else if (ev === 'readable') {
- var state = this._readableState;
- if (!state.endEmitted && !state.readableListening) {
- state.readableListening = state.needReadable = true;
- state.emittedReadable = false;
- if (!state.reading) {
- processNextTick(nReadingNextTick, this);
- } else if (state.length) {
- emitReadable(this);
- }
- }
- }
-
- return res;
-};
-Readable.prototype.addListener = Readable.prototype.on;
-
-function nReadingNextTick(self) {
- debug('readable nexttick read 0');
- self.read(0);
-}
-
-// pause() and resume() are remnants of the legacy readable stream API
-// If the user uses them, then switch into old mode.
-Readable.prototype.resume = function () {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- resume(this, state);
- }
- return this;
-};
-
-function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- processNextTick(resume_, stream, state);
- }
-}
-
-function resume_(stream, state) {
- if (!state.reading) {
- debug('resume read 0');
- stream.read(0);
- }
-
- state.resumeScheduled = false;
- state.awaitDrain = 0;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading) stream.read(0);
-}
-
-Readable.prototype.pause = function () {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
-};
-
-function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- while (state.flowing && stream.read() !== null) {}
-}
-
-// wrap an old-style stream as the async data source.
-// This is *not* part of the readable stream interface.
-// It is an ugly unfortunate mess of history.
-Readable.prototype.wrap = function (stream) {
- var state = this._readableState;
- var paused = false;
-
- var self = this;
- stream.on('end', function () {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) self.push(chunk);
- }
+ function swap(b, n, m) {
+ var i = b[n];
+ b[n] = b[m];
+ b[m] = i;
+ }
- self.push(null);
- });
+ Buffer.prototype.swap16 = function swap16() {
+ var len = this.length;
+ if (len % 2 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 16-bits');
+ }
+ for (var i = 0; i < len; i += 2) {
+ swap(this, i, i + 1);
+ }
+ return this;
+ };
- stream.on('data', function (chunk) {
- debug('wrapped data');
- if (state.decoder) chunk = state.decoder.write(chunk);
+ Buffer.prototype.swap32 = function swap32() {
+ var len = this.length;
+ if (len % 4 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 32-bits');
+ }
+ for (var i = 0; i < len; i += 4) {
+ swap(this, i, i + 3);
+ swap(this, i + 1, i + 2);
+ }
+ return this;
+ };
- // don't skip over falsy values in objectMode
- if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
+ Buffer.prototype.swap64 = function swap64() {
+ var len = this.length;
+ if (len % 8 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 64-bits');
+ }
+ for (var i = 0; i < len; i += 8) {
+ swap(this, i, i + 7);
+ swap(this, i + 1, i + 6);
+ swap(this, i + 2, i + 5);
+ swap(this, i + 3, i + 4);
+ }
+ return this;
+ };
+
+ Buffer.prototype.toString = function toString() {
+ var length = this.length | 0;
+ if (length === 0) return '';
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
+ return slowToString.apply(this, arguments);
+ };
+
+ Buffer.prototype.equals = function equals(b) {
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer');
+ if (this === b) return true;
+ return Buffer.compare(this, b) === 0;
+ };
+
+ Buffer.prototype.inspect = function inspect() {
+ var str = '';
+ var max = exports.INSPECT_MAX_BYTES;
+ if (this.length > 0) {
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
+ if (this.length > max) str += ' ... ';
+ }
+ return '';
+ };
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
-
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (this[i] === undefined && typeof stream[i] === 'function') {
- this[i] = function (method) {
- return function () {
- return stream[method].apply(stream, arguments);
- };
- }(i);
- }
- }
-
- // proxy certain important events.
- for (var n = 0; n < kProxyEvents.length; n++) {
- stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
- }
-
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function (n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
-
- return self;
-};
-
-// exposed for testing purposes only.
-Readable._fromList = fromList;
-
-// Pluck off n bytes from an array of buffers.
-// Length is the combined lengths of all the buffers in the list.
-// This function is designed to be inlinable, so please take care when making
-// changes to the function body.
-function fromList(n, state) {
- // nothing buffered
- if (state.length === 0) return null;
-
- var ret;
- if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
- // read it all, truncate the list
- if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
- state.buffer.clear();
- } else {
- // read part of list
- ret = fromListPartial(n, state.buffer, state.decoder);
- }
-
- return ret;
-}
-
-// Extracts only enough buffered data to satisfy the amount requested.
-// This function is designed to be inlinable, so please take care when making
-// changes to the function body.
-function fromListPartial(n, list, hasStrings) {
- var ret;
- if (n < list.head.data.length) {
- // slice is the same for buffers and strings
- ret = list.head.data.slice(0, n);
- list.head.data = list.head.data.slice(n);
- } else if (n === list.head.data.length) {
- // first chunk is a perfect match
- ret = list.shift();
- } else {
- // result spans more than one buffer
- ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
- }
- return ret;
-}
-
-// Copies a specified amount of characters from the list of buffered data
-// chunks.
-// This function is designed to be inlinable, so please take care when making
-// changes to the function body.
-function copyFromBufferString(n, list) {
- var p = list.head;
- var c = 1;
- var ret = p.data;
- n -= ret.length;
- while (p = p.next) {
- var str = p.data;
- var nb = n > str.length ? str.length : n;
- if (nb === str.length) ret += str;else ret += str.slice(0, n);
- n -= nb;
- if (n === 0) {
- if (nb === str.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = str.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
-}
-
-// Copies a specified amount of bytes from the list of buffered data chunks.
-// This function is designed to be inlinable, so please take care when making
-// changes to the function body.
-function copyFromBuffer(n, list) {
- var ret = Buffer.allocUnsafe(n);
- var p = list.head;
- var c = 1;
- p.data.copy(ret);
- n -= p.data.length;
- while (p = p.next) {
- var buf = p.data;
- var nb = n > buf.length ? buf.length : n;
- buf.copy(ret, ret.length - n, 0, nb);
- n -= nb;
- if (n === 0) {
- if (nb === buf.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = buf.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
-}
-
-function endReadable(stream) {
- var state = stream._readableState;
-
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
-
- if (!state.endEmitted) {
- state.ended = true;
- processNextTick(endReadableNT, state, stream);
- }
-}
-
-function endReadableNT(state, stream) {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
-}
-
-function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
-}
-
-function indexOf(xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
-}
-/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(5)))
-
-/***/ }),
-/* 17 */
-/***/ (function(module, exports, __webpack_require__) {
-
-module.exports = __webpack_require__(8).EventEmitter;
-
-
-/***/ }),
-/* 18 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/**/
-
-var processNextTick = __webpack_require__(6);
-/**/
-
-// undocumented cb() API, needed for core, not for public API
-function destroy(err, cb) {
- var _this = this;
-
- var readableDestroyed = this._readableState && this._readableState.destroyed;
- var writableDestroyed = this._writableState && this._writableState.destroyed;
-
- if (readableDestroyed || writableDestroyed) {
- if (cb) {
- cb(err);
- } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
- processNextTick(emitErrorNT, this, err);
- }
- return;
- }
-
- // we set destroyed to true before firing error callbacks in order
- // to make it re-entrance safe in case destroy() is called within callbacks
-
- if (this._readableState) {
- this._readableState.destroyed = true;
- }
-
- // if this is a duplex stream mark the writable part as destroyed as well
- if (this._writableState) {
- this._writableState.destroyed = true;
- }
-
- this._destroy(err || null, function (err) {
- if (!cb && err) {
- processNextTick(emitErrorNT, _this, err);
- if (_this._writableState) {
- _this._writableState.errorEmitted = true;
- }
- } else if (cb) {
- cb(err);
- }
- });
-}
-
-function undestroy() {
- if (this._readableState) {
- this._readableState.destroyed = false;
- this._readableState.reading = false;
- this._readableState.ended = false;
- this._readableState.endEmitted = false;
- }
-
- if (this._writableState) {
- this._writableState.destroyed = false;
- this._writableState.ended = false;
- this._writableState.ending = false;
- this._writableState.finished = false;
- this._writableState.errorEmitted = false;
- }
-}
-
-function emitErrorNT(self, err) {
- self.emit('error', err);
-}
-
-module.exports = {
- destroy: destroy,
- undestroy: undestroy
-};
-
-/***/ }),
-/* 19 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// a transform stream is a readable/writable stream where you do
-// something with the data. Sometimes it's called a "filter",
-// but that's not a great name for it, since that implies a thing where
-// some bits pass through, and others are simply ignored. (That would
-// be a valid example of a transform, of course.)
-//
-// While the output is causally related to the input, it's not a
-// necessarily symmetric or synchronous transformation. For example,
-// a zlib stream might take multiple plain-text writes(), and then
-// emit a single compressed chunk some time in the future.
-//
-// Here's how this works:
-//
-// The Transform stream has all the aspects of the readable and writable
-// stream classes. When you write(chunk), that calls _write(chunk,cb)
-// internally, and returns false if there's a lot of pending writes
-// buffered up. When you call read(), that calls _read(n) until
-// there's enough pending readable data buffered up.
-//
-// In a transform stream, the written data is placed in a buffer. When
-// _read(n) is called, it transforms the queued up data, calling the
-// buffered _write cb's as it consumes chunks. If consuming a single
-// written chunk would result in multiple output chunks, then the first
-// outputted bit calls the readcb, and subsequent chunks just go into
-// the read buffer, and will cause it to emit 'readable' if necessary.
-//
-// This way, back-pressure is actually determined by the reading side,
-// since _read has to be called to start processing a new chunk. However,
-// a pathological inflate type of transform can cause excessive buffering
-// here. For example, imagine a stream where every byte of input is
-// interpreted as an integer from 0-255, and then results in that many
-// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
-// 1kb of data being output. In this case, you could write a very small
-// amount of input, and end up with a very large amount of output. In
-// such a pathological inflating mechanism, there'd be no way to tell
-// the system to stop doing the transform. A single 4MB write could
-// cause the system to run out of memory.
-//
-// However, even in such a pathological case, only a single written chunk
-// would be consumed, and then the rest would wait (un-transformed) until
-// the results of the previous transformed chunk were consumed.
-
-
-
-module.exports = Transform;
-
-var Duplex = __webpack_require__(0);
-
-/**/
-var util = __webpack_require__(3);
-util.inherits = __webpack_require__(1);
-/**/
-
-util.inherits(Transform, Duplex);
-
-function TransformState(stream) {
- this.afterTransform = function (er, data) {
- return afterTransform(stream, er, data);
- };
-
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- this.writeencoding = null;
-}
-
-function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
-
- var cb = ts.writecb;
-
- if (!cb) {
- return stream.emit('error', new Error('write callback called multiple times'));
- }
-
- ts.writechunk = null;
- ts.writecb = null;
-
- if (data !== null && data !== undefined) stream.push(data);
-
- cb(er);
-
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
-}
-
-function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
-
- Duplex.call(this, options);
-
- this._transformState = new TransformState(this);
-
- var stream = this;
-
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
-
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
-
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
-
- if (typeof options.flush === 'function') this._flush = options.flush;
- }
-
- // When the writable side finishes, then flush out anything remaining.
- this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er, data) {
- done(stream, er, data);
- });else done(stream);
- });
-}
-
-Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
-};
-
-// This is the part where you do stuff!
-// override this function in implementation classes.
-// 'chunk' is an input chunk.
-//
-// Call `push(newChunk)` to pass along transformed output
-// to the readable side. You may call 'push' zero or more times.
-//
-// Call `cb(err)` when you are done with this chunk. If you pass
-// an error, then that'll put the hurt on the whole operation. If you
-// never call cb(), then you'll never get another chunk.
-Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('_transform() is not implemented');
-};
-
-Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
-};
-
-// Doesn't matter what the args are here.
-// _transform does all the work.
-// That we got here means that the readable side wants more data.
-Transform.prototype._read = function (n) {
- var ts = this._transformState;
-
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
-};
-
-Transform.prototype._destroy = function (err, cb) {
- var _this = this;
-
- Duplex.prototype._destroy.call(this, err, function (err2) {
- cb(err2);
- _this.emit('close');
- });
-};
-
-function done(stream, er, data) {
- if (er) return stream.emit('error', er);
-
- if (data !== null && data !== undefined) stream.push(data);
-
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
-
- if (ws.length) throw new Error('Calling transform done when ws.length != 0');
-
- if (ts.transforming) throw new Error('Calling transform done when still transforming');
-
- return stream.push(null);
-}
-
-/***/ }),
-/* 20 */
-/***/ (function(module, exports, __webpack_require__) {
-
-var helper = __webpack_require__(12);
-var isArray = __webpack_require__(13).isArray;
-
-var currentElement, currentElementName;
-
-function validateOptions(userOptions) {
- var options = helper.copyOptions(userOptions);
- helper.ensureFlagExists('ignoreDeclaration', options);
- helper.ensureFlagExists('ignoreInstruction', options);
- helper.ensureFlagExists('ignoreAttributes', options);
- helper.ensureFlagExists('ignoreText', options);
- helper.ensureFlagExists('ignoreComment', options);
- helper.ensureFlagExists('ignoreCdata', options);
- helper.ensureFlagExists('ignoreDoctype', options);
- helper.ensureFlagExists('compact', options);
- helper.ensureFlagExists('indentText', options);
- helper.ensureFlagExists('indentCdata', options);
- helper.ensureFlagExists('indentAttributes', options);
- helper.ensureFlagExists('indentInstruction', options);
- helper.ensureFlagExists('fullTagEmptyElement', options);
- helper.ensureFlagExists('noQuotesForNativeAttributes', options);
- helper.ensureSpacesExists(options);
- if (typeof options.spaces === 'number') {
- options.spaces = Array(options.spaces + 1).join(' ');
- }
- helper.ensureKeyExists('declaration', options);
- helper.ensureKeyExists('instruction', options);
- helper.ensureKeyExists('attributes', options);
- helper.ensureKeyExists('text', options);
- helper.ensureKeyExists('comment', options);
- helper.ensureKeyExists('cdata', options);
- helper.ensureKeyExists('doctype', options);
- helper.ensureKeyExists('type', options);
- helper.ensureKeyExists('name', options);
- helper.ensureKeyExists('elements', options);
- helper.checkFnExists('doctype', options);
- helper.checkFnExists('instruction', options);
- helper.checkFnExists('cdata', options);
- helper.checkFnExists('comment', options);
- helper.checkFnExists('text', options);
- helper.checkFnExists('instructionName', options);
- helper.checkFnExists('elementName', options);
- helper.checkFnExists('attributeName', options);
- helper.checkFnExists('attributeValue', options);
- helper.checkFnExists('attributes', options);
- helper.checkFnExists('fullTagEmptyElement', options);
- return options;
-}
-
-function writeIndentation(options, depth, firstLine) {
- return (!firstLine && options.spaces ? '\n' : '') + Array(depth + 1).join(options.spaces);
-}
-
-function writeAttributes(attributes, options, depth) {
- if (options.ignoreAttributes) {
- return '';
- }
- if ('attributesFn' in options) {
- attributes = options.attributesFn(attributes, currentElementName, currentElement);
- }
- var key, attr, attrName, quote, result = '';
- for (key in attributes) {
- if (attributes.hasOwnProperty(key)) {
- quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== 'string' ? '' : '"';
- attr = '' + attributes[key]; // ensure number and boolean are converted to String
- attr = attr.replace(/"/g, '"');
- attrName = 'attributeNameFn' in options ? options.attributeNameFn(key, attr, currentElementName, currentElement) : key;
- result += (options.spaces && options.indentAttributes? writeIndentation(options, depth+1, false) : ' ');
- result += attrName + '=' + quote + ('attributeValueFn' in options ? options.attributeValueFn(attr, key, currentElementName, currentElement) : attr) + quote;
- }
- }
- if (attributes && Object.keys(attributes).length && options.spaces && options.indentAttributes) {
- result += writeIndentation(options, depth, false);
- }
- return result;
-}
-
-function writeDeclaration(declaration, options, depth) {
- currentElement = declaration;
- currentElementName = 'xml';
- return options.ignoreDeclaration ? '' : '' + 'xml' + writeAttributes(declaration[options.attributesKey], options, depth) + '?>';
-}
-
-function writeInstruction(instruction, options, depth) {
- if (options.ignoreInstruction) {
- return '';
- }
- var key;
- for (key in instruction) {
- if (instruction.hasOwnProperty(key)) {
- break;
- }
- }
- var instructionName = 'instructionNameFn' in options ? options.instructionNameFn(key, instruction[key], currentElementName, currentElement) : key;
- if (typeof instruction[key] === 'object') {
- currentElement = instruction;
- currentElementName = instructionName;
- return '' + instructionName + writeAttributes(instruction[key][options.attributesKey], options, depth) + '?>';
- } else {
- var instructionValue = instruction[key] ? instruction[key] : '';
- if ('instructionFn' in options) instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
- return '' + instructionName + (instructionValue ? ' ' + instructionValue : '') + '?>';
- }
-}
-
-function writeComment(comment, options) {
- return options.ignoreComment ? '' : '';
-}
-
-function writeCdata(cdata, options) {
- return options.ignoreCdata ? '' : '';
-}
-
-function writeDoctype(doctype, options) {
- return options.ignoreDoctype ? '' : '';
-}
-
-function writeText(text, options) {
- if (options.ignoreText) return '';
- text = '' + text; // ensure Number and Boolean are converted to String
- text = text.replace(/&/g, '&'); // desanitize to avoid double sanitization
- text = text.replace(/&/g, '&').replace(//g, '>');
- return 'textFn' in options ? options.textFn(text, currentElementName, currentElement) : text;
-}
-
-function hasContent(element, options) {
- var i;
- if (element.elements && element.elements.length) {
- for (i = 0; i < element.elements.length; ++i) {
- switch (element.elements[i][options.typeKey]) {
- case 'text':
- if (options.indentText) {
- return true;
- }
- break; // skip to next key
- case 'cdata':
- if (options.indentCdata) {
- return true;
- }
- break; // skip to next key
- case 'instruction':
- if (options.indentInstruction) {
- return true;
- }
- break; // skip to next key
- case 'doctype':
- case 'comment':
- case 'element':
- return true;
- default:
- return true;
- }
- }
- }
- return false;
-}
-
-function writeElement(element, options, depth) {
- currentElement = element;
- currentElementName = element.name;
- var xml = '', elementName = 'elementNameFn' in options ? options.elementNameFn(element.name, element) : element.name;
- xml += '<' + elementName;
- if (element[options.attributesKey]) {
- xml += writeAttributes(element[options.attributesKey], options, depth);
- }
- var withClosingTag = element[options.elementsKey] && element[options.elementsKey].length || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
- if (!withClosingTag) {
- if ('fullTagEmptyElementFn' in options) {
- withClosingTag = options.fullTagEmptyElementFn(element.name, element);
- } else {
- withClosingTag = options.fullTagEmptyElement;
- }
- }
- if (withClosingTag) {
- xml += '>';
- if (element[options.elementsKey] && element[options.elementsKey].length) {
- xml += writeElements(element[options.elementsKey], options, depth + 1);
- currentElement = element;
- currentElementName = element.name;
- }
- xml += options.spaces && hasContent(element, options) ? '\n' + Array(depth + 1).join(options.spaces) : '';
- xml += '' + elementName + '>';
- } else {
- xml += '/>';
- }
- return xml;
-}
-
-function writeElements(elements, options, depth, firstLine) {
- return elements.reduce(function (xml, element) {
- var indent = writeIndentation(options, depth, firstLine && !xml);
- switch (element.type) {
- case 'element': return xml + indent + writeElement(element, options, depth);
- case 'comment': return xml + indent + writeComment(element[options.commentKey], options);
- case 'doctype': return xml + indent + writeDoctype(element[options.doctypeKey], options);
- case 'cdata': return xml + (options.indentCdata ? indent : '') + writeCdata(element[options.cdataKey], options);
- case 'text': return xml + (options.indentText ? indent : '') + writeText(element[options.textKey], options);
- case 'instruction':
- var instruction = {};
- instruction[element[options.nameKey]] = element[options.attributesKey] ? element : element[options.instructionKey];
- return xml + (options.indentInstruction ? indent : '') + writeInstruction(instruction, options, depth);
- }
- }, '');
-}
-
-function hasContentCompact(element, options, anyContent) {
- var key;
- for (key in element) {
- if (element.hasOwnProperty(key)) {
- switch (key) {
- case options.parentKey:
- case options.attributesKey:
- break; // skip to next key
- case options.textKey:
- if (options.indentText || anyContent) {
- return true;
- }
- break; // skip to next key
- case options.cdataKey:
- if (options.indentCdata || anyContent) {
- return true;
- }
- break; // skip to next key
- case options.instructionKey:
- if (options.indentInstruction || anyContent) {
- return true;
- }
- break; // skip to next key
- case options.doctypeKey:
- case options.commentKey:
- return true;
- default:
- return true;
- }
- }
- }
- return false;
-}
-
-function writeElementCompact(element, name, options, depth, indent) {
- currentElement = element;
- currentElementName = name;
- var elementName = 'elementNameFn' in options ? options.elementNameFn(name, element) : name;
- if (typeof element === 'undefined' || element === null) {
- return 'fullTagEmptyElementFn' in options && options.fullTagEmptyElementFn(name, element) || options.fullTagEmptyElement ? '<' + elementName + '>' + elementName + '>' : '<' + elementName + '/>';
- }
- var xml = '';
- if (name) {
- xml += '<' + elementName;
- if (typeof element !== 'object') {
- xml += '>' + writeText(element,options) + '' + elementName + '>';
- return xml;
- }
- if (element[options.attributesKey]) {
- xml += writeAttributes(element[options.attributesKey], options, depth);
- }
- var withClosingTag = hasContentCompact(element, options, true) || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
- if (!withClosingTag) {
- if ('fullTagEmptyElementFn' in options) {
- withClosingTag = options.fullTagEmptyElementFn(name, element);
- } else {
- withClosingTag = options.fullTagEmptyElement;
- }
- }
- if (withClosingTag) {
- xml += '>';
- } else {
- xml += '/>';
- return xml;
- }
- }
- xml += writeElementsCompact(element, options, depth + 1, false);
- currentElement = element;
- currentElementName = name;
- if (name) {
- xml += (indent ? writeIndentation(options, depth, false) : '') + '' + elementName + '>';
- }
- return xml;
-}
-
-function writeElementsCompact(element, options, depth, firstLine) {
- var i, key, nodes, xml = '';
- for (key in element) {
- if (element.hasOwnProperty(key)) {
- nodes = isArray(element[key]) ? element[key] : [element[key]];
- for (i = 0; i < nodes.length; ++i) {
- switch (key) {
- case options.declarationKey: xml += writeDeclaration(nodes[i], options, depth); break;
- case options.instructionKey: xml += (options.indentInstruction ? writeIndentation(options, depth, firstLine) : '') + writeInstruction(nodes[i], options, depth); break;
- case options.attributesKey: case options.parentKey: break; // skip
- case options.textKey: xml += (options.indentText ? writeIndentation(options, depth, firstLine) : '') + writeText(nodes[i], options); break;
- case options.cdataKey: xml += (options.indentCdata ? writeIndentation(options, depth, firstLine) : '') + writeCdata(nodes[i], options); break;
- case options.doctypeKey: xml += writeIndentation(options, depth, firstLine) + writeDoctype(nodes[i], options); break;
- case options.commentKey: xml += writeIndentation(options, depth, firstLine) + writeComment(nodes[i], options); break;
- default: xml += writeIndentation(options, depth, firstLine) + writeElementCompact(nodes[i], key, options, depth, hasContentCompact(nodes[i], options));
- }
- firstLine = firstLine && !xml;
- }
- }
- }
- return xml;
-}
-
-module.exports = function (js, options) {
- options = validateOptions(options);
- var xml = '';
- currentElement = js;
- currentElementName = '_root_';
- if (options.compact) {
- xml = writeElementsCompact(js, options, 0, true);
- } else {
- if (js[options.declarationKey]) {
- xml += writeDeclaration(js[options.declarationKey], options, 0);
- }
- if (js[options.elementsKey] && js[options.elementsKey].length) {
- xml += writeElements(js[options.elementsKey], options, 0, !xml);
- }
- }
- return xml;
-};
-
-
-/***/ }),
-/* 21 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/*jslint node:true */
-
-var xml2js = __webpack_require__(14);
-var xml2json = __webpack_require__(36);
-var js2xml = __webpack_require__(20);
-var json2xml = __webpack_require__(37);
-
-module.exports = {
- xml2js: xml2js,
- xml2json: xml2json,
- js2xml: js2xml,
- json2xml: json2xml
-};
-
-
-/***/ }),
-/* 22 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/* WEBPACK VAR INJECTION */(function(Buffer) {;(function (sax) { // wrapper for non-node envs
- sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
- sax.SAXParser = SAXParser
- sax.SAXStream = SAXStream
- sax.createStream = createStream
-
- // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
- // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
- // since that's the earliest that a buffer overrun could occur. This way, checks are
- // as rare as required, but as often as necessary to ensure never crossing this bound.
- // Furthermore, buffers are only tested at most once per write(), so passing a very
- // large string into write() might have undesirable effects, but this is manageable by
- // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
- // edge case, result in creating at most one complete copy of the string passed in.
- // Set to Infinity to have unlimited buffers.
- sax.MAX_BUFFER_LENGTH = 64 * 1024
-
- var buffers = [
- 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
- 'procInstName', 'procInstBody', 'entity', 'attribName',
- 'attribValue', 'cdata', 'script'
- ]
-
- sax.EVENTS = [
- 'text',
- 'processinginstruction',
- 'sgmldeclaration',
- 'doctype',
- 'comment',
- 'opentagstart',
- 'attribute',
- 'opentag',
- 'closetag',
- 'opencdata',
- 'cdata',
- 'closecdata',
- 'error',
- 'end',
- 'ready',
- 'script',
- 'opennamespace',
- 'closenamespace'
- ]
-
- function SAXParser (strict, opt) {
- if (!(this instanceof SAXParser)) {
- return new SAXParser(strict, opt)
- }
+ Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError('Argument must be a Buffer');
+ }
- var parser = this
- clearBuffers(parser)
- parser.q = parser.c = ''
- parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
- parser.opt = opt || {}
- parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
- parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
- parser.tags = []
- parser.closed = parser.closedRoot = parser.sawRoot = false
- parser.tag = parser.error = null
- parser.strict = !!strict
- parser.noscript = !!(strict || parser.opt.noscript)
- parser.state = S.BEGIN
- parser.strictEntities = parser.opt.strictEntities
- parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
- parser.attribList = []
-
- // namespaces form a prototype chain.
- // it always points at the current tag,
- // which protos to its parent tag.
- if (parser.opt.xmlns) {
- parser.ns = Object.create(rootNS)
- }
+ if (start === undefined) {
+ start = 0;
+ }
+ if (end === undefined) {
+ end = target ? target.length : 0;
+ }
+ if (thisStart === undefined) {
+ thisStart = 0;
+ }
+ if (thisEnd === undefined) {
+ thisEnd = this.length;
+ }
- // mostly just for error reporting
- parser.trackPosition = parser.opt.position !== false
- if (parser.trackPosition) {
- parser.position = parser.line = parser.column = 0
- }
- emit(parser, 'onready')
- }
-
- if (!Object.create) {
- Object.create = function (o) {
- function F () {}
- F.prototype = o
- var newf = new F()
- return newf
- }
- }
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
+ throw new RangeError('out of range index');
+ }
- if (!Object.keys) {
- Object.keys = function (o) {
- var a = []
- for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
- return a
- }
- }
-
- function checkBufferLength (parser) {
- var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
- var maxActual = 0
- for (var i = 0, l = buffers.length; i < l; i++) {
- var len = parser[buffers[i]].length
- if (len > maxAllowed) {
- // Text/cdata nodes can get big, and since they're buffered,
- // we can get here under normal conditions.
- // Avoid issues by emitting the text node now,
- // so at least it won't get any bigger.
- switch (buffers[i]) {
- case 'textNode':
- closeText(parser)
- break
-
- case 'cdata':
- emitNode(parser, 'oncdata', parser.cdata)
- parser.cdata = ''
- break
-
- case 'script':
- emitNode(parser, 'onscript', parser.script)
- parser.script = ''
- break
-
- default:
- error(parser, 'Max buffer length exceeded: ' + buffers[i])
- }
- }
- maxActual = Math.max(maxActual, len)
- }
- // schedule the next check for the earliest possible buffer overrun.
- var m = sax.MAX_BUFFER_LENGTH - maxActual
- parser.bufferCheckPosition = m + parser.position
- }
-
- function clearBuffers (parser) {
- for (var i = 0, l = buffers.length; i < l; i++) {
- parser[buffers[i]] = ''
- }
- }
+ if (thisStart >= thisEnd && start >= end) {
+ return 0;
+ }
+ if (thisStart >= thisEnd) {
+ return -1;
+ }
+ if (start >= end) {
+ return 1;
+ }
- function flushBuffers (parser) {
- closeText(parser)
- if (parser.cdata !== '') {
- emitNode(parser, 'oncdata', parser.cdata)
- parser.cdata = ''
- }
- if (parser.script !== '') {
- emitNode(parser, 'onscript', parser.script)
- parser.script = ''
- }
- }
-
- SAXParser.prototype = {
- end: function () { end(this) },
- write: write,
- resume: function () { this.error = null; return this },
- close: function () { return this.write(null) },
- flush: function () { flushBuffers(this) }
- }
-
- var Stream
- try {
- Stream = __webpack_require__(25).Stream
- } catch (ex) {
- Stream = function () {}
- }
-
- var streamWraps = sax.EVENTS.filter(function (ev) {
- return ev !== 'error' && ev !== 'end'
- })
-
- function createStream (strict, opt) {
- return new SAXStream(strict, opt)
- }
-
- function SAXStream (strict, opt) {
- if (!(this instanceof SAXStream)) {
- return new SAXStream(strict, opt)
- }
+ start >>>= 0;
+ end >>>= 0;
+ thisStart >>>= 0;
+ thisEnd >>>= 0;
- Stream.apply(this)
+ if (this === target) return 0;
- this._parser = new SAXParser(strict, opt)
- this.writable = true
- this.readable = true
+ var x = thisEnd - thisStart;
+ var y = end - start;
+ var len = Math.min(x, y);
- var me = this
+ var thisCopy = this.slice(thisStart, thisEnd);
+ var targetCopy = target.slice(start, end);
- this._parser.onend = function () {
- me.emit('end')
- }
+ for (var i = 0; i < len; ++i) {
+ if (thisCopy[i] !== targetCopy[i]) {
+ x = thisCopy[i];
+ y = targetCopy[i];
+ break;
+ }
+ }
+
+ if (x < y) return -1;
+ if (y < x) return 1;
+ return 0;
+ };
+
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
+ //
+ // Arguments:
+ // - buffer - a Buffer to search
+ // - val - a string, Buffer, or number
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
+ // - encoding - an optional encoding, relevant is val is a string
+ // - dir - true for indexOf, false for lastIndexOf
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
+ // Empty buffer means no match
+ if (buffer.length === 0) return -1;
+
+ // Normalize byteOffset
+ if (typeof byteOffset === 'string') {
+ encoding = byteOffset;
+ byteOffset = 0;
+ } else if (byteOffset > 0x7fffffff) {
+ byteOffset = 0x7fffffff;
+ } else if (byteOffset < -0x80000000) {
+ byteOffset = -0x80000000;
+ }
+ byteOffset = +byteOffset; // Coerce to Number.
+ if (isNaN(byteOffset)) {
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
+ byteOffset = dir ? 0 : buffer.length - 1;
+ }
- this._parser.onerror = function (er) {
- me.emit('error', er)
+ // Normalize byteOffset: negative offsets start from the end of the buffer
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
+ if (byteOffset >= buffer.length) {
+ if (dir) return -1;
+ else byteOffset = buffer.length - 1;
+ } else if (byteOffset < 0) {
+ if (dir) byteOffset = 0;
+ else return -1;
+ }
- // if didn't throw, then means error was handled.
- // go ahead and clear error, so we can write again.
- me._parser.error = null
- }
+ // Normalize val
+ if (typeof val === 'string') {
+ val = Buffer.from(val, encoding);
+ }
- this._decoder = null
-
- streamWraps.forEach(function (ev) {
- Object.defineProperty(me, 'on' + ev, {
- get: function () {
- return me._parser['on' + ev]
- },
- set: function (h) {
- if (!h) {
- me.removeAllListeners(ev)
- me._parser['on' + ev] = h
- return h
- }
- me.on(ev, h)
- },
- enumerable: true,
- configurable: false
- })
- })
- }
-
- SAXStream.prototype = Object.create(Stream.prototype, {
- constructor: {
- value: SAXStream
- }
- })
-
- SAXStream.prototype.write = function (data) {
- if (typeof Buffer === 'function' &&
- typeof Buffer.isBuffer === 'function' &&
- Buffer.isBuffer(data)) {
- if (!this._decoder) {
- var SD = __webpack_require__(11).StringDecoder
- this._decoder = new SD('utf8')
- }
- data = this._decoder.write(data)
- }
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
+ if (Buffer.isBuffer(val)) {
+ // Special case: looking for empty string/buffer always fails
+ if (val.length === 0) {
+ return -1;
+ }
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
+ } else if (typeof val === 'number') {
+ val = val & 0xff; // Search for a byte value [0-255]
+ if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') {
+ if (dir) {
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
+ } else {
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
+ }
+ }
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
+ }
- this._parser.write(data.toString())
- this.emit('data', data)
- return true
- }
+ throw new TypeError('val must be string, number or Buffer');
+ }
- SAXStream.prototype.end = function (chunk) {
- if (chunk && chunk.length) {
- this.write(chunk)
- }
- this._parser.end()
- return true
- }
-
- SAXStream.prototype.on = function (ev, handler) {
- var me = this
- if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
- me._parser['on' + ev] = function () {
- var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
- args.splice(0, 0, ev)
- me.emit.apply(me, args)
- }
- }
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
+ var indexSize = 1;
+ var arrLength = arr.length;
+ var valLength = val.length;
- return Stream.prototype.on.call(me, ev, handler)
- }
-
- // this really needs to be replaced with character classes.
- // XML allows all manner of ridiculous numbers and digits.
- var CDATA = '[CDATA['
- var DOCTYPE = 'DOCTYPE'
- var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
- var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
- var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
-
- // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
- // This implementation works on strings, a single character at a time
- // as such, it cannot ever support astral-plane characters (10000-EFFFF)
- // without a significant breaking change to either this parser, or the
- // JavaScript language. Implementation of an emoji-capable xml parser
- // is left as an exercise for the reader.
- var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
-
- var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
-
- var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
- var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
-
- function isWhitespace (c) {
- return c === ' ' || c === '\n' || c === '\r' || c === '\t'
- }
-
- function isQuote (c) {
- return c === '"' || c === '\''
- }
-
- function isAttribEnd (c) {
- return c === '>' || isWhitespace(c)
- }
-
- function isMatch (regex, c) {
- return regex.test(c)
- }
-
- function notMatch (regex, c) {
- return !isMatch(regex, c)
- }
-
- var S = 0
- sax.STATE = {
- BEGIN: S++, // leading byte order mark or whitespace
- BEGIN_WHITESPACE: S++, // leading whitespace
- TEXT: S++, // general stuff
- TEXT_ENTITY: S++, // & and such.
- OPEN_WAKA: S++, // <
- SGML_DECL: S++, //
- SCRIPT: S++, //
diff --git a/snippets/common_ui/sheet_sidebar_select/index.js b/snippets/common_ui/sheet_sidebar_select/index.js
index 7d597b6..9b6cdad 100644
--- a/snippets/common_ui/sheet_sidebar_select/index.js
+++ b/snippets/common_ui/sheet_sidebar_select/index.js
@@ -7,10 +7,7 @@
* Create menu
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('My tools')
- .addItem('Show sidebar', 'userActionShowSidebar')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('My tools').addItem('Show sidebar', 'userActionShowSidebar').addToUi();
}
/**
diff --git a/snippets/customfunctions/PARSEAPINET/Code.js b/snippets/customfunctions/PARSEAPINET/Code.js
index 7b592b5..1dc0d13 100644
--- a/snippets/customfunctions/PARSEAPINET/Code.js
+++ b/snippets/customfunctions/PARSEAPINET/Code.js
@@ -4,12 +4,11 @@
* @param {Boolean} increase
*/
function PARSEAPINET(pics, increase) {
- return (Array.isArray(pics) ? pics : [[pics]]).map(row => {
+ return (Array.isArray(pics) ? pics : [[pics]]).map((row) => {
try {
const obj = JSON.parse(row[0]);
- if (!!increase === true)
- return obj.map(pic => Array(pic[1]).fill(pic[4])).flat();
- else return obj.map(pic => pic[4]);
+ if (!!increase === true) return obj.map((pic) => Array(pic[1]).fill(pic[4])).flat();
+ else return obj.map((pic) => pic[4]);
} catch (err) {
return ['#ERR.PARSEAPINET'];
}
diff --git a/snippets/customfunctions/PARSEAPINET/appsscript.json b/snippets/customfunctions/PARSEAPINET/appsscript.json
index 3cf1d24..e867f29 100644
--- a/snippets/customfunctions/PARSEAPINET/appsscript.json
+++ b/snippets/customfunctions/PARSEAPINET/appsscript.json
@@ -1,7 +1,6 @@
{
"timeZone": "America/New_York",
- "dependencies": {
- },
+ "dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/customfunctions/RAINREPORT/appsscript.json b/snippets/customfunctions/RAINREPORT/appsscript.json
index d89c863..a6935af 100644
--- a/snippets/customfunctions/RAINREPORT/appsscript.json
+++ b/snippets/customfunctions/RAINREPORT/appsscript.json
@@ -2,4 +2,4 @@
"timeZone": "Europe/Moscow",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/customfunctions/RAINREPORT/index.js b/snippets/customfunctions/RAINREPORT/index.js
index d806ff8..784c25e 100644
--- a/snippets/customfunctions/RAINREPORT/index.js
+++ b/snippets/customfunctions/RAINREPORT/index.js
@@ -30,8 +30,7 @@ function RAINREPORT(rain, skipEmpty = true) {
data: [],
name: _cloud_[i],
};
- if (_report_[_cloud_[i]].data.indexOf(item) === -1)
- _report_[_cloud_[i]].data.push(item);
+ if (_report_[_cloud_[i]].data.indexOf(item) === -1) _report_[_cloud_[i]].data.push(item);
});
return Object.keys(_report_)
.sort()
diff --git a/snippets/customfunctions/customfunction_flatten-arguments/appsscript.json b/snippets/customfunctions/customfunction_flatten-arguments/appsscript.json
index beb0c43..71d934d 100644
--- a/snippets/customfunctions/customfunction_flatten-arguments/appsscript.json
+++ b/snippets/customfunctions/customfunction_flatten-arguments/appsscript.json
@@ -1,8 +1,6 @@
{
"timeZone": "Europe/Moscow",
- "oauthScopes": [
- "https://www.googleapis.com/auth/spreadsheets"
- ],
+ "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"],
"dependencies": {},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/customfunctions/customfunction_flatten-arguments/flatten-arguments.js b/snippets/customfunctions/customfunction_flatten-arguments/flatten-arguments.js
index 56c90a6..bb2c103 100644
--- a/snippets/customfunctions/customfunction_flatten-arguments/flatten-arguments.js
+++ b/snippets/customfunctions/customfunction_flatten-arguments/flatten-arguments.js
@@ -8,16 +8,11 @@ function OHLCV_CEXIO_1d(date, pair) {
try {
date = Array.isArray(date) ? date.flat(2) : [date];
pair = Array.isArray(pair) ? pair.flat(2) : [pair];
- return date.map(function(date) {
- return pair.map(function(pair) {
- var url =
- 'https://cex.io/api/ohlcv/hd/' +
- date +
- '/' +
- pair +
- '/';
+ return date.map(function (date) {
+ return pair.map(function (pair) {
+ var url = 'https://cex.io/api/ohlcv/hd/' + date + '/' + pair + '/';
var response = UrlFetchApp.fetch(url, {
- muteHttpExceptions: true
+ muteHttpExceptions: true,
});
var json = response.getContentText();
// return json;
@@ -27,10 +22,6 @@ function OHLCV_CEXIO_1d(date, pair) {
});
});
} catch (err) {
- return Utilities.formatString(
- '%s\n%s',
- err.message,
- err.stack
- );
+ return Utilities.formatString('%s\n%s', err.message, err.stack);
}
}
diff --git a/snippets/customfunctions/customfunction_jaro-winker-distance/appsscript.json b/snippets/customfunctions/customfunction_jaro-winker-distance/appsscript.json
index c7983be..27a31e3 100644
--- a/snippets/customfunctions/customfunction_jaro-winker-distance/appsscript.json
+++ b/snippets/customfunctions/customfunction_jaro-winker-distance/appsscript.json
@@ -3,4 +3,4 @@
"oauthScopes": [],
"dependencies": {},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/customfunctions/customfunction_jaro-winker-distance/config.json b/snippets/customfunctions/customfunction_jaro-winker-distance/config.json
index 51685ce..a6c4c2b 100644
--- a/snippets/customfunctions/customfunction_jaro-winker-distance/config.json
+++ b/snippets/customfunctions/customfunction_jaro-winker-distance/config.json
@@ -1,6 +1,4 @@
{
"type": "container-bound-sheet",
- "src": [
- "./node_modules/jaro-winkler/index.js"
- ]
-}
\ No newline at end of file
+ "src": ["./node_modules/jaro-winkler/index.js"]
+}
diff --git a/snippets/customfunctions/customfunction_union_ranges/appsscript.json b/snippets/customfunctions/customfunction_union_ranges/appsscript.json
index ec36b84..37f65c3 100644
--- a/snippets/customfunctions/customfunction_union_ranges/appsscript.json
+++ b/snippets/customfunctions/customfunction_union_ranges/appsscript.json
@@ -5,4 +5,4 @@
"libraries": []
},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/customfunctions/customfunction_union_ranges/customfunction_union_ranges.js b/snippets/customfunctions/customfunction_union_ranges/customfunction_union_ranges.js
index 11b0c33..e289596 100644
--- a/snippets/customfunctions/customfunction_union_ranges/customfunction_union_ranges.js
+++ b/snippets/customfunctions/customfunction_union_ranges/customfunction_union_ranges.js
@@ -23,7 +23,7 @@ function UNIONRANGES(ranges) {
if (length > 400000) return '#ERROR_OVER_TOTAL_CELLS: ' + length;
for (var i = 0; i < arguments.length; i++)
result = result.concat(
- arguments[i].filter(function(el) {
+ arguments[i].filter(function (el) {
return el.join('').length > 0;
})
);
diff --git a/snippets/customfunctions/using_cache_service/appsscript.json b/snippets/customfunctions/using_cache_service/appsscript.json
index d89c863..a6935af 100644
--- a/snippets/customfunctions/using_cache_service/appsscript.json
+++ b/snippets/customfunctions/using_cache_service/appsscript.json
@@ -2,4 +2,4 @@
"timeZone": "Europe/Moscow",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/api_find_and_replace_named_ranges/appsscript.json b/snippets/docs/api_find_and_replace_named_ranges/appsscript.json
index 6e03377..b5960b6 100644
--- a/snippets/docs/api_find_and_replace_named_ranges/appsscript.json
+++ b/snippets/docs/api_find_and_replace_named_ranges/appsscript.json
@@ -1,12 +1,14 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Docs",
- "serviceId": "docs",
- "version": "v1"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Docs",
+ "serviceId": "docs",
+ "version": "v1"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/api_find_and_replace_named_ranges/index.js b/snippets/docs/api_find_and_replace_named_ranges/index.js
index 9698329..991386e 100644
--- a/snippets/docs/api_find_and_replace_named_ranges/index.js
+++ b/snippets/docs/api_find_and_replace_named_ranges/index.js
@@ -35,7 +35,7 @@ function run() {
* @return {GoogleAppsScript.Docs.Schema.BatchUpdateDocumentResponse}
*/
function replaceAllText(replacements, docId) {
- const requests = replacements.map(replacement => {
+ const requests = replacements.map((replacement) => {
const substringMatchCriteria = Docs.newSubstringMatchCriteria();
substringMatchCriteria.matchCase = false;
substringMatchCriteria.text = replacement.substitution;
@@ -53,10 +53,7 @@ function replaceAllText(replacements, docId) {
const batchUpdateDocumentRequest = Docs.newBatchUpdateDocumentRequest();
batchUpdateDocumentRequest.requests = requests;
- const batchUpdateDocumentResponse = Docs.Documents.batchUpdate(
- batchUpdateDocumentRequest,
- docId
- );
+ const batchUpdateDocumentResponse = Docs.Documents.batchUpdate(batchUpdateDocumentRequest, docId);
return batchUpdateDocumentResponse;
}
diff --git a/snippets/docs/create_footnote/appsscript.json b/snippets/docs/create_footnote/appsscript.json
index 6e03377..b5960b6 100644
--- a/snippets/docs/create_footnote/appsscript.json
+++ b/snippets/docs/create_footnote/appsscript.json
@@ -1,12 +1,14 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Docs",
- "serviceId": "docs",
- "version": "v1"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Docs",
+ "serviceId": "docs",
+ "version": "v1"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/create_footnote/index.js b/snippets/docs/create_footnote/index.js
index 4f1f7b9..4f1d28c 100644
--- a/snippets/docs/create_footnote/index.js
+++ b/snippets/docs/create_footnote/index.js
@@ -19,11 +19,7 @@ function run() {
* @param {string} id
* @returns Result of batch updates or an issue reply
*/
-function createFootnoteWithText_(
- text,
- bodyIndex,
- id = DocumentApp.getActiveDocument().getId()
-) {
+function createFootnoteWithText_(text, bodyIndex, id = DocumentApp.getActiveDocument().getId()) {
const createFootnoteReplies = createFootnote_(bodyIndex, id);
if (createFootnoteReplies && createFootnoteReplies.replies.length) {
const reply = createFootnoteReplies.replies[0];
@@ -36,10 +32,7 @@ function createFootnoteWithText_(
* Insert an empty footnote to body index
* @param {number} bodyIndex
*/
-function createFootnote_(
- bodyIndex,
- id = DocumentApp.getActiveDocument().getId()
-) {
+function createFootnote_(bodyIndex, id = DocumentApp.getActiveDocument().getId()) {
return Docs.Documents.batchUpdate(
{
requests: {
@@ -59,11 +52,7 @@ function createFootnote_(
* @param {string} text
* @param {string} segmentId
*/
-function appendTextTo_(
- text,
- segmentId = undefined,
- id = DocumentApp.getActiveDocument().getId()
-) {
+function appendTextTo_(text, segmentId = undefined, id = DocumentApp.getActiveDocument().getId()) {
return Docs.Documents.batchUpdate(
{
requests: {
diff --git a/snippets/docs/docs_push_2D_array_to_table/appsscript.json b/snippets/docs/docs_push_2D_array_to_table/appsscript.json
index 9b192e8..27e7f91 100644
--- a/snippets/docs/docs_push_2D_array_to_table/appsscript.json
+++ b/snippets/docs/docs_push_2D_array_to_table/appsscript.json
@@ -1,10 +1,7 @@
{
"timeZone": "Europe/Moscow",
- "oauthScopes": [
- "https://www.googleapis.com/auth/documents"
- ],
- "dependencies": {
- },
+ "oauthScopes": ["https://www.googleapis.com/auth/documents"],
+ "dependencies": {},
"exceptionLogging": "STACKDRIVER",
- "runtimeVersion": "V8"
-}
\ No newline at end of file
+ "runtimeVersion": "V8"
+}
diff --git a/snippets/docs/document_center-align-table-cell-content/appsscript.json b/snippets/docs/document_center-align-table-cell-content/appsscript.json
index 5dd7074..7301f4f 100644
--- a/snippets/docs/document_center-align-table-cell-content/appsscript.json
+++ b/snippets/docs/document_center-align-table-cell-content/appsscript.json
@@ -1,9 +1,6 @@
{
"timeZone": "Europe/Moscow",
- "oauthScopes": [
- "https://www.googleapis.com/auth/documents"
- ],
- "dependencies": {
- },
+ "oauthScopes": ["https://www.googleapis.com/auth/documents"],
+ "dependencies": {},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/document_center-align-table-cell-content/center-align-table-cell-content.js b/snippets/docs/document_center-align-table-cell-content/center-align-table-cell-content.js
index 0601dc3..c05a5ba 100644
--- a/snippets/docs/document_center-align-table-cell-content/center-align-table-cell-content.js
+++ b/snippets/docs/document_center-align-table-cell-content/center-align-table-cell-content.js
@@ -17,12 +17,10 @@ function run() {
*/
function setСenterAlignmentForAllTables_(doc) {
var style = {};
- style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
- DocumentApp.HorizontalAlignment.CENTER;
- style[DocumentApp.Attribute.VERTICAL_ALIGNMENT] =
- DocumentApp.VerticalAlignment.CENTER;
+ style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.CENTER;
+ style[DocumentApp.Attribute.VERTICAL_ALIGNMENT] = DocumentApp.VerticalAlignment.CENTER;
var tables = doc.getBody().getTables();
- tables.forEach(function(table) {
+ tables.forEach(function (table) {
var numRows = table.getNumRows();
var indexRow = 0;
while (indexRow < numRows) {
@@ -45,26 +43,17 @@ function setСenterAlignmentForAllTables_(doc) {
*/
function setСenterAlignmentForAllTables2_(doc) {
var style = {};
- style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
- DocumentApp.HorizontalAlignment.CENTER;
- style[DocumentApp.Attribute.VERTICAL_ALIGNMENT] =
- DocumentApp.VerticalAlignment.CENTER;
+ style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.CENTER;
+ style[DocumentApp.Attribute.VERTICAL_ALIGNMENT] = DocumentApp.VerticalAlignment.CENTER;
var body = doc.getBody();
for (var i = 0; i < body.getNumChildren(); i++) {
if (body.getChild(i).getType() == 'TABLE') {
var table = body.getChild(i).asTable();
var rows = table.getNumRows();
- var cols = table
- .getChild(0)
- .asTableRow()
- .getNumChildren();
+ var cols = table.getChild(0).asTableRow().getNumChildren();
for (var j = 0; j < rows; j++) {
for (var k = 0; k < cols; k++) {
- body
- .getChild(i)
- .asTable()
- .getCell(j, k)
- .setAttributes(style);
+ body.getChild(i).asTable().getCell(j, k).setAttributes(style);
}
}
}
diff --git a/snippets/docs/document_copy-inline-image/appsscript.json b/snippets/docs/document_copy-inline-image/appsscript.json
index 59a9c29..b0cdab3 100644
--- a/snippets/docs/document_copy-inline-image/appsscript.json
+++ b/snippets/docs/document_copy-inline-image/appsscript.json
@@ -10,4 +10,4 @@
"libraries": []
},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/document_copy-inline-image/config.json b/snippets/docs/document_copy-inline-image/config.json
index 686319f..e41bba2 100644
--- a/snippets/docs/document_copy-inline-image/config.json
+++ b/snippets/docs/document_copy-inline-image/config.json
@@ -1,7 +1,4 @@
{
"type": "standalone",
- "src": [
- "./shims/Array.find.js",
- "./shims/Array.findIndex.js"
- ]
-}
\ No newline at end of file
+ "src": ["./shims/Array.find.js", "./shims/Array.findIndex.js"]
+}
diff --git a/snippets/docs/document_copy-inline-image/copy-inline-image.js b/snippets/docs/document_copy-inline-image/copy-inline-image.js
index da281b2..4a123a8 100644
--- a/snippets/docs/document_copy-inline-image/copy-inline-image.js
+++ b/snippets/docs/document_copy-inline-image/copy-inline-image.js
@@ -5,28 +5,23 @@
* @param {number} index The index of the inlineImage. Starts from 0
*/
function getBlobImageByIndexFromDoc_(from, index) {
- var template =
- 'https://docs.google.com/feeds/download/documents/export/Export' +
- '?id=%s&exportFormat=zip';
+ var template = 'https://docs.google.com/feeds/download/documents/export/Export' + '?id=%s&exportFormat=zip';
var url = Utilities.formatString(template, from);
var file = UrlFetchApp.fetch(url, {
headers: {
- Authorization: 'Bearer ' + ScriptApp.getOAuthToken()
- }
+ Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),
+ },
}).getBlob();
var blobs = Utilities.unzip(file);
var imagePath = blobs
- .find(function(b) {
+ .find(function (b) {
return /^.+?\.html$/.test(b.getName());
})
.getDataAsString()
.match(//g)
- [index].replace(
- /^.*?"(images\/image\d+\..{2,4})".*?$/g,
- '$1'
- );
+ [index].replace(/^.*?"(images\/image\d+\..{2,4})".*?$/g, '$1');
var patt = new RegExp(imagePath);
- var blob = blobs.find(function(b) {
+ var blob = blobs.find(function (b) {
return patt.test(b.getName());
});
return blob;
@@ -37,14 +32,6 @@ function getBlobImageByIndexFromDoc_(from, index) {
* @ignore
*/
function run() {
- var blob = getBlobImageByIndexFromDoc_(
- '1HhlzUD2RuN0coxp7IuOBwiS4hYWAKdjUzUyiyoFjH4s',
- 0
- );
- DocumentApp.openById(
- '1h7_W36wN-9p2Msabj-ZBcHLGQWdX-QtB_YqBpsmrMp0'
- )
- .getBody()
- .clear()
- .appendImage(blob);
+ var blob = getBlobImageByIndexFromDoc_('1HhlzUD2RuN0coxp7IuOBwiS4hYWAKdjUzUyiyoFjH4s', 0);
+ DocumentApp.openById('1h7_W36wN-9p2Msabj-ZBcHLGQWdX-QtB_YqBpsmrMp0').getBody().clear().appendImage(blob);
}
diff --git a/snippets/docs/document_paste-data-to-selection/document_paste-data-to-selection.js b/snippets/docs/document_paste-data-to-selection/document_paste-data-to-selection.js
index 0fbd9af..5af3700 100644
--- a/snippets/docs/document_paste-data-to-selection/document_paste-data-to-selection.js
+++ b/snippets/docs/document_paste-data-to-selection/document_paste-data-to-selection.js
@@ -14,13 +14,11 @@ function pasteTextToSelection_(text) {
var selection = doc.getSelection();
if (selection) {
var rEls = selection.getRangeElements();
- rEls.forEach(function(rEl) {
+ rEls.forEach(function (rEl) {
var element = rEl.getElement();
switch (element.getType()) {
case DocumentApp.ElementType.TEXT:
- element
- .asText()
- .deleteText(rEl.getStartOffset(), rEl.getEndOffsetInclusive());
+ element.asText().deleteText(rEl.getStartOffset(), rEl.getEndOffsetInclusive());
break;
case DocumentApp.ElementType.PARAGRAPH:
element.removeFromParent();
diff --git a/snippets/docs/find_and_replace_bulk/appsscript.json b/snippets/docs/find_and_replace_bulk/appsscript.json
index 6e03377..b5960b6 100644
--- a/snippets/docs/find_and_replace_bulk/appsscript.json
+++ b/snippets/docs/find_and_replace_bulk/appsscript.json
@@ -1,12 +1,14 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Docs",
- "serviceId": "docs",
- "version": "v1"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Docs",
+ "serviceId": "docs",
+ "version": "v1"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/find_and_replace_bulk/index.js b/snippets/docs/find_and_replace_bulk/index.js
index 9cb9af5..7b412a5 100644
--- a/snippets/docs/find_and_replace_bulk/index.js
+++ b/snippets/docs/find_and_replace_bulk/index.js
@@ -34,10 +34,7 @@ function run() {
* @param {string} id The Doc id
* @return {GoogleAppsScript.Docs.Schema.BatchUpdateDocumentResponse}
*/
-function replaceAllText(
- replacements,
- id = DocumentApp.getActiveDocument().getId()
-) {
+function replaceAllText(replacements, id = DocumentApp.getActiveDocument().getId()) {
const requests = replacements.map((replacement) => {
const substringMatchCriteria = Docs.newSubstringMatchCriteria();
substringMatchCriteria.matchCase = false;
@@ -56,10 +53,7 @@ function replaceAllText(
const batchUpdateDocumentRequest = Docs.newBatchUpdateDocumentRequest();
batchUpdateDocumentRequest.requests = requests;
- const batchUpdateDocumentResponse = Docs.Documents.batchUpdate(
- batchUpdateDocumentRequest,
- id
- );
+ const batchUpdateDocumentResponse = Docs.Documents.batchUpdate(batchUpdateDocumentRequest, id);
return batchUpdateDocumentResponse;
}
diff --git a/snippets/docs/uncheck-checklist/appsscript.json b/snippets/docs/uncheck-checklist/appsscript.json
index 6e03377..b5960b6 100644
--- a/snippets/docs/uncheck-checklist/appsscript.json
+++ b/snippets/docs/uncheck-checklist/appsscript.json
@@ -1,12 +1,14 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Docs",
- "serviceId": "docs",
- "version": "v1"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Docs",
+ "serviceId": "docs",
+ "version": "v1"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/docs/uncheck-checklist/triggerActions.js b/snippets/docs/uncheck-checklist/triggerActions.js
index 4b0b718..3452be7 100644
--- a/snippets/docs/uncheck-checklist/triggerActions.js
+++ b/snippets/docs/uncheck-checklist/triggerActions.js
@@ -2,8 +2,5 @@
* Creates the user menu for handy use.
*/
function onOpen() {
- DocumentApp.getUi()
- .createMenu('Checklists')
- .addItem('Mark the list as its last item', 'run')
- .addToUi();
+ DocumentApp.getUi().createMenu('Checklists').addItem('Mark the list as its last item', 'run').addToUi();
}
diff --git a/snippets/drive/convert_file_to_drive_format/appsscript.json b/snippets/drive/convert_file_to_drive_format/appsscript.json
index 41a1288..7739bca 100644
--- a/snippets/drive/convert_file_to_drive_format/appsscript.json
+++ b/snippets/drive/convert_file_to_drive_format/appsscript.json
@@ -11,4 +11,4 @@
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/drive/copying_access_rights_between_two_entities/appsscript.json b/snippets/drive/copying_access_rights_between_two_entities/appsscript.json
index 11954e8..1b628a7 100644
--- a/snippets/drive/copying_access_rights_between_two_entities/appsscript.json
+++ b/snippets/drive/copying_access_rights_between_two_entities/appsscript.json
@@ -18,4 +18,4 @@
}
]
}
-}
\ No newline at end of file
+}
diff --git a/snippets/drive/drive-upload_file_from_url/upload_file_from_url.js b/snippets/drive/drive-upload_file_from_url/upload_file_from_url.js
index ca77957..3431b54 100644
--- a/snippets/drive/drive-upload_file_from_url/upload_file_from_url.js
+++ b/snippets/drive/drive-upload_file_from_url/upload_file_from_url.js
@@ -9,8 +9,7 @@
* User action. Runs the snippet
*/
function userActionRun() {
- var url =
- 'https://admin.singlaapparels.com/Main/fileurl/64F619B8-C2BE-4EDF-BF9B-01FD60C5D957/4/RakeshKumar.jpg';
+ var url = 'https://admin.singlaapparels.com/Main/fileurl/64F619B8-C2BE-4EDF-BF9B-01FD60C5D957/4/RakeshKumar.jpg';
var blob = UrlFetchApp.fetch(url).getBlob();
DriveApp.createFile(blob);
}
diff --git a/snippets/drive/drive_change_user_role/appsscript.json b/snippets/drive/drive_change_user_role/appsscript.json
index ecf54ca..f3b91a0 100644
--- a/snippets/drive/drive_change_user_role/appsscript.json
+++ b/snippets/drive/drive_change_user_role/appsscript.json
@@ -11,4 +11,4 @@
"libraries": []
},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/drive/driveapp_change_owner_in_folder/appsscript.json b/snippets/drive/driveapp_change_owner_in_folder/appsscript.json
index f1f01e7..b0f2b4f 100644
--- a/snippets/drive/driveapp_change_owner_in_folder/appsscript.json
+++ b/snippets/drive/driveapp_change_owner_in_folder/appsscript.json
@@ -4,4 +4,4 @@
"libraries": []
},
"exceptionLogging": "STACKDRIVER"
-}
\ No newline at end of file
+}
diff --git a/snippets/drive/save_file_to_drive/index.js b/snippets/drive/save_file_to_drive/index.js
index c22b854..2300d5d 100644
--- a/snippets/drive/save_file_to_drive/index.js
+++ b/snippets/drive/save_file_to_drive/index.js
@@ -6,9 +6,7 @@
*/
function run() {
// https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html
- const file = saveFileFromUrl_(
- 'https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv'
- );
+ const file = saveFileFromUrl_('https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv');
console.log(file.getName());
}
diff --git a/snippets/drive/utf8_bom_to_utf8/utf8_bom_to_utf8.js b/snippets/drive/utf8_bom_to_utf8/utf8_bom_to_utf8.js
index dc4b02e..69f83fe 100644
--- a/snippets/drive/utf8_bom_to_utf8/utf8_bom_to_utf8.js
+++ b/snippets/drive/utf8_bom_to_utf8/utf8_bom_to_utf8.js
@@ -9,16 +9,11 @@
* User action. Runs the snippet
*/
function userActionRun() {
- const blob = DriveApp.getFileById(
- '1ZA6qJA7s6MWuCb65dx0E6GtWi5eL7hYc'
- ).getBlob();
+ const blob = DriveApp.getFileById('1ZA6qJA7s6MWuCb65dx0E6GtWi5eL7hYc').getBlob();
const isUTF8BOM = isUTF8BOM_(blob);
- const content = (isUTF8BOM.BOM
- ? Utilities.newBlob(isUTF8BOM.bytes.slice(3))
- : blob
- ).getDataAsString('UTF-8');
+ const content = (isUTF8BOM.BOM ? Utilities.newBlob(isUTF8BOM.bytes.slice(3)) : blob).getDataAsString('UTF-8');
const xml = XmlService.parse(content);
@@ -27,7 +22,7 @@ function userActionRun() {
root
.getChild('ExportData')
.getChildren('tag')
- .forEach(child => console.log(child.getAttribute('Value').getValue()));
+ .forEach((child) => console.log(child.getAttribute('Value').getValue()));
console.log(XmlService.getPrettyFormat().format(xml.getRootElement()));
}
diff --git a/snippets/external/czech-national-bank-public-api/index.js b/snippets/external/czech-national-bank-public-api/index.js
index 22e95b2..14b5c09 100644
--- a/snippets/external/czech-national-bank-public-api/index.js
+++ b/snippets/external/czech-national-bank-public-api/index.js
@@ -13,7 +13,7 @@ function run() {
const data = Utilities.newBlob(httpResponse.getContent(), 'plain/text')
.getDataAsString()
.split('\n')
- .map((line) => line.split('|'))
+ .map((line) => line.split('|'))
.slice(1);
console.log(data);
/*
diff --git a/snippets/external/external_smartlabru/README.md b/snippets/external/external_smartlabru/README.md
index 1b313fc..678ca8a 100755
--- a/snippets/external/external_smartlabru/README.md
+++ b/snippets/external/external_smartlabru/README.md
@@ -1,5 +1,5 @@
-README
-=============
-* DOCS https://script.google.com/macros/library/versions/d/MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h
-* SUBJECT http://smart-lab.ru/indeks-optimizma/
-* LIB KEY MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h
\ No newline at end of file
+# README
+
+- DOCS https://script.google.com/macros/library/versions/d/MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h
+- SUBJECT http://smart-lab.ru/indeks-optimizma/
+- LIB KEY MUjQ0enKqP-RKxsvJNoWR8vVsbLCrn_6h
diff --git a/snippets/extra/xml-js_demo/init.js b/snippets/extra/xml-js_demo/init.js
index 46aa3ee..15d477f 100644
--- a/snippets/extra/xml-js_demo/init.js
+++ b/snippets/extra/xml-js_demo/init.js
@@ -1,6 +1,5 @@
-
-!function(global){
+!(function (global) {
const window = {};
global.window = window;
global.convert = window;
-}(this);
+})(this);
diff --git a/snippets/forms/create_file_upload_field/index.js b/snippets/forms/create_file_upload_field/index.js
index e8c0287..5240514 100644
--- a/snippets/forms/create_file_upload_field/index.js
+++ b/snippets/forms/create_file_upload_field/index.js
@@ -12,14 +12,11 @@ function run() {
// Create a copy of the Form and fill it with other items
// Copy
- const newForm = FormApp.openById(
- DriveApp.getFileById(form.getId()).makeCopy().getId()
- );
+ const newForm = FormApp.openById(DriveApp.getFileById(form.getId()).makeCopy().getId());
// Delete all items except one
newForm.getItems().forEach((item) => {
- if (!fileUploadItems.some((entry) => entry.index === item.getIndex()))
- newForm.deleteItem(item);
+ if (!fileUploadItems.some((entry) => entry.index === item.getIndex())) newForm.deleteItem(item);
});
// Add a TEXT item
diff --git a/snippets/forms/get_pre_fill_entries_map/index.js b/snippets/forms/get_pre_fill_entries_map/index.js
index ec8a242..a36b24d 100644
--- a/snippets/forms/get_pre_fill_entries_map/index.js
+++ b/snippets/forms/get_pre_fill_entries_map/index.js
@@ -53,7 +53,7 @@ function getPreFillEntriesMap_(form) {
var params = prefilledUrl
.split('&entry.')
- .map(str => str.split('=')[0])
+ .map((str) => str.split('=')[0])
.slice(1);
return {
@@ -76,30 +76,13 @@ function getDefaultItemResponse_(item) {
case FormApp.ItemType.PARAGRAPH_TEXT:
return item.asParagraphTextItem().createResponse('-');
case FormApp.ItemType.MULTIPLE_CHOICE:
- return item.asMultipleChoiceItem().createResponse(
- item
- .asMultipleChoiceItem()
- .getChoices()[0]
- .getValue()
- );
+ return item.asMultipleChoiceItem().createResponse(item.asMultipleChoiceItem().getChoices()[0].getValue());
case FormApp.ItemType.CHECKBOX:
- return item.asCheckboxItem().createResponse([
- item
- .asCheckboxItem()
- .getChoices()[0]
- .getValue(),
- ]);
+ return item.asCheckboxItem().createResponse([item.asCheckboxItem().getChoices()[0].getValue()]);
case FormApp.ItemType.LIST:
- return item.asListItem().createResponse(
- item
- .asListItem()
- .getChoices()[0]
- .getValue()
- );
+ return item.asListItem().createResponse(item.asListItem().getChoices()[0].getValue());
case FormApp.ItemType.SCALE:
- return item
- .asScaleItem()
- .createResponse(item.asScaleItem().getLowerBound());
+ return item.asScaleItem().createResponse(item.asScaleItem().getLowerBound());
case FormApp.ItemType.GRID: {
const columns = item.asGridItem().getColumns();
const resp = item
diff --git a/snippets/gae/start_stop_instance/GAE/instances.js b/snippets/gae/start_stop_instance/GAE/instances.js
index c79013c..68ef50d 100644
--- a/snippets/gae/start_stop_instance/GAE/instances.js
+++ b/snippets/gae/start_stop_instance/GAE/instances.js
@@ -1,6 +1,6 @@
/* exported Instances */
-const Instances = (self => {
+const Instances = ((self) => {
/**
* List instances
* @param {{
@@ -18,17 +18,11 @@ const Instances = (self => {
return p;
}, {});
const queryParams = Object.keys(request)
- .reduce(
- (p, c) =>
- pathParamsNames.includes(c)
- ? p
- : p.push(`${c}=${decodeURIComponent(request[c])}`) && p,
- []
- )
+ .reduce((p, c) => (pathParamsNames.includes(c) ? p : p.push(`${c}=${decodeURIComponent(request[c])}`) && p), [])
.join('&');
- const url = `${host}/${pathParams.project}/zones/${
- pathParams.zone
- }/instances${queryParams.length ? '?' : ''}${queryParams}`;
+ const url = `${host}/${pathParams.project}/zones/${pathParams.zone}/instances${
+ queryParams.length ? '?' : ''
+ }${queryParams}`;
console.log(url);
const options = Object.assign(
@@ -62,17 +56,9 @@ const Instances = (self => {
return p;
}, {});
const queryParams = Object.keys(request)
- .reduce(
- (p, c) =>
- pathParamsNames.includes(c)
- ? p
- : p.push(`${c}=${decodeURIComponent(request[c])}`) && p,
- []
- )
+ .reduce((p, c) => (pathParamsNames.includes(c) ? p : p.push(`${c}=${decodeURIComponent(request[c])}`) && p), [])
.join('&');
- const url = `${host}/${pathParams.project}/zones/${
- pathParams.zone
- }/instances/${pathParams.resourceId}/stop${
+ const url = `${host}/${pathParams.project}/zones/${pathParams.zone}/instances/${pathParams.resourceId}/stop${
queryParams.length ? '?' : ''
}${queryParams}`;
const options = Object.assign(
@@ -107,17 +93,9 @@ const Instances = (self => {
return p;
}, {});
const queryParams = Object.keys(request)
- .reduce(
- (p, c) =>
- pathParamsNames.includes(c)
- ? p
- : p.push(`${c}=${decodeURIComponent(request[c])}`) && p,
- []
- )
+ .reduce((p, c) => (pathParamsNames.includes(c) ? p : p.push(`${c}=${decodeURIComponent(request[c])}`) && p), [])
.join('&');
- const url = `${host}/${pathParams.project}/zones/${
- pathParams.zone
- }/instances/${pathParams.resourceId}/start${
+ const url = `${host}/${pathParams.project}/zones/${pathParams.zone}/instances/${pathParams.resourceId}/start${
queryParams.length ? '?' : ''
}${queryParams}`;
const options = Object.assign(
diff --git a/snippets/gae/start_stop_instance/index.js b/snippets/gae/start_stop_instance/index.js
index 70cb0f4..3c66d08 100644
--- a/snippets/gae/start_stop_instance/index.js
+++ b/snippets/gae/start_stop_instance/index.js
@@ -13,12 +13,8 @@ function runStop() {
const instances = JSON.parse(Instances.list(request).getContentText());
const res = {};
if (instances && instances.items)
- res.stops = instances.items.map(item =>
- JSON.parse(
- Instances.stop(
- Object.assign(DEFAULT_PROJECT, { resourceId: item.id })
- ).getContentText()
- )
+ res.stops = instances.items.map((item) =>
+ JSON.parse(Instances.stop(Object.assign(DEFAULT_PROJECT, { resourceId: item.id })).getContentText())
);
else res.other = instances;
console.log(res);
@@ -32,12 +28,8 @@ function runStart() {
const instances = JSON.parse(Instances.list(reques).getContentText());
const res = {};
if (instances && instances.items)
- res.starts = instances.items.map(item =>
- JSON.parse(
- Instances.start(
- Object.assign(DEFAULT_PROJECT, { resourceId: item.id })
- ).getContentText()
- )
+ res.starts = instances.items.map((item) =>
+ JSON.parse(Instances.start(Object.assign(DEFAULT_PROJECT, { resourceId: item.id })).getContentText())
);
else res.other = instances;
console.log(res);
diff --git a/snippets/gmail/answering_machine/index.js b/snippets/gmail/answering_machine/index.js
index f0a7435..d8d4059 100644
--- a/snippets/gmail/answering_machine/index.js
+++ b/snippets/gmail/answering_machine/index.js
@@ -25,6 +25,6 @@ function forwardWithoutAttachments_(query) {
console.log(c.getFirstMessageSubject());
return p;
}, [])
- .find(msg => msg.getAttachments().length);
+ .find((msg) => msg.getAttachments().length);
return message.forward('alexanderivanovdev@gmail.com', { attachments: [] });
}
diff --git a/snippets/gmail/forward_without_attachments/forward_without_attachments.js b/snippets/gmail/forward_without_attachments/forward_without_attachments.js
index f0a7435..d8d4059 100644
--- a/snippets/gmail/forward_without_attachments/forward_without_attachments.js
+++ b/snippets/gmail/forward_without_attachments/forward_without_attachments.js
@@ -25,6 +25,6 @@ function forwardWithoutAttachments_(query) {
console.log(c.getFirstMessageSubject());
return p;
}, [])
- .find(msg => msg.getAttachments().length);
+ .find((msg) => msg.getAttachments().length);
return message.forward('alexanderivanovdev@gmail.com', { attachments: [] });
}
diff --git a/snippets/gpf/copy_paste_data_between_sheets/Code.js b/snippets/gpf/copy_paste_data_between_sheets/Code.js
index 9d7928d..0bbfe3d 100644
--- a/snippets/gpf/copy_paste_data_between_sheets/Code.js
+++ b/snippets/gpf/copy_paste_data_between_sheets/Code.js
@@ -7,35 +7,14 @@ function Macro1() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('E1:F1').activate();
var currentCell = spreadsheet.getCurrentCell();
- spreadsheet
- .getSelection()
- .getNextDataRange(SpreadsheetApp.Direction.DOWN)
- .activate();
+ spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.PREVIOUS)
- .activate();
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.PREVIOUS)
- .activate();
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.DOWN)
- .activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.PREVIOUS).activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.PREVIOUS).activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
spreadsheet.getRange('A7').activate();
- spreadsheet
- .getRange('E1:F3')
- .copyTo(
- spreadsheet.getActiveRange(),
- SpreadsheetApp.CopyPasteType.PASTE_NORMAL,
- false
- );
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.UP)
- .activate();
+ spreadsheet.getRange('E1:F3').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.UP).activate();
}
/**
@@ -45,36 +24,17 @@ function Pasteacrosssheets() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('E1:F1').activate();
var currentCell = spreadsheet.getCurrentCell();
- spreadsheet
- .getSelection()
- .getNextDataRange(SpreadsheetApp.Direction.DOWN)
- .activate();
+ spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Sheet1'), true);
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.PREVIOUS)
- .activate();
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.PREVIOUS)
- .activate();
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.DOWN)
- .activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.PREVIOUS).activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.PREVIOUS).activate();
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
spreadsheet.getRange('A7').activate();
spreadsheet
.getRange('Sheet2!E1:F3')
- .copyTo(
- spreadsheet.getActiveRange(),
- SpreadsheetApp.CopyPasteType.PASTE_NORMAL,
- false
- );
- spreadsheet
- .getCurrentCell()
- .getNextDataCell(SpreadsheetApp.Direction.UP)
- .activate();
+ .copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
+ spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.UP).activate();
}
/**
diff --git a/snippets/gpf/copy_paste_data_between_sheets/Code2.js b/snippets/gpf/copy_paste_data_between_sheets/Code2.js
index 6a8e37b..ab54d89 100644
--- a/snippets/gpf/copy_paste_data_between_sheets/Code2.js
+++ b/snippets/gpf/copy_paste_data_between_sheets/Code2.js
@@ -11,14 +11,9 @@ function copyData_() {
const data = book
.getRange('Sheet2!E:F')
.getValues()
- .filter(row => row.some(cell => cell !== ''));
+ .filter((row) => row.some((cell) => cell !== ''));
const target = book.getSheetByName('Sheet1');
const targetData = target.getRange('A:B').getValues();
- const lastRow =
- targetData.length -
- targetData.reverse().findIndex(row => row.some(cell => cell !== ''));
- if (data.length)
- target
- .getRange(lastRow + 1, 1, data.length, data[0].length)
- .setValues(data);
+ const lastRow = targetData.length - targetData.reverse().findIndex((row) => row.some((cell) => cell !== ''));
+ if (data.length) target.getRange(lastRow + 1, 1, data.length, data[0].length).setValues(data);
}
diff --git a/snippets/patterns/bootstrap_jquery/.clasp.json b/snippets/patterns/bootstrap_jquery/.clasp.json
index c89aa61..d6f5452 100644
--- a/snippets/patterns/bootstrap_jquery/.clasp.json
+++ b/snippets/patterns/bootstrap_jquery/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "1VpI6PRVsIQ08W6gIHs2y1UlIbGBOeQSHXxiUZxvODqRZ06Ziz_ylLyXp",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/snippets/patterns/bootstrap_jquery/appsscript.json b/snippets/patterns/bootstrap_jquery/appsscript.json
index daf33ab..ed36616 100644
--- a/snippets/patterns/bootstrap_jquery/appsscript.json
+++ b/snippets/patterns/bootstrap_jquery/appsscript.json
@@ -1,11 +1,10 @@
{
"timeZone": "Europe/Moscow",
- "dependencies": {
- },
+ "dependencies": {},
"webapp": {
"access": "MYSELF",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/patterns/bootstrap_jquery/bootstrap.html b/snippets/patterns/bootstrap_jquery/bootstrap.html
index 3f203a5..816658f 100644
--- a/snippets/patterns/bootstrap_jquery/bootstrap.html
+++ b/snippets/patterns/bootstrap_jquery/bootstrap.html
@@ -1,3 +1,3 @@
\ No newline at end of file
+
diff --git a/snippets/sheets/append_row_with_date_time/index.js b/snippets/sheets/append_row_with_date_time/index.js
index 43f2616..7457c97 100644
--- a/snippets/sheets/append_row_with_date_time/index.js
+++ b/snippets/sheets/append_row_with_date_time/index.js
@@ -11,23 +11,15 @@
* @return {GoogleAppsScript.Spreadsheet.Sheet} // The sheet
*/
function appendDateTimeRow_(sheet) {
- const locale = sheet
- .getParent()
- .getSpreadsheetLocale()
- .split('_')[0];
- return sheet.appendRow([
- ...new Date().toLocaleString(locale).split(/[,\s]+/, 2),
- ]);
+ const locale = sheet.getParent().getSpreadsheetLocale().split('_')[0];
+ return sheet.appendRow([...new Date().toLocaleString(locale).split(/[,\s]+/, 2)]);
}
/**
* Creates an ueser menu for the snippet
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('My tools')
- .addItem('Add new row', 'userActionAddNewRow')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('My tools').addItem('Add new row', 'userActionAddNewRow').addToUi();
}
/**
* User action
diff --git a/snippets/sheets/append_values_from_sheet_to_one/index.js b/snippets/sheets/append_values_from_sheet_to_one/index.js
index c4dbbf9..19c0d75 100644
--- a/snippets/sheets/append_values_from_sheet_to_one/index.js
+++ b/snippets/sheets/append_values_from_sheet_to_one/index.js
@@ -13,16 +13,9 @@
*/
function appendValues_(from, to) {
const fromRange = from.getRange('A2:C');
- const fromValues = fromRange
- .getValues()
- .filter(row => row.some(cell => cell !== ''));
+ const fromValues = fromRange.getValues().filter((row) => row.some((cell) => cell !== ''));
if (fromValues.length)
- to.getRange(
- to.getLastRow() + 1,
- 2,
- fromValues.length,
- fromValues[0].length
- ).setValues(fromValues);
+ to.getRange(to.getLastRow() + 1, 2, fromValues.length, fromValues[0].length).setValues(fromValues);
fromRange.clearContent();
return fromValues.length;
}
@@ -31,10 +24,7 @@ function appendValues_(from, to) {
* Creates an ueser menu for the snippet
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('My tools')
- .addItem('Copy data', 'userActionCopyData')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('My tools').addItem('Copy data', 'userActionCopyData').addToUi();
}
/**
* User action
diff --git a/snippets/sheets/autoid/autoid.js b/snippets/sheets/autoid/autoid.js
index e3719ab..cd42fb5 100644
--- a/snippets/sheets/autoid/autoid.js
+++ b/snippets/sheets/autoid/autoid.js
@@ -14,11 +14,8 @@ function autoid_(sheet) {
var indexDate = data[0].indexOf('DATE');
if (indexId < 0 || indexDate < 0) return;
var id = data.reduce(
- function(p, row) {
- var year =
- row[indexDate] && row[indexDate].getTime
- ? row[indexDate].getFullYear() % 100
- : '-';
+ function (p, row) {
+ var year = row[indexDate] && row[indexDate].getTime ? row[indexDate].getFullYear() % 100 : '-';
if (!Object.prototype.hasOwnProperty.call(p.indexByGroup, year)) {
p.indexByGroup[year] = [];
}
@@ -38,24 +35,18 @@ function autoid_(sheet) {
// Logger.log(JSON.stringify(id, null, ' '));
var newId = data
- .map(function(row, i) {
+ .map(function (row, i) {
if (row[indexId] !== '') return [row[indexId]];
if (isNumeric(id.years[i])) {
var lastId = Math.max.apply(
null,
- id.indexByGroup[id.years[i]].filter(function(e) {
+ id.indexByGroup[id.years[i]].filter(function (e) {
return isNumeric(e);
})
);
lastId = lastId === -Infinity ? 1 : lastId + 1;
id.indexByGroup[id.years[i]].push(lastId);
- return [
- Utilities.formatString(
- '%s-%s',
- id.years[i],
- ('000000000' + lastId).slice(-3)
- )
- ];
+ return [Utilities.formatString('%s-%s', id.years[i], ('000000000' + lastId).slice(-3))];
}
return [''];
})
@@ -86,7 +77,7 @@ function onEdit(e) {
function userActionUpdateId() {
onEdit({
range: SpreadsheetApp.getActiveRange(),
- source: SpreadsheetApp.getActive()
+ source: SpreadsheetApp.getActive(),
});
}
@@ -94,10 +85,7 @@ function userActionUpdateId() {
*
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('AUTOID')
- .addItem('Update', 'userActionUpdateId')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('AUTOID').addItem('Update', 'userActionUpdateId').addToUi();
}
/**
diff --git a/snippets/sheets/autoid/config.json b/snippets/sheets/autoid/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/autoid/config.json
+++ b/snippets/sheets/autoid/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/clean_cells_by_find_result copy/index.js b/snippets/sheets/clean_cells_by_find_result copy/index.js
index f95cfb3..1737191 100644
--- a/snippets/sheets/clean_cells_by_find_result copy/index.js
+++ b/snippets/sheets/clean_cells_by_find_result copy/index.js
@@ -23,9 +23,6 @@ function findAndReplace_(book, text) {
return groups;
}, {});
return Object.keys(a1NotationsGroups).map((sheetName) =>
- book
- .getSheetByName(sheetName)
- .getRangeList(a1NotationsGroups[sheetName])
- .clearContent()
+ book.getSheetByName(sheetName).getRangeList(a1NotationsGroups[sheetName]).clearContent()
);
}
diff --git a/snippets/sheets/clean_cells_by_find_result/index.js b/snippets/sheets/clean_cells_by_find_result/index.js
index f95cfb3..1737191 100644
--- a/snippets/sheets/clean_cells_by_find_result/index.js
+++ b/snippets/sheets/clean_cells_by_find_result/index.js
@@ -23,9 +23,6 @@ function findAndReplace_(book, text) {
return groups;
}, {});
return Object.keys(a1NotationsGroups).map((sheetName) =>
- book
- .getSheetByName(sheetName)
- .getRangeList(a1NotationsGroups[sheetName])
- .clearContent()
+ book.getSheetByName(sheetName).getRangeList(a1NotationsGroups[sheetName]).clearContent()
);
}
diff --git a/snippets/sheets/copy_format_between_sheets/copy_format_between_sheets.js b/snippets/sheets/copy_format_between_sheets/copy_format_between_sheets.js
index a6edc2c..bdd219d 100644
--- a/snippets/sheets/copy_format_between_sheets/copy_format_between_sheets.js
+++ b/snippets/sheets/copy_format_between_sheets/copy_format_between_sheets.js
@@ -12,18 +12,9 @@ const SETTINGS = Object.freeze({
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Copy format')
- .addItem(
- `Copy format from ${SETTINGS.template1Name} to the active sheet`,
- 'userActionFormatActiveSheetByTemplate'
- )
- .addItem(
- 'Copy format from the active sheet to all sheets',
- 'userActionFormatAllSheetsByActive'
- )
- .addItem(
- `Sync format for the list ${SETTINGS.syncListSheet.join(', ')}`,
- 'userActionSyncFormatForList'
- )
+ .addItem(`Copy format from ${SETTINGS.template1Name} to the active sheet`, 'userActionFormatActiveSheetByTemplate')
+ .addItem('Copy format from the active sheet to all sheets', 'userActionFormatAllSheetsByActive')
+ .addItem(`Sync format for the list ${SETTINGS.syncListSheet.join(', ')}`, 'userActionSyncFormatForList')
.addToUi();
}
@@ -45,9 +36,7 @@ function userActionFormatAllSheetsByActive() {
const template = SpreadsheetApp.getActiveSheet();
const book = SpreadsheetApp.getActive()
.getSheets()
- .forEach(sheet =>
- sheet !== template ? formatSheetByTemplate_(sheet, template) : undefined
- );
+ .forEach((sheet) => (sheet !== template ? formatSheetByTemplate_(sheet, template) : undefined));
}
/**
@@ -59,11 +48,9 @@ function userActionSyncFormatForList() {
const template = SETTINGS.syncListSheet.includes(templateName)
? activeSheet
: SpreadsheetApp.getActive().getSheetByName(SETTINGS.syncListSheet[0]);
- SETTINGS.syncListSheet.forEach(sheetName => {
+ SETTINGS.syncListSheet.forEach((sheetName) => {
const sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
- return sheet !== template
- ? formatSheetByTemplate_(sheet, template)
- : undefined;
+ return sheet !== template ? formatSheetByTemplate_(sheet, template) : undefined;
});
}
@@ -79,32 +66,15 @@ function formatSheetByTemplate_(sheet, template) {
const activeSheetMaxRows = sheet.getMaxRows();
const activeSheetMaxCols = sheet.getMaxColumns();
- const templateRange = template.getRange(
- 1,
- 1,
- templateSheetMaxRows,
- templateSheetMaxCols
- );
+ const templateRange = template.getRange(1, 1, templateSheetMaxRows, templateSheetMaxCols);
const sheetRange = sheet.getRange(
1,
1,
- activeSheetMaxRows > templateSheetMaxRows
- ? templateSheetMaxRows
- : activeSheetMaxRows,
- activeSheetMaxCols > templateSheetMaxCols
- ? templateSheetMaxCols
- : activeSheetMaxCols
+ activeSheetMaxRows > templateSheetMaxRows ? templateSheetMaxRows : activeSheetMaxRows,
+ activeSheetMaxCols > templateSheetMaxCols ? templateSheetMaxCols : activeSheetMaxCols
);
- templateRange.copyTo(
- sheetRange,
- SpreadsheetApp.CopyPasteType.PASTE_FORMAT,
- false
- );
- templateRange.copyTo(
- sheetRange,
- SpreadsheetApp.CopyPasteType.PASTE_COLUMN_WIDTHS,
- false
- );
+ templateRange.copyTo(sheetRange, SpreadsheetApp.CopyPasteType.PASTE_FORMAT, false);
+ templateRange.copyTo(sheetRange, SpreadsheetApp.CopyPasteType.PASTE_COLUMN_WIDTHS, false);
return sheetRange;
}
diff --git a/snippets/sheets/copying_protected_ranges_between_two_entities/appsscript.json b/snippets/sheets/copying_protected_ranges_between_two_entities/appsscript.json
index 092167f..dcd6930 100644
--- a/snippets/sheets/copying_protected_ranges_between_two_entities/appsscript.json
+++ b/snippets/sheets/copying_protected_ranges_between_two_entities/appsscript.json
@@ -11,4 +11,4 @@
}
]
}
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/copying_protected_ranges_between_two_entities/index.js b/snippets/sheets/copying_protected_ranges_between_two_entities/index.js
index 03fe42e..84efba5 100644
--- a/snippets/sheets/copying_protected_ranges_between_two_entities/index.js
+++ b/snippets/sheets/copying_protected_ranges_between_two_entities/index.js
@@ -38,8 +38,7 @@ function copyingAccessRightsBetweenTwoEntities_(fromId, toId) {
const toDict = {};
const requestsDeleteProtectedRanges = Sheets.Spreadsheets.get(toId, {
- fields:
- 'sheets(properties.sheetId,properties.title,protectedRanges.protectedRangeId)',
+ fields: 'sheets(properties.sheetId,properties.title,protectedRanges.protectedRangeId)',
}).sheets.reduce((p, sheet) => {
toDict[sheet.properties.title] = sheet.properties.sheetId;
const protectedRangeIds = sheet.protectedRanges
@@ -67,17 +66,14 @@ function copyingAccessRightsBetweenTwoEntities_(fromId, toId) {
toId
);
- const requestsAddProtectedRanges = fromProtectedRanges.reduce(
- (p, protectedRange) => {
- if (protectedRange.range && toDict[protectedRange.sheetTitle]) {
- protectedRange.range.sheetId = toDict[protectedRange.sheetTitle];
- delete protectedRange.sheetTitle;
- p.push({ addProtectedRange: { protectedRange } });
- }
- return p;
- },
- []
- );
+ const requestsAddProtectedRanges = fromProtectedRanges.reduce((p, protectedRange) => {
+ if (protectedRange.range && toDict[protectedRange.sheetTitle]) {
+ protectedRange.range.sheetId = toDict[protectedRange.sheetTitle];
+ delete protectedRange.sheetTitle;
+ p.push({ addProtectedRange: { protectedRange } });
+ }
+ return p;
+ }, []);
if (requestsAddProtectedRanges.length)
Sheets.Spreadsheets.batchUpdate(
diff --git a/snippets/sheets/count_cells/config.json b/snippets/sheets/count_cells/config.json
index 81e35e4..cf5009a 100644
--- a/snippets/sheets/count_cells/config.json
+++ b/snippets/sheets/count_cells/config.json
@@ -1,4 +1,4 @@
{
"type": "single",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/count_cells/index.js b/snippets/sheets/count_cells/index.js
index c23e31d..52198a5 100644
--- a/snippets/sheets/count_cells/index.js
+++ b/snippets/sheets/count_cells/index.js
@@ -39,18 +39,9 @@ function getCountCells2_(array, filterCallback) {
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('My tools')
- .addItem(
- 'Get count empty cells of active range',
- 'userActionGetCountEmptyCells'
- )
- .addItem(
- 'Get count non-empty cells of B:B range',
- 'userActionGetCountNonEmptyCells'
- )
- .addItem(
- 'Get count white cells of active range',
- 'userActionGetCountWhiteCells'
- )
+ .addItem('Get count empty cells of active range', 'userActionGetCountEmptyCells')
+ .addItem('Get count non-empty cells of B:B range', 'userActionGetCountNonEmptyCells')
+ .addItem('Get count white cells of active range', 'userActionGetCountWhiteCells')
.addToUi();
}
/**
@@ -60,20 +51,16 @@ function userActionGetCountEmptyCells() {
/** @type {ReduceCallback} */
const reduceCallback = (acc, cv) => {
const length = cv.length;
- const count = cv.filter(cell => cell === '').length;
+ const count = cv.filter((cell) => cell === '').length;
acc.count += count;
acc.total += length;
return acc;
};
- const countCells = getCountCells_(
- SpreadsheetApp.getActiveRange().getValues(),
- reduceCallback
- );
+ const countCells = getCountCells_(SpreadsheetApp.getActiveRange().getValues(), reduceCallback);
const ui = SpreadsheetApp.getUi();
ui.alert(
'Count cells',
- `Empty: ${countCells.count}. With values: ${countCells.total -
- countCells.count}. Total: ${countCells.total}`,
+ `Empty: ${countCells.count}. With values: ${countCells.total - countCells.count}. Total: ${countCells.total}`,
ui.ButtonSet.OK
);
}
@@ -83,17 +70,10 @@ function userActionGetCountEmptyCells() {
*/
function userActionGetCountWhiteCells() {
/** @type {ReduceCallback} */
- const filterCallback = cell => cell === '#ffffff';
- const countCells = getCountCells2_(
- SpreadsheetApp.getActiveRange().getBackgrounds(),
- filterCallback
- );
+ const filterCallback = (cell) => cell === '#ffffff';
+ const countCells = getCountCells2_(SpreadsheetApp.getActiveRange().getBackgrounds(), filterCallback);
const ui = SpreadsheetApp.getUi();
- ui.alert(
- 'Count cells',
- `White: ${countCells.count}. Total: ${countCells.total}`,
- ui.ButtonSet.OK
- );
+ ui.alert('Count cells', `White: ${countCells.count}. Total: ${countCells.total}`, ui.ButtonSet.OK);
}
/**
@@ -101,18 +81,11 @@ function userActionGetCountWhiteCells() {
*/
function userActionGetCountNonEmptyCells() {
/** @type {ReduceCallback} */
- const filterCallback = cell => cell !== '';
+ const filterCallback = (cell) => cell !== '';
const sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
- const countCells = getCountCells2_(
- sheet.getRange(`B1:B${sheet.getLastRow()}`).getValues(),
- filterCallback
- );
+ const countCells = getCountCells2_(sheet.getRange(`B1:B${sheet.getLastRow()}`).getValues(), filterCallback);
const ui = SpreadsheetApp.getUi();
- ui.alert(
- 'Count cells',
- `Non-empty: ${countCells.count}. Total: ${countCells.total}`,
- ui.ButtonSet.OK
- );
+ ui.alert('Count cells', `Non-empty: ${countCells.count}. Total: ${countCells.total}`, ui.ButtonSet.OK);
}
/**
diff --git a/snippets/sheets/delete_move_rows_by_conditional/run.js b/snippets/sheets/delete_move_rows_by_conditional/run.js
index 6363c87..17dc6a6 100644
--- a/snippets/sheets/delete_move_rows_by_conditional/run.js
+++ b/snippets/sheets/delete_move_rows_by_conditional/run.js
@@ -24,16 +24,12 @@ function run2() {
const action = (values, i, i2) => {
const data = values.slice(i, i + i2);
- archive
- .getRange(archive.getLastRow() + 1, 1, data.length, data[0].length)
- .setValues(data);
+ archive.getRange(archive.getLastRow() + 1, 1, data.length, data[0].length).setValues(data);
};
const condition = (values, i) => {
const row = values[i];
- return (
- i > 0 && row[0] !== '' && row[1] !== '' && row[3] !== '' && row[5] !== ''
- );
+ return i > 0 && row[0] !== '' && row[1] !== '' && row[3] !== '' && row[5] !== '';
};
deleteRowsByConditional_(sheet, condition, action);
diff --git a/snippets/sheets/dynamic_meny/code.js b/snippets/sheets/dynamic_meny/code.js
index 4dae208..a0c80f8 100644
--- a/snippets/sheets/dynamic_meny/code.js
+++ b/snippets/sheets/dynamic_meny/code.js
@@ -27,7 +27,7 @@ function onOpen() {
var menu = ui.createMenu('Test');
- MENU.forEach(function(item, i) {
+ MENU.forEach(function (item, i) {
menu.addItem(item.caption, item.functionName + i);
});
@@ -44,14 +44,12 @@ function onOpen() {
function itemMenu(e) {
var caption = e.item.caption;
var order = e.order;
- Browser.msgBox(
- Utilities.formatString('Был нажат %sй пункт меню: %s', order + 1, caption)
- );
+ Browser.msgBox(Utilities.formatString('Был нажат %sй пункт меню: %s', order + 1, caption));
}
-(function(self) {
- MENU.forEach(function(item, i) {
- self[item.functionName + i] = function() {
+(function (self) {
+ MENU.forEach(function (item, i) {
+ self[item.functionName + i] = function () {
return self[item.functionName]({ item: item, order: i });
};
});
diff --git a/snippets/sheets/export-import-to-csv/config.json b/snippets/sheets/export-import-to-csv/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/export-import-to-csv/config.json
+++ b/snippets/sheets/export-import-to-csv/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/export-import-to-csv/index.js b/snippets/sheets/export-import-to-csv/index.js
index a13aea6..93b7e0d 100644
--- a/snippets/sheets/export-import-to-csv/index.js
+++ b/snippets/sheets/export-import-to-csv/index.js
@@ -38,11 +38,7 @@ function userActionImportFromCSV() {
* User action. Import the CSV file
*/
function userActionExportToCSV() {
- var res = exportToCSV_(
- CSV_FILE_ID,
- SpreadsheetApp.getActive().getId(),
- SpreadsheetApp.getActiveSheet().getSheetId()
- );
+ var res = exportToCSV_(CSV_FILE_ID, SpreadsheetApp.getActive().getId(), SpreadsheetApp.getActiveSheet().getSheetId());
Logger.log(res);
}
@@ -56,9 +52,7 @@ function userActionExportToCSV() {
function importFromCSV_(csvId, spreadsheetId, sheetId) {
// Get CSV data
- var data = DriveApp.getFileById(csvId)
- .getBlob()
- .getDataAsString();
+ var data = DriveApp.getFileById(csvId).getBlob().getDataAsString();
// Clear the Sheet
var updateCellsRequest = Sheets.newUpdateCellsRequest();
@@ -122,9 +116,6 @@ function batchUpdateSpreadsheet_(request, spreadsheetId) {
requests: [],
};
resource.requests.push(request);
- var batchUpdateSpreadsheetResponse = Sheets.Spreadsheets.batchUpdate(
- resource,
- spreadsheetId
- );
+ var batchUpdateSpreadsheetResponse = Sheets.Spreadsheets.batchUpdate(resource, spreadsheetId);
return batchUpdateSpreadsheetResponse;
}
diff --git a/snippets/sheets/filters_samples/config.json b/snippets/sheets/filters_samples/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/filters_samples/config.json
+++ b/snippets/sheets/filters_samples/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/find_and_replace_samples/index.js b/snippets/sheets/find_and_replace_samples/index.js
index 6ae82e1..a9c5a66 100644
--- a/snippets/sheets/find_and_replace_samples/index.js
+++ b/snippets/sheets/find_and_replace_samples/index.js
@@ -25,10 +25,7 @@ function findAndReplace_(book, expr, repl, excl) {
return groups;
}, {});
return Object.keys(a1NotationsGroups).map((sheetName) =>
- book
- .getSheetByName(sheetName)
- .getRangeList(a1NotationsGroups[sheetName])
- .clearContent()
+ book.getSheetByName(sheetName).getRangeList(a1NotationsGroups[sheetName]).clearContent()
);
}
diff --git a/snippets/sheets/get_data_sheet_as_array_of_objects/appsscript.json b/snippets/sheets/get_data_sheet_as_array_of_objects/appsscript.json
index 8f430df..59936af 100644
--- a/snippets/sheets/get_data_sheet_as_array_of_objects/appsscript.json
+++ b/snippets/sheets/get_data_sheet_as_array_of_objects/appsscript.json
@@ -1,13 +1,15 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Sheets",
- "serviceId": "sheets",
- "version": "v4"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Sheets",
+ "serviceId": "sheets",
+ "version": "v4"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"],
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/get_data_sheet_as_array_of_objects/code.js b/snippets/sheets/get_data_sheet_as_array_of_objects/code.js
index 15b840a..00a2aac 100644
--- a/snippets/sheets/get_data_sheet_as_array_of_objects/code.js
+++ b/snippets/sheets/get_data_sheet_as_array_of_objects/code.js
@@ -3,9 +3,7 @@
*
*/
function getData() {
- const values = SpreadsheetApp.getActiveSheet()
- .getDataRange()
- .getValues();
+ const values = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
const headers = values.shift();
const data = values.reduce((p, c) => {
const entry = c.reduce((o, v, j) => {
diff --git a/snippets/sheets/hide_empty_columns/appsscript.json b/snippets/sheets/hide_empty_columns/appsscript.json
index 8f430df..59936af 100644
--- a/snippets/sheets/hide_empty_columns/appsscript.json
+++ b/snippets/sheets/hide_empty_columns/appsscript.json
@@ -1,13 +1,15 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Sheets",
- "serviceId": "sheets",
- "version": "v4"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Sheets",
+ "serviceId": "sheets",
+ "version": "v4"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"],
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/hide_empty_columns/code.js b/snippets/sheets/hide_empty_columns/code.js
index 8f317f6..716eb4b 100644
--- a/snippets/sheets/hide_empty_columns/code.js
+++ b/snippets/sheets/hide_empty_columns/code.js
@@ -26,44 +26,43 @@ const hideEmptyColumnsOfSheet_ = (sheet, headersRows = 1) => {
majorDimension: 'COLUMNS',
});
- const createUpdateDimensionPropertiesRequest = fabricUpdateDimensionPropertiesRequest_(
- sheetId
- );
+ const createUpdateDimensionPropertiesRequest = fabricUpdateDimensionPropertiesRequest_(sheetId);
- const updateDimensionPropertiesRequests = values.values.reduceRight((
- /** @type {Array.} */ p,
- /** @type {Array.} */ c,
- /** @type {number} */ i
- ) => {
- if (!c.slice(headersRows).some(Boolean)) {
- let last = p[p.length - 1];
- if (last == undefined) {
- last = createUpdateDimensionPropertiesRequest({
- startIndex: i,
- endIndex: i + 1,
- });
- p.push(last);
- }
- if (i + 1 === last.range.startIndex) last.range.startIndex = i;
- else
- p.push(
- createUpdateDimensionPropertiesRequest({
+ const updateDimensionPropertiesRequests = values.values.reduceRight(
+ (
+ /** @type {Array.} */ p,
+ /** @type {Array.} */ c,
+ /** @type {number} */ i
+ ) => {
+ if (!c.slice(headersRows).some(Boolean)) {
+ let last = p[p.length - 1];
+ if (last == undefined) {
+ last = createUpdateDimensionPropertiesRequest({
startIndex: i,
endIndex: i + 1,
- })
- );
- }
- return p;
- }, []);
+ });
+ p.push(last);
+ }
+ if (i + 1 === last.range.startIndex) last.range.startIndex = i;
+ else
+ p.push(
+ createUpdateDimensionPropertiesRequest({
+ startIndex: i,
+ endIndex: i + 1,
+ })
+ );
+ }
+ return p;
+ },
+ []
+ );
const batchUpdateSpreadsheetRequest = Sheets.newBatchUpdateSpreadsheetRequest();
- batchUpdateSpreadsheetRequest.requests = updateDimensionPropertiesRequests.map(
- updateDimensionPropertiesRequest => {
- const request = Sheets.newRequest();
- request.updateDimensionProperties = updateDimensionPropertiesRequest;
- return request;
- }
- );
+ batchUpdateSpreadsheetRequest.requests = updateDimensionPropertiesRequests.map((updateDimensionPropertiesRequest) => {
+ const request = Sheets.newRequest();
+ request.updateDimensionProperties = updateDimensionPropertiesRequest;
+ return request;
+ });
Sheets.Spreadsheets.batchUpdate(batchUpdateSpreadsheetRequest, bookId);
};
@@ -72,7 +71,7 @@ const hideEmptyColumnsOfSheet_ = (sheet, headersRows = 1) => {
* @param {number} sheetId
* @return {GoogleAppsScript.Sheets.Schema.UpdateDimensionPropertiesRequest}
*/
-const fabricUpdateDimensionPropertiesRequest_ = sheetId => props => {
+const fabricUpdateDimensionPropertiesRequest_ = (sheetId) => (props) => {
const updateDimensionPropertiesRequest = Sheets.newUpdateDimensionPropertiesRequest();
updateDimensionPropertiesRequest.fields = 'hiddenByUser';
updateDimensionPropertiesRequest.properties = { hiddenByUser: true };
diff --git a/snippets/sheets/hyperlinks/config.json b/snippets/sheets/hyperlinks/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/hyperlinks/config.json
+++ b/snippets/sheets/hyperlinks/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/on_change_trigger_sample/index.js b/snippets/sheets/on_change_trigger_sample/index.js
index 6be3bec..c5520a8 100644
--- a/snippets/sheets/on_change_trigger_sample/index.js
+++ b/snippets/sheets/on_change_trigger_sample/index.js
@@ -5,7 +5,7 @@
*/
function onChange1(e) {
const bookId = ScriptApp.getProjectTriggers()
- .find(function(trigger) {
+ .find(function (trigger) {
return trigger.getUniqueId() === e.triggerUid;
})[0]
.getTriggerSourceId();
diff --git a/snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/index.js b/snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/index.js
index f0b6069..d266d91 100644
--- a/snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/index.js
+++ b/snippets/sheets/on_change_trigger_sample_DEPRECATED_ES5/index.js
@@ -5,7 +5,7 @@
*/
function onChange1(e) {
var bookId = ScriptApp.getProjectTriggers()
- .filter(function(trigger) {
+ .filter(function (trigger) {
return trigger.getUniqueId() === e.triggerUid;
})[0]
.getTriggerSourceId();
diff --git a/snippets/sheets/on_edit_active_user/index.js b/snippets/sheets/on_edit_active_user/index.js
index fead883..c90a385 100644
--- a/snippets/sheets/on_edit_active_user/index.js
+++ b/snippets/sheets/on_edit_active_user/index.js
@@ -12,11 +12,7 @@ function onedit(e) {
if (e.range.getRow() < 2) return;
e.range
.offset(0, -1 * e.range.getColumn() + 1)
- .setValue(
- Session.getEffectiveUser().getEmail() +
- ' ' +
- Session.getActiveUser().getEmail()
- );
+ .setValue(Session.getEffectiveUser().getEmail() + ' ' + Session.getActiveUser().getEmail());
}
/**
@@ -28,11 +24,7 @@ function onEdit(e) {
if (e.range.getRow() < 2) return;
e.range
.offset(0, -1 * e.range.getColumn() + 2)
- .setValue(
- Session.getEffectiveUser().getEmail() +
- ' ' +
- Session.getActiveUser().getEmail()
- );
+ .setValue(Session.getEffectiveUser().getEmail() + ' ' + Session.getActiveUser().getEmail());
}
/**
diff --git a/snippets/sheets/on_edit_sort/index.js b/snippets/sheets/on_edit_sort/index.js
index b674689..11ce96c 100644
--- a/snippets/sheets/on_edit_sort/index.js
+++ b/snippets/sheets/on_edit_sort/index.js
@@ -6,12 +6,7 @@ function onEdit(e) {
const sheetName = 'Sheet1'; // name of the sheet the script should work on
const colToSort = 4; // name of the column should sort on
- if (
- e &&
- e.range &&
- e.range.getColumn() === colToSort &&
- e.range.getRow() > 1
- ) {
+ if (e && e.range && e.range.getColumn() === colToSort && e.range.getRow() > 1) {
const sheet = e.range.getSheet();
if (sheet.getName() == sheetName) sheet.sort(colToSort);
}
diff --git a/snippets/sheets/on_edit_timestamp_with_check/index.js b/snippets/sheets/on_edit_timestamp_with_check/index.js
index 457800d..658902b 100644
--- a/snippets/sheets/on_edit_timestamp_with_check/index.js
+++ b/snippets/sheets/on_edit_timestamp_with_check/index.js
@@ -9,10 +9,7 @@ function onEdit(e) {
if (e && e.range && e.range.getColumn() > 1 && e.range.getRow() > 1) {
const sheet = e.range.getSheet();
if (sheet.getName() !== sheetName) {
- const writeVal =
- e.value && sheet.getRange(e.range.getRow(), 1).getValue() == true
- ? new Date()
- : '';
+ const writeVal = e.value && sheet.getRange(e.range.getRow(), 1).getValue() == true ? new Date() : '';
sheet.getRange(e.range.rowStart, colToStamp).setValue(writeVal);
}
}
diff --git a/snippets/sheets/on_selection_change_simple_trigger/index.js b/snippets/sheets/on_selection_change_simple_trigger/index.js
index 32b8ecf..e1a23bd 100644
--- a/snippets/sheets/on_selection_change_simple_trigger/index.js
+++ b/snippets/sheets/on_selection_change_simple_trigger/index.js
@@ -5,11 +5,7 @@
function onSelectionChange(e) {
try {
var range = e.range;
- if (
- range.getNumRows() === 1 &&
- range.getNumColumns() === 1 &&
- range.getCell(1, 1).getValue() === ''
- ) {
+ if (range.getNumRows() === 1 && range.getNumColumns() === 1 && range.getCell(1, 1).getValue() === '') {
range.setBackground(randomColor_());
}
} catch (error) {
diff --git a/snippets/sheets/protection_multiple_sheets/index.js b/snippets/sheets/protection_multiple_sheets/index.js
index 24bb9c3..c6851ee 100644
--- a/snippets/sheets/protection_multiple_sheets/index.js
+++ b/snippets/sheets/protection_multiple_sheets/index.js
@@ -19,9 +19,7 @@ const UNPROTECTED_ADDRS = ['A1:C9'];
*/
function userActionRunSnippet() {
const book = SpreadsheetApp.getActive();
- const sheets = book
- .getSheets()
- .filter((sheet) => SHEET_LIST.includes(sheet.getName()));
+ const sheets = book.getSheets().filter((sheet) => SHEET_LIST.includes(sheet.getName()));
sheets.forEach((sheet) => {
const unprotected = UNPROTECTED_ADDRS.map((addr) => sheet.getRange(addr));
diff --git a/snippets/sheets/rename_sheets_by_patt/appsscript.json b/snippets/sheets/rename_sheets_by_patt/appsscript.json
index 8f430df..59936af 100644
--- a/snippets/sheets/rename_sheets_by_patt/appsscript.json
+++ b/snippets/sheets/rename_sheets_by_patt/appsscript.json
@@ -1,13 +1,15 @@
{
"timeZone": "Europe/Moscow",
"dependencies": {
- "enabledAdvancedServices": [{
- "userSymbol": "Sheets",
- "serviceId": "sheets",
- "version": "v4"
- }]
+ "enabledAdvancedServices": [
+ {
+ "userSymbol": "Sheets",
+ "serviceId": "sheets",
+ "version": "v4"
+ }
+ ]
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"],
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/rename_sheets_by_patt/code.js b/snippets/sheets/rename_sheets_by_patt/code.js
index c4254af..3a8b810 100644
--- a/snippets/sheets/rename_sheets_by_patt/code.js
+++ b/snippets/sheets/rename_sheets_by_patt/code.js
@@ -22,20 +22,19 @@ function renameToCurrentYear_(year) {
month: 'short',
})
)
- .map(name => new RegExp(`(${name}) (\\d{2})`));
+ .map((name) => new RegExp(`(${name}) (\\d{2})`));
SpreadsheetApp.getActive()
.getSheets()
- .forEach(sheet => {
+ .forEach((sheet) => {
const name = sheet.getName();
let match = undefined;
- const patt = listOfNamesPatts.find(patt => {
+ const patt = listOfNamesPatts.find((patt) => {
const match_ = name.match(patt);
if (match_) {
match = match_;
return true;
}
});
- if (match && match[2] !== year)
- sheet.setName(name.replace(match[0], `${match[1]} ${year}`));
+ if (match && match[2] !== year) sheet.setName(name.replace(match[0], `${match[1]} ${year}`));
});
}
diff --git a/snippets/sheets/reset_sheet_data/appsscript.json b/snippets/sheets/reset_sheet_data/appsscript.json
index 69e7032..e5dbdde 100644
--- a/snippets/sheets/reset_sheet_data/appsscript.json
+++ b/snippets/sheets/reset_sheet_data/appsscript.json
@@ -5,4 +5,4 @@
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/reset_sheet_data/makeCopyBeforeReset.js b/snippets/sheets/reset_sheet_data/makeCopyBeforeReset.js
index 3dcd76b..48299c0 100644
--- a/snippets/sheets/reset_sheet_data/makeCopyBeforeReset.js
+++ b/snippets/sheets/reset_sheet_data/makeCopyBeforeReset.js
@@ -8,9 +8,7 @@ function userActionMakeCopyBeforeReset() {
const __checkvar__ = 'Make copy before reset';
if (SpreadsheetApp.getActiveSheet().getName() !== __checkvar__) {
SpreadsheetApp.getActive().getSheetByName(__checkvar__).activate();
- SpreadsheetApp.getUi().alert(
- 'OK. The original sheet will activated. Please, fill data and try again!'
- );
+ SpreadsheetApp.getUi().alert('OK. The original sheet will activated. Please, fill data and try again!');
return;
}
// ============================================== END
diff --git a/snippets/sheets/reset_sheet_data/readme.md b/snippets/sheets/reset_sheet_data/readme.md
index fa05e68..dc2c35b 100644
--- a/snippets/sheets/reset_sheet_data/readme.md
+++ b/snippets/sheets/reset_sheet_data/readme.md
@@ -43,7 +43,6 @@ You have to decide how you want to reset your sheet. This is expressed in indivi
Sorry, your browser doesn't support embedded videos.
-
{{< codeFromFile "makeCopyBeforeReset.js" >}}
{{< clipboard >}}
diff --git a/snippets/sheets/reset_sheet_data/triggerActions.js b/snippets/sheets/reset_sheet_data/triggerActions.js
index fa41e87..1680557 100644
--- a/snippets/sheets/reset_sheet_data/triggerActions.js
+++ b/snippets/sheets/reset_sheet_data/triggerActions.js
@@ -4,19 +4,10 @@
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Reset sheet')
- .addItem(
- 'Reset active sheet (ContactPrice example)',
- 'userActionResetActiveSheetByRangesAddresses'
- )
+ .addItem('Reset active sheet (ContactPrice example)', 'userActionResetActiveSheetByRangesAddresses')
.addItem('Reset ranges', 'userActionResetRangesByRangesAddresses')
- .addItem(
- 'Reset multiple sheets',
- 'userActionResetMultipleSheetsByRangesAddresses'
- )
- .addItem(
- 'Reset "GSM" columns',
- 'userActionResetMultipleSheetsBySpecialColumns'
- )
+ .addItem('Reset multiple sheets', 'userActionResetMultipleSheetsByRangesAddresses')
+ .addItem('Reset "GSM" columns', 'userActionResetMultipleSheetsBySpecialColumns')
.addItem('Reset to a specific value', 'userActionResetToSpecificValue')
.addItem('Make a copy before reset', 'userActionMakeCopyBeforeReset')
.addToUi();
diff --git a/snippets/sheets/reset_sheet_data/userActions.js b/snippets/sheets/reset_sheet_data/userActions.js
index 8f8cb47..3c9203e 100644
--- a/snippets/sheets/reset_sheet_data/userActions.js
+++ b/snippets/sheets/reset_sheet_data/userActions.js
@@ -56,15 +56,13 @@ function userActionResetMultipleSheetsByColor() {
.getFontColors()
.reduce((p, row, i) => {
var colors = row.reduce((p2, color, j) => {
- if (color === fColor)
- p2.push(Utilities.formatString('R%sC%s', i + 1, j + 1));
+ if (color === fColor) p2.push(Utilities.formatString('R%sC%s', i + 1, j + 1));
return p2;
}, []);
if (colors.length) p = p.concat(colors);
return p;
}, []);
- if (rangesAddressesList.length)
- resetByRangesList_(sheet, rangesAddressesList);
+ if (rangesAddressesList.length) resetByRangesList_(sheet, rangesAddressesList);
}
});
}
@@ -81,10 +79,7 @@ function userActionResetMultipleSheetsBySpecialColumns() {
.getRange('2:2')
.getValues()[0]
.reduce((p, cell, i) => {
- if (cell === 'GSA')
- p.push(
- Utilities.formatString('R3C%s:R%sC%s', i + 1, lastRow, i + 1)
- );
+ if (cell === 'GSA') p.push(Utilities.formatString('R3C%s:R%sC%s', i + 1, lastRow, i + 1));
return p;
}, []);
if (rangesAddressesList.length) {
diff --git a/snippets/sheets/shuffle_some_data/config.json b/snippets/sheets/shuffle_some_data/config.json
index 81e35e4..cf5009a 100644
--- a/snippets/sheets/shuffle_some_data/config.json
+++ b/snippets/sheets/shuffle_some_data/config.json
@@ -1,4 +1,4 @@
{
"type": "single",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/shuffle_some_data/index.js b/snippets/sheets/shuffle_some_data/index.js
index bb9a09f..7fa6f99 100644
--- a/snippets/sheets/shuffle_some_data/index.js
+++ b/snippets/sheets/shuffle_some_data/index.js
@@ -22,8 +22,7 @@ function onOpen() {
function onEdit(e) {
if (
e.range.getSheet().getName() === 'Sheet1' &&
- ((e.range.getColumn() === 2 && e.range.getRow() > 3) ||
- e.range.getA1Notation() === 'F6')
+ ((e.range.getColumn() === 2 && e.range.getRow() > 3) || e.range.getA1Notation() === 'F6')
) {
SpreadsheetApp.getActive().toast('Start ...');
fillData_(e.range.getSheet());
@@ -61,17 +60,11 @@ function fillData_(sheet) {
const range = sheet.getRange('B3:C');
const values = range.getValues();
- const totalData = values
- .map((_, i) => i)
- .filter((_, i) => values[i][0] !== '');
+ const totalData = values.map((_, i) => i).filter((_, i) => values[i][0] !== '');
- const sortIndexes = totalData
- .sort(() => 0.5 - Math.random())
- .slice(0, parseInt(totalData.length * percent));
+ const sortIndexes = totalData.sort(() => 0.5 - Math.random()).slice(0, parseInt(totalData.length * percent));
- const newValues = values.map((_, i) => [
- sortIndexes.indexOf(i) !== -1 ? true : '',
- ]);
+ const newValues = values.map((_, i) => [sortIndexes.indexOf(i) !== -1 ? true : '']);
sheet.getRange('C3:C').setValues(newValues);
}
@@ -84,11 +77,9 @@ function extractData_(sheet) {
const range = sheet.getRange('A3:C');
const values = range.getValues();
- const totalData = values.filter(row => row[0] !== '');
+ const totalData = values.filter((row) => row[0] !== '');
- const sortIndexes = totalData
- .sort(() => 0.5 - Math.random())
- .slice(0, parseInt(totalData.length * percent));
+ const sortIndexes = totalData.sort(() => 0.5 - Math.random()).slice(0, parseInt(totalData.length * percent));
sheet
.getRange('L3:N')
diff --git a/snippets/sheets/sort_book_sheets/.clasp.json b/snippets/sheets/sort_book_sheets/.clasp.json
index b9732bc..4c2f6db 100644
--- a/snippets/sheets/sort_book_sheets/.clasp.json
+++ b/snippets/sheets/sort_book_sheets/.clasp.json
@@ -1,4 +1,4 @@
{
"scriptId": "1q6uooLGsK-sRinMPjKuUtF8QAYT46VBDYVGznGUY2yoeouoeBeNjKEVg",
"rootDir": "dist"
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/sort_book_sheets/index.js b/snippets/sheets/sort_book_sheets/index.js
index e5ead25..55259b8 100644
--- a/snippets/sheets/sort_book_sheets/index.js
+++ b/snippets/sheets/sort_book_sheets/index.js
@@ -22,8 +22,7 @@ function userActionSortBookByListNames() {
return {
items: self,
getId: (prop) => {
- if (!Object.prototype.hasOwnProperty.call(self, prop))
- self[prop] = ++next;
+ if (!Object.prototype.hasOwnProperty.call(self, prop)) self[prop] = ++next;
return self[prop];
},
};
diff --git a/snippets/sheets/sort_sheet_when_form_submit/sort_sheet_when_form_submit.js b/snippets/sheets/sort_sheet_when_form_submit/sort_sheet_when_form_submit.js
index 3aebcbe..687c6c4 100644
--- a/snippets/sheets/sort_sheet_when_form_submit/sort_sheet_when_form_submit.js
+++ b/snippets/sheets/sort_sheet_when_form_submit/sort_sheet_when_form_submit.js
@@ -10,11 +10,9 @@
*/
function onformsubmit(e) {
const sheet = e.range.getSheet();
- sheet
- .getRange('1:1')
- .copyTo(sheet.getRange(`${e.range.getRow()}:${e.range.getRow()}`), {
- formatOnly: true,
- });
+ sheet.getRange('1:1').copyTo(sheet.getRange(`${e.range.getRow()}:${e.range.getRow()}`), {
+ formatOnly: true,
+ });
const range = sheet.getRange(e.range.getRow(), 4);
onEdit({
range: range,
@@ -31,7 +29,7 @@ function onEdit(e) {
const rowIndex = sheet
.getDataRange()
.getValues()
- .findIndex(row => row[0] === '');
+ .findIndex((row) => row[0] === '');
const rows = rowIndex === -1 ? sheet.getLastRow() - 1 : rowIndex - 1;
sheet.getRange(2, 1, rows, sheet.getLastColumn()).sort([
{ column: 4, ascending: true },
@@ -44,17 +42,9 @@ function onEdit(e) {
*
*/
function install() {
- ScriptApp.getProjectTriggers().forEach(trigger => {
- if (
- [
- ScriptApp.EventType.ON_FORM_SUBMIT,
- ScriptApp.EventType.ON_EDIT,
- ].includes(trigger.getEventType())
- )
+ ScriptApp.getProjectTriggers().forEach((trigger) => {
+ if ([ScriptApp.EventType.ON_FORM_SUBMIT, ScriptApp.EventType.ON_EDIT].includes(trigger.getEventType()))
ScriptApp.deleteTrigger(trigger);
});
- ScriptApp.newTrigger('onformsubmit')
- .forSpreadsheet(SpreadsheetApp.getActive())
- .onFormSubmit()
- .create();
+ ScriptApp.newTrigger('onformsubmit').forSpreadsheet(SpreadsheetApp.getActive()).onFormSubmit().create();
}
diff --git a/snippets/sheets/spreadsheet-apply_format/apply_format.js b/snippets/sheets/spreadsheet-apply_format/apply_format.js
index a457151..7e1d65a 100644
--- a/snippets/sheets/spreadsheet-apply_format/apply_format.js
+++ b/snippets/sheets/spreadsheet-apply_format/apply_format.js
@@ -25,7 +25,7 @@ function runFormatActiveSheet() {
function runFormatActiveSpreadsheet() {
SpreadsheetApp.getActive()
.getSheets()
- .forEach(function(sheet) {
+ .forEach(function (sheet) {
applyFormat_(sheet.getDataRange());
});
}
diff --git a/snippets/sheets/spreadsheet-apply_format/config.json b/snippets/sheets/spreadsheet-apply_format/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/spreadsheet-apply_format/config.json
+++ b/snippets/sheets/spreadsheet-apply_format/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/spreadsheet-autoincrement/autoincrement.js b/snippets/sheets/spreadsheet-autoincrement/autoincrement.js
index 962aa63..4ad3710 100644
--- a/snippets/sheets/spreadsheet-autoincrement/autoincrement.js
+++ b/snippets/sheets/spreadsheet-autoincrement/autoincrement.js
@@ -12,19 +12,19 @@ function autoincrement_(sheet) {
if (data.length < 2) return;
var indexCol = data[0].indexOf('autoincrement');
if (indexCol < 0) return;
- var increment = data.map(function(row) {
+ var increment = data.map(function (row) {
return row[indexCol];
});
var lastIncrement = Math.max.apply(
null,
- increment.filter(function(e) {
+ increment.filter(function (e) {
return isNumeric_(e);
})
);
lastIncrement = isNumeric_(lastIncrement) ? lastIncrement : 0;
var newIncrement = data
- .map(function(row) {
+ .map(function (row) {
if (row[indexCol] !== '') return [row[indexCol]];
if (row.join('').length > 0) return [++lastIncrement];
return [''];
@@ -78,10 +78,7 @@ function userActionUpdateIncrement() {
*
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('AUTOINCREMENT')
- .addItem('Update', 'userActionUpdateIncrement')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('AUTOINCREMENT').addItem('Update', 'userActionUpdateIncrement').addToUi();
}
/**
diff --git a/snippets/sheets/spreadsheet-autoincrement/config.json b/snippets/sheets/spreadsheet-autoincrement/config.json
index 41f3b57..428d518 100644
--- a/snippets/sheets/spreadsheet-autoincrement/config.json
+++ b/snippets/sheets/spreadsheet-autoincrement/config.json
@@ -1,4 +1,4 @@
{
"type": "container-bound-sheet",
"src": []
-}
\ No newline at end of file
+}
diff --git a/snippets/sheets/spreadsheet-charts_calendar/charts_calendar.js b/snippets/sheets/spreadsheet-charts_calendar/charts_calendar.js
index 1274a45..53d069a 100644
--- a/snippets/sheets/spreadsheet-charts_calendar/charts_calendar.js
+++ b/snippets/sheets/spreadsheet-charts_calendar/charts_calendar.js
@@ -7,10 +7,7 @@
*
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('Charts')
- .addItem('Show calendar chart', 'userActionShowCalendarChart')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('Charts').addItem('Show calendar chart', 'userActionShowCalendarChart').addToUi();
}
/**
@@ -18,13 +15,7 @@ function onOpen() {
*/
function userActionShowCalendarChart() {
var template = HtmlService.createTemplateFromFile('charts_calendar_ui');
- SpreadsheetApp.getUi().showModalDialog(
- template
- .evaluate()
- .setWidth(1100)
- .setHeight(450),
- ' '
- );
+ SpreadsheetApp.getUi().showModalDialog(template.evaluate().setWidth(1100).setHeight(450), ' ');
}
/**
@@ -34,10 +25,10 @@ function getData() {
return SpreadsheetApp.getActive()
.getRange("'Calendar chart'!A:B")
.getValues()
- .filter(function(row) {
+ .filter(function (row) {
return row[0] && row[0].getTime;
})
- .map(function(row) {
+ .map(function (row) {
row[0] = row[0].getTime();
return row;
});
diff --git a/snippets/sheets/spreadsheet-charts_calendar/charts_calendar_ui.html b/snippets/sheets/spreadsheet-charts_calendar/charts_calendar_ui.html
index 4691a32..801bd1e 100644
--- a/snippets/sheets/spreadsheet-charts_calendar/charts_calendar_ui.html
+++ b/snippets/sheets/spreadsheet-charts_calendar/charts_calendar_ui.html
@@ -10,10 +10,7 @@
}
Document
-
+
diff --git a/snippets/common_ui/open-dialog-from-sidebar/triggerActionss.js b/snippets/common_ui/open-dialog-from-sidebar/triggerActionss.js
index b9037be..60f89ed 100644
--- a/snippets/common_ui/open-dialog-from-sidebar/triggerActionss.js
+++ b/snippets/common_ui/open-dialog-from-sidebar/triggerActionss.js
@@ -2,8 +2,5 @@
* Create menu for handy use
*/
function onOpen() {
- SpreadsheetApp.getUi()
- .createMenu('Apps Script Snippets')
- .addItem('Open sidebar', 'run')
- .addToUi();
+ SpreadsheetApp.getUi().createMenu('Apps Script Snippets').addItem('Open sidebar', 'run').addToUi();
}
diff --git a/snippets/common_ui/open_url_in_browser/index.js b/snippets/common_ui/open_url_in_browser/index.js
index e5a21bc..ad8f3c5 100644
--- a/snippets/common_ui/open_url_in_browser/index.js
+++ b/snippets/common_ui/open_url_in_browser/index.js
@@ -18,9 +18,7 @@ function onOpen() {
* User action
*/
function userActionOpenMyFile() {
- const file = DriveApp.getFileById(
- '17mpcNilHA43kWqYm8qHAwiwAqFJ1DQ9QENBXHa6CoDM'
- );
+ const file = DriveApp.getFileById('17mpcNilHA43kWqYm8qHAwiwAqFJ1DQ9QENBXHa6CoDM');
openUrlInBrowser_(file.getUrl());
}
diff --git a/snippets/common_ui/sheet_sidebar_select/app.html b/snippets/common_ui/sheet_sidebar_select/app.html
index 7b81b6f..c25c2d9 100644
--- a/snippets/common_ui/sheet_sidebar_select/app.html
+++ b/snippets/common_ui/sheet_sidebar_select/app.html
@@ -3,10 +3,7 @@
-
+
Document