├── .babelrc ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .idea ├── .gitignore ├── codeStyles │ └── codeStyleConfig.xml ├── inspectionProfiles │ └── Project_Default.xml ├── js-coroutines.iml ├── misc.xml ├── modules.xml └── vcs.xml ├── .prettierrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENCE.txt ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── _config.yml ├── dist ├── append-async.js ├── append.js ├── array-utilities.js ├── async-array-wrappers.js ├── async-compression-wrappers.js ├── async-json-wrappers.js ├── async-wrapper-utils.js ├── async-wrappers.js ├── branch.js ├── call.js ├── compose.js ├── concat-async.js ├── concat.js ├── coroutines.js ├── es6 │ ├── append-async.js │ ├── append.js │ ├── array-utilities.js │ ├── async-array-wrappers.js │ ├── async-compression-wrappers.js │ ├── async-json-wrappers.js │ ├── async-wrapper-utils.js │ ├── async-wrappers.js │ ├── branch.js │ ├── call.js │ ├── compose.js │ ├── concat-async.js │ ├── concat.js │ ├── coroutines.js │ ├── every.js │ ├── filter-async.js │ ├── filter.js │ ├── find-async.js │ ├── find-index-async.js │ ├── find-index.js │ ├── find.js │ ├── for-each-async.js │ ├── for-each.js │ ├── group-by-async.js │ ├── group-by.js │ ├── includes-async.js │ ├── includes.js │ ├── index-of-async.js │ ├── index-of.js │ ├── index.js │ ├── is-object.js │ ├── jscoroutines.d.ts │ ├── json.js │ ├── key-by-async.js │ ├── key-by.js │ ├── last-index-of-async.js │ ├── last-index-of.js │ ├── lz-string │ │ ├── base64-string.js │ │ └── lz-string.js │ ├── map-async.js │ ├── map.js │ ├── pipe.js │ ├── polyfill.js │ ├── reduce-async.js │ ├── reduce.js │ ├── repeat.js │ ├── run.js │ ├── singleton.js │ ├── some-async.js │ ├── some.js │ ├── sort-async.js │ ├── tap.js │ ├── timsort.js │ ├── unique-by-async.js │ ├── unique-by.js │ ├── update.js │ ├── useInternalEngine.js │ ├── wrappers.js │ └── yastjson │ │ └── lib │ │ ├── ast.js │ │ ├── expression.js │ │ ├── parse.js │ │ ├── token.js │ │ ├── tokenizer.js │ │ └── yielder.js ├── every.js ├── filter-async.js ├── filter.js ├── find-async.js ├── find-index-async.js ├── find-index.js ├── find.js ├── for-each-async.js ├── for-each.js ├── group-by-async.js ├── group-by.js ├── includes-async.js ├── includes.js ├── index-of-async.js ├── index-of.js ├── index.js ├── is-object.js ├── json.js ├── key-by-async.js ├── key-by.js ├── last-index-of-async.js ├── last-index-of.js ├── lz-string │ ├── base64-string.js │ └── lz-string.js ├── map-async.js ├── map.js ├── pipe.js ├── polyfill.js ├── reduce-async.js ├── reduce.js ├── repeat.js ├── run.js ├── singleton.js ├── some-async.js ├── some.js ├── sort-async.js ├── tap.js ├── timsort.js ├── unique-by-async.js ├── unique-by.js ├── update.js ├── useInternalEngine.js ├── wrappers.js └── yastjson │ └── lib │ ├── ast.js │ ├── expression.js │ ├── parse.js │ ├── token.js │ ├── tokenizer.js │ └── yielder.js ├── doc.conf.json ├── docs ├── Iterator.html ├── array-utilities.js.html ├── async-wrappers.js.html ├── coroutines.js.html ├── fonts │ ├── Montserrat │ │ ├── Montserrat-Bold.eot │ │ ├── Montserrat-Bold.ttf │ │ ├── Montserrat-Bold.woff │ │ ├── Montserrat-Bold.woff2 │ │ ├── Montserrat-Regular.eot │ │ ├── Montserrat-Regular.ttf │ │ ├── Montserrat-Regular.woff │ │ └── Montserrat-Regular.woff2 │ └── Source-Sans-Pro │ │ ├── sourcesanspro-light-webfont.eot │ │ ├── sourcesanspro-light-webfont.svg │ │ ├── sourcesanspro-light-webfont.ttf │ │ ├── sourcesanspro-light-webfont.woff │ │ ├── sourcesanspro-light-webfont.woff2 │ │ ├── sourcesanspro-regular-webfont.eot │ │ ├── sourcesanspro-regular-webfont.svg │ │ ├── sourcesanspro-regular-webfont.ttf │ │ ├── sourcesanspro-regular-webfont.woff │ │ └── sourcesanspro-regular-webfont.woff2 ├── global.html ├── index.html ├── scripts │ ├── collapse.js │ ├── linenumber.js │ ├── nav.js │ ├── polyfill.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js │ └── search.js ├── styles │ ├── jsdoc.css │ └── prettify.css └── wrappers.js.html ├── mocha.wallaby.js ├── out └── types.d.ts ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── scripts └── build.sh ├── src ├── App.css ├── App.js ├── App.test.js ├── component │ ├── append-async.js │ ├── append.js │ ├── array-utilities.js │ ├── async-array-wrappers.js │ ├── async-compression-wrappers.js │ ├── async-json-wrappers.js │ ├── async-wrapper-utils.js │ ├── async-wrappers.js │ ├── branch.js │ ├── call.js │ ├── compose.js │ ├── concat-async.js │ ├── concat.js │ ├── coroutines.js │ ├── every.js │ ├── filter-async.js │ ├── filter.js │ ├── find-async.js │ ├── find-index-async.js │ ├── find-index.js │ ├── find.js │ ├── for-each-async.js │ ├── for-each.js │ ├── group-by-async.js │ ├── group-by.js │ ├── includes-async.js │ ├── includes.js │ ├── index-of-async.js │ ├── index-of.js │ ├── index.js │ ├── is-object.js │ ├── jscoroutines.d.ts │ ├── json.js │ ├── key-by-async.js │ ├── key-by.js │ ├── last-index-of-async.js │ ├── last-index-of.js │ ├── lz-string │ │ ├── base64-string.js │ │ └── lz-string.js │ ├── map-async.js │ ├── map.js │ ├── pipe.js │ ├── polyfill.js │ ├── reduce-async.js │ ├── reduce.js │ ├── repeat.js │ ├── run.js │ ├── singleton.js │ ├── some-async.js │ ├── some.js │ ├── sort-async.js │ ├── tap.js │ ├── timsort.js │ ├── unique-by-async.js │ ├── unique-by.js │ ├── update.js │ ├── useInternalEngine.js │ ├── wrappers.js │ └── yastjson │ │ ├── lib │ │ ├── ast.js │ │ ├── expression.js │ │ ├── parse.js │ │ ├── token.js │ │ ├── tokenizer.js │ │ └── yielder.js │ │ └── test │ │ └── test.json ├── index.css ├── index.js ├── logo.svg ├── serviceWorker.js ├── setupTests.js └── test │ ├── array-async.test.js │ ├── array-generator.test.js │ ├── basic-express.js │ ├── compression.test.js │ ├── functional.test.js │ ├── json.test.js │ └── sort.test.js └── template ├── LICENSE ├── publish.js ├── static ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ ├── OpenSans-Regular-webfont.woff │ ├── OpenSans-Semibold-webfont.eot │ ├── OpenSans-Semibold-webfont.svg │ ├── OpenSans-Semibold-webfont.ttf │ ├── OpenSans-Semibold-webfont.woff │ ├── OpenSans-SemiboldItalic-webfont.eot │ ├── OpenSans-SemiboldItalic-webfont.svg │ ├── OpenSans-SemiboldItalic-webfont.ttf │ └── OpenSans-SemiboldItalic-webfont.woff ├── icons │ ├── home.svg │ └── search.svg ├── scripts │ ├── linenumber.js │ └── pagelocation.js └── styles │ ├── collapse.css │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css └── tmpl ├── augments-spread.tmpl ├── augments.tmpl ├── container.tmpl ├── details.tmpl ├── example.tmpl ├── examples.tmpl ├── exceptions.tmpl ├── layout.tmpl ├── mainpage.tmpl ├── members.tmpl ├── method.tmpl ├── params.tmpl ├── properties.tmpl ├── returns.tmpl ├── source.tmpl ├── tutorial.tmpl ├── type-spread.tmpl └── type.tmpl /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "comments": false, 3 | "presets": ["@babel/preset-env", "@babel/preset-react", 4 | [ 5 | 'minify', 6 | { 7 | "builtIns": false, 8 | "deadcode": true, 9 | "mangle": { 10 | "exclude": ["r", "o", "n"] 11 | } 12 | } 13 | ]], 14 | "plugins": [ 15 | "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime"] 16 | } 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Either detailed steps to reproduce the behavior or an example project. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Desktop (please complete the following information):** 23 | - OS: [e.g. iOS] 24 | - Browser [e.g. chrome, safari] 25 | - Version [e.g. 22] 26 | 27 | **Smartphone (please complete the following information):** 28 | - Device: [e.g. iPhone6] 29 | - OS: [e.g. iOS8.1] 30 | - Browser [e.g. stock browser, safari] 31 | - Version [e.g. 22] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/js-coroutines.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": false, 3 | "printWidth": 120, 4 | "tabWidth": 4, 5 | "singleQuote": true, 6 | "trailingComma": "es5", 7 | "jsxBracketSameLine": false, 8 | "arrowParens": "always", 9 | "semi": false, 10 | "bracketSpacing": true 11 | } 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. 4 | 5 | Please note we have a code of conduct, please follow it in all your interactions with the project. 6 | 7 | ## Pull Request Process 8 | 9 | Update the CHANGELOG.md with details of changes to the interface, this includes new functions and updates to existing functions. 10 | Increase the version numbers. The versioning scheme we use is SemVer. 11 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Template 2 | 3 | ## Description 4 | 5 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 6 | 7 | Fixes # (issue) 8 | 9 | ## Type of change 10 | 11 | Please delete options that are not relevant. 12 | 13 | - [ ] Bug fix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 16 | - [ ] This change requires a documentation update 17 | 18 | ## How Has This Been Tested? 19 | 20 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration 21 | 22 | **Test Configuration**: 23 | 24 | * Hardware: 25 | * Toolchain: 26 | 27 | ## Checklist: 28 | 29 | - [ ] I have performed a self-review of my own code 30 | - [ ] I have commented my code, particularly in hard-to-understand areas 31 | - [ ] I have made corresponding changes to the documentation 32 | - [ ] My changes generate no new warnings 33 | - [ ] I have added tests that prove my fix is effective or that my feature works 34 | - [ ] I have checked my code and corrected any misspellings 35 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /dist/append-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.appendAsync=void 0;var _wrappers=require("./wrappers"),_append=require("./append"),appendAsync=(0,_wrappers.wrapAsPromise)(_append.append);exports.appendAsync=appendAsync; -------------------------------------------------------------------------------- /dist/append.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.append=append;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_forEach=require("./for-each"),_wrappers=require("./wrappers"),_marked=_regenerator.default.mark(append);function append(b,c){var d;return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=b.length,a.next=3,!0;case 3:return b.length+=c.length,void(a.next=6);case 6:return a.delegateYield((0,_forEach.forEach)(c,(0,_wrappers.yielding)(function(c,a){return b[a+d]=c})),"t0",7);case 7:return a.abrupt("return",b);case 8:case"end":return a.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/array-utilities.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.exitWith=exitWith,exports.doReturn=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),doReturn=Symbol("return");exports.doReturn=doReturn;function exitWith(a){var b;return b={},(0,_defineProperty2.default)(b,doReturn,!0),(0,_defineProperty2.default)(b,"value",a),b} -------------------------------------------------------------------------------- /dist/async-array-wrappers.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.everyAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_every=require("./every"),everyAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_every.every);exports.everyAsync=everyAsync; -------------------------------------------------------------------------------- /dist/async-compression-wrappers.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.base64Decompress=exports.base64decompressFromUTF16Async=exports.decompressAsync=exports.decompressFromEncodedURIComponentAsync=exports.decompressFromUint8ArrayAsync=exports.decompressFromUTF16Async=exports.decompressFromBase64Async=exports.base64Compress=exports.base64CompressToUTF16Async=exports.compressAsync=exports.compressToEncodedURIComponentAsync=exports.compressToUint8ArrayAsync=exports.compressToUTF16Async=exports.compressToBase64Async=void 0;var _wrappers=require("./wrappers"),_base64String=require("./lz-string/base64-string"),_lzString=require("./lz-string/lz-string"),compressToBase64Async=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.compressToBase64);exports.compressToBase64Async=compressToBase64Async;var compressToUTF16Async=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.compressToUTF16);exports.compressToUTF16Async=compressToUTF16Async;var compressToUint8ArrayAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.compressToUint8Array);exports.compressToUint8ArrayAsync=compressToUint8ArrayAsync;var compressToEncodedURIComponentAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.compressToEncodedURIComponent);exports.compressToEncodedURIComponentAsync=compressToEncodedURIComponentAsync;var compressAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.compress);exports.compressAsync=compressAsync;var base64CompressToUTF16Async=(0,_wrappers.wrapAsPromise)(_base64String.Base64StringGenerator.compressToUTF16);exports.base64CompressToUTF16Async=base64CompressToUTF16Async;var base64Compress=(0,_wrappers.wrapAsPromise)(_base64String.Base64StringGenerator.compress);exports.base64Compress=base64Compress;var decompressFromBase64Async=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.decompressFromBase64);exports.decompressFromBase64Async=decompressFromBase64Async;var decompressFromUTF16Async=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.decompressFromUTF16);exports.decompressFromUTF16Async=decompressFromUTF16Async;var decompressFromUint8ArrayAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.decompressFromUint8Array);exports.decompressFromUint8ArrayAsync=decompressFromUint8ArrayAsync;var decompressFromEncodedURIComponentAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.decompressFromURIComponent);exports.decompressFromEncodedURIComponentAsync=decompressFromEncodedURIComponentAsync;var decompressAsync=(0,_wrappers.wrapAsPromise)(_lzString.LZStringGenerator.decompress);exports.decompressAsync=decompressAsync;var base64decompressFromUTF16Async=(0,_wrappers.wrapAsPromise)(_base64String.Base64StringGenerator.decompressFromUTF16);exports.base64decompressFromUTF16Async=base64decompressFromUTF16Async;var base64Decompress=(0,_wrappers.wrapAsPromise)(_base64String.Base64StringGenerator.decompress);exports.base64Decompress=base64Decompress; -------------------------------------------------------------------------------- /dist/async-json-wrappers.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseAsync=exports.stringifyAsync=void 0;var _wrappers=require("./wrappers"),_parse=require("./yastjson/lib/parse"),_json=require("./json"),stringifyAsync=(0,_wrappers.wrapAsPromise)(_json.stringify);exports.stringifyAsync=stringifyAsync;var parseAsync=(0,_wrappers.wrapAsPromise)(_parse.parse);exports.parseAsync=parseAsync; -------------------------------------------------------------------------------- /dist/async-wrapper-utils.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.wrapAsPromiseAndYieldFn=wrapAsPromiseAndYieldFn;var _wrappers=require("./wrappers"),_run=_interopRequireDefault(require("./run")),_call=require("./call");function wrapAsPromiseAndYieldFn(a){var b=function(b,c){for(var d=arguments.length,e=Array(2} a promise for destination after appending 10 | */ 11 | export const appendAsync = wrapAsPromise(append) 12 | -------------------------------------------------------------------------------- /dist/es6/append.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {yielding} from './wrappers' 3 | 4 | /** 5 | * Appends one array to another 6 | * @generator 7 | * @param {Array} array1 - the destination 8 | * @param {Array} array2 - the source 9 | * @returns {Generator<*, Array, *>} returns array1 10 | * @example 11 | * 12 | * // Updates array1 13 | * yield * append(array1, array2) 14 | */ 15 | export function* append(array1, array2) { 16 | const l = array1.length 17 | yield true 18 | array1.length += array2.length 19 | yield 20 | yield* forEach( 21 | array2, 22 | yielding((a, i) => (array1[i + l] = a)) 23 | ) 24 | 25 | return array1 26 | } 27 | -------------------------------------------------------------------------------- /dist/es6/array-utilities.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @callback Filter 3 | * @param {any} element 4 | * @param {number} index 5 | * @param {Array} collection 6 | * @returns {Generator} a generator for a value of true if included in the filter 7 | */ 8 | 9 | /** 10 | * @callback Map 11 | * @param {any} element 12 | * @param {number} index 13 | * @param {Array} collection 14 | * @returns {any} updated item 15 | */ 16 | 17 | /** 18 | * @callback Reduce 19 | * @param {any} accumulator 20 | * @param {any} element 21 | * @param {number} index 22 | * @param {Array} collection 23 | * @returns {any} updated value 24 | */ 25 | 26 | /** 27 | * @callback Process 28 | * @param {any} value - the value being processed 29 | * @param {number|string} key - the key or index of the value 30 | * @param {Array} collection - the collection being iterated 31 | */ 32 | 33 | export const doReturn = Symbol('return') 34 | 35 | export function exitWith(value) { 36 | return {[doReturn]: true, value} 37 | } 38 | 39 | -------------------------------------------------------------------------------- /dist/es6/async-array-wrappers.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {every} from './every' 3 | 4 | /** 5 | * Asynchronously check if every element in an array matches 6 | * a predicate 7 | * @function everyAsync 8 | * @param {Array} array 9 | * @param {Filter} fn 10 | * @returns {Promise.} promise for true if all items matched the filter 11 | */ 12 | export const everyAsync = wrapAsPromiseAndYieldFn(every) 13 | 14 | /** 15 | * @callback SortFunction 16 | * @param {any} item1 17 | * @param {any} item2 18 | * @returns < 0 if item 2 is bigger than item 1, === 0 if they are the same else > 0 19 | */ 20 | 21 | /** 22 | * @callback ExtractFunction 23 | * @param {any} item1 24 | * @returns {any} the value to sort item 1 by 25 | */ 26 | 27 | 28 | -------------------------------------------------------------------------------- /dist/es6/async-json-wrappers.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromise} from './wrappers' 2 | import {parse} from './yastjson/lib/parse' 3 | import {stringify} from './json' 4 | 5 | /** 6 | * Asynchronously stringify data into JSON 7 | * @function 8 | * @name stringifyAsync 9 | * @param {any} data - Object to store 10 | * @returns {Promise.} a Promise for the JSON representation of data 11 | */ 12 | export const stringifyAsync = wrapAsPromise(stringify) 13 | /** 14 | * Asynchronously parse JSON into an object 15 | * @function parseAsync 16 | * @param {String} json - the JSON to be parsed 17 | * @returns {Promise.} a Promise for the parsed JSON 18 | */ 19 | export const parseAsync = wrapAsPromise(parse) 20 | -------------------------------------------------------------------------------- /dist/es6/async-wrapper-utils.js: -------------------------------------------------------------------------------- 1 | import {yielding} from './wrappers' 2 | import run from './run' 3 | import {call} from './call' 4 | 5 | /** 6 | * Create a promised function 7 | * @param {Function} fn 8 | * @returns {Function} 9 | */ 10 | export function wrapAsPromiseAndYieldFn(fn) { 11 | const result = function (array, processor, ...params) { 12 | return run(fn(array, yielding(processor), ...params)) 13 | } 14 | result.with = function (...params) { 15 | return call(result, ...params) 16 | } 17 | return result 18 | } 19 | -------------------------------------------------------------------------------- /dist/es6/async-wrappers.js: -------------------------------------------------------------------------------- 1 | export * from './async-array-wrappers' 2 | export * from './async-compression-wrappers' 3 | export * from './async-json-wrappers' 4 | export {sortAsync} from './sort-async' 5 | export {findAsync} from './find-async' 6 | export {findIndexAsync} from './find-index-async' 7 | export {mapAsync} from './map-async' 8 | export {filterAsync} from './filter-async' 9 | export {reduceAsync} from './reduce-async' 10 | export {appendAsync} from './append-async' 11 | export {concatAsync} from './concat-async' 12 | export {forEachAsync} from './for-each-async' 13 | export {someAsync} from './some-async' 14 | export {includesAsync} from './includes-async' 15 | export {indexOfAsync} from './index-of-async' 16 | export {lastIndexOfAsync} from './last-index-of-async' 17 | export {keyByAsync} from './key-by-async' 18 | export {groupByAsync} from './group-by-async' 19 | export {uniqueByAsync} from './unique-by-async' 20 | -------------------------------------------------------------------------------- /dist/es6/branch.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Branches a pipeline by starting another "continuation" with 5 | * the current parameters. Starts a function but the pipeline 6 | * continues immediately creating two execution contexts 7 | * @param {Function} fn - the function to start - can be async or generator 8 | */ 9 | export function branch(fn) { 10 | return function (params) { 11 | let result = fn.call(this, params) 12 | if (result) { 13 | if (result.next) { 14 | run(result).catch(console.error) 15 | } else if (result.then) { 16 | result.catch(console.error) 17 | } 18 | } 19 | return params 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dist/es6/call.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a version of a function with its end 3 | * parameters supplied 4 | * @param {Function|GeneratorFunction|AsyncFunction} fn - the function to configure 5 | * @param {...any[]} config - the additional parameters to pass 6 | * @returns {Function} 7 | */ 8 | export function call(fn, ...config) { 9 | return function (...params) { 10 | return fn.apply(this, [...params, ...config]) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dist/es6/compose.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Create a function that executes a pipeline of 5 | * functions asynchronously, the function executes the list in 6 | * REVERSE order, allowing you to "compose on" a new function 7 | * at the head of the chain 8 | * @param {...(Function|Promise|Array<(Promise|Function|GeneratorFunction|AsyncFunction)>|GeneratorFunction|AsyncFunction)} fns - the pipeline to execute 9 | * @returns {AsyncFunction} an async function to execute the pipeline 10 | */ 11 | export function compose(...fns) { 12 | return async function (params) { 13 | let result = params 14 | 15 | let list = fns.flat(Infinity) 16 | for (let i = list.length - 1; i >= 0; i--) { 17 | let fn = list[i] 18 | if (!fn) continue 19 | let nextResult = fn.call(this, result) 20 | if (nextResult) { 21 | if (nextResult.next) { 22 | result = await run(nextResult) 23 | } else if (nextResult.then) { 24 | result = await nextResult 25 | } else { 26 | result = nextResult 27 | } 28 | } 29 | } 30 | return result 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /dist/es6/concat-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromise} from './wrappers' 2 | import {concat} from './concat' 3 | 4 | /** 5 | * Concatenates 2 arrays into a new array 6 | * @function concatAsync 7 | * @param {Array} array1 8 | * @param {Array} array2 9 | * @returns {Promise.} a promise for combined array 10 | */ 11 | export const concatAsync = wrapAsPromise(concat) 12 | -------------------------------------------------------------------------------- /dist/es6/concat.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {yielding} from './wrappers' 3 | 4 | /** 5 | * Concatenate two arrays into a new array 6 | * @generator 7 | * @param {Array} array1 8 | * @param {Array} array2 9 | * @returns {Generator<*, Array, *>} the concatenated arrays 10 | * @example 11 | * 12 | * const concatenated = yield * concat(array1, array2) 13 | */ 14 | export function* concat(array1, array2) { 15 | yield true 16 | const result = new Array(array1.length + array2.length) 17 | yield 18 | const l = array1.length 19 | yield* forEach( 20 | array1, 21 | yielding((a, i) => (result[i] = a)) 22 | ) 23 | yield* forEach( 24 | array2, 25 | yielding((a, i) => (result[i + l] = a)) 26 | ) 27 | return result 28 | } 29 | -------------------------------------------------------------------------------- /dist/es6/coroutines.js: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * A coroutine to be run during the gaps in other processing and animation. 4 | *

5 | *

6 | * The coroutine should yield regularly to do a time check. A plain yield will cause 7 | * a check against the standard time remaining specified when running. yield {number} will 8 | * check that number milliseconds are available and yield true will abandon any more 9 | * processing on the current frame. 10 | *

11 | * @callback Coroutine 12 | * @generator 13 | * @yields {number} either undefined to perform a standard time remaining check, a number of milliseconds required for the next step or true if we should abandon the current frame 14 | * @returns the result of the function if any to be returned to the caller 15 | */ 16 | 17 | /** 18 | * @typedef IteratorResult 19 | * @object 20 | * @property {any} [value] - the returned value 21 | * @property {boolean} done - whether the iterator is complete 22 | */ 23 | 24 | /** 25 | * @interface Iterator 26 | */ 27 | 28 | /** 29 | * Get the next value 30 | * @function 31 | * @name Iterator#next 32 | * @param {any} value - value to send to the coroutine 33 | * @returns {IteratorResult} 34 | */ 35 | 36 | /** 37 | * A coroutine to be used in high priority to animate. 38 | * 39 | * Executing a yield will cause the routine to resume at the start 40 | * of the next frame. 41 | * @callback AnimationCoroutine 42 | * @generator 43 | * @returns the result of the function if any to be returned to the caller 44 | */ 45 | 46 | 47 | /** 48 | * @callback GeneratorFunction 49 | * @generator 50 | * @param {...*} params - the parameters to pass 51 | * @returns {*} the result of the coroutine 52 | */ 53 | 54 | /** 55 | * @callback AsyncFunction 56 | * @param {*} params - the parameters to pass 57 | * @async 58 | * @returns {*} result of calling the function 59 | */ 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /dist/es6/every.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {exitWith} from './array-utilities' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Filter} fn 8 | * @returns {Generator<*, boolean, *>} true if all of the collection items matched the filter 9 | * @example 10 | * 11 | * if(! yield * every(records, yielding(r=>r.valid))) return 12 | */ 13 | export function* every(collection, fn) { 14 | let result = true 15 | yield* forEach(collection, function* (value, key) { 16 | if (!(yield* fn(value, key, collection))) { 17 | result = false 18 | return exitWith(false) 19 | } 20 | }) 21 | return result 22 | } 23 | -------------------------------------------------------------------------------- /dist/es6/filter-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {filter} from './filter' 3 | 4 | /** 5 | * Filters an array asynchronously 6 | * @function filterAsync 7 | * @param {Array} array 8 | * @param {Filter} filter 9 | * @returns {Promise.} promise for the filtered array 10 | */ 11 | export const filterAsync = wrapAsPromiseAndYieldFn(filter) 12 | -------------------------------------------------------------------------------- /dist/es6/filter.js: -------------------------------------------------------------------------------- 1 | import {isObject} from './is-object' 2 | import {forEach} from './for-each' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Filter} fn 8 | * @returns {Generator<*, Object|Array, *>} collection of elements matching the filter 9 | * @example 10 | * 11 | * const filtered = yield * filter(array, yielding(v=>v.value > 1000, 100)) 12 | */ 13 | export function* filter(collection, fn) { 14 | if (isObject(collection)) { 15 | let result = {} 16 | yield* forEach(collection, function* (value, key, array) { 17 | if (yield* fn(value, key, array)) { 18 | result[key] = value 19 | } 20 | }) 21 | return result 22 | } else { 23 | let result = [] 24 | yield* forEach(collection, function* (value, key, array) { 25 | if (yield* fn(value, key, array)) { 26 | result.push(value) 27 | } 28 | }) 29 | return result 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dist/es6/find-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {find} from './find' 3 | 4 | /** 5 | * Finds an item in an array asynchronously 6 | * @function findAsync 7 | * @param {Array} array 8 | * @param {Filter} filter 9 | * @returns {Promise.} promise for the item found or null if no match 10 | */ 11 | export const findAsync = wrapAsPromiseAndYieldFn(find) 12 | -------------------------------------------------------------------------------- /dist/es6/find-index-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {findIndex} from './find-index' 3 | 4 | /** 5 | * Finds an item index in an array asynchronously 6 | * @function findIndexAsync 7 | * @param {Array} array 8 | * @param {Filter} filter 9 | * @returns {Promise.} promise for the index of the first item to pass the filter or -1 10 | */ 11 | export const findIndexAsync = wrapAsPromiseAndYieldFn(findIndex) 12 | -------------------------------------------------------------------------------- /dist/es6/find-index.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {exitWith} from './array-utilities' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Filter} fn 8 | * @returns {Generator<*, number, *>} Index of matching element or -1 9 | * @example 10 | * 11 | * if(-1 === yield * findIndex(records, yielding(v=>v.id === '123'))) 12 | * return 13 | */ 14 | export function* findIndex(collection, fn, start) { 15 | let output = -1 16 | yield* forEach( 17 | collection, 18 | function* (value, key) { 19 | let result = yield* fn(value, key, collection) 20 | if (result) { 21 | output = key 22 | return exitWith(key) 23 | } 24 | }, 25 | start 26 | ) 27 | return output 28 | } 29 | -------------------------------------------------------------------------------- /dist/es6/find.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {exitWith} from './array-utilities' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Filter} fn 8 | * @param {any} [start] - the key to start at 9 | * @returns {Generator<*, *, *>} the first matching value in the collection or null 10 | * @example 11 | * 12 | * const record = yield * find(arrayOfRecords, yielding(v=>v.id === '1234')) 13 | */ 14 | export function* find(collection, fn, start) { 15 | let output = undefined 16 | yield* forEach( 17 | collection, 18 | function* (value, key) { 19 | let result = yield* fn(value, key, collection) 20 | if (result) { 21 | output = value 22 | return exitWith(value) 23 | } 24 | }, 25 | start 26 | ) 27 | return output 28 | } 29 | -------------------------------------------------------------------------------- /dist/es6/for-each-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {forEach} from './for-each' 3 | 4 | /** 5 | * Asynchronously loop over the elements of an array 6 | * @function forEachAsync 7 | * @param {Array} array 8 | * @param {Process} fn 9 | * @returns {Promise} promise for the end of the operation 10 | */ 11 | export const forEachAsync = wrapAsPromiseAndYieldFn(forEach) 12 | -------------------------------------------------------------------------------- /dist/es6/for-each.js: -------------------------------------------------------------------------------- 1 | import {isObject} from './is-object' 2 | import {doReturn} from './array-utilities' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Process} fn 8 | * @param {number|string} [start] 9 | * @returns {Generator<*, *, *>} 10 | * @example 11 | * // Loop over all keys/value pairs in an object 12 | * yield * forEach(object, yielding((value, key)=> { ... })) 13 | * 14 | * // Loop over all the values in an array 15 | * yield * forEach(array, generatorFunction) 16 | * 17 | * function * generatorFunction(value, index) { 18 | * let i = 0 19 | * while(i < 10000) { 20 | * doSomething(value) 21 | * if(i % 100 === 0) yield 22 | * } 23 | * } 24 | */ 25 | export function* forEach(collection, fn, start) { 26 | if (isObject(collection)) { 27 | let started = !start 28 | for (let key in collection) { 29 | if (!started) { 30 | started = key === start 31 | } 32 | if (started) { 33 | if (Object.prototype.hasOwnProperty.call(collection, key)) { 34 | let result = yield* fn(collection[key], key, collection) 35 | if (result && result[doReturn]) return result.value 36 | } 37 | } 38 | } 39 | } else { 40 | for (let index = start || 0, length = collection.length; index < length; index++) { 41 | let result = yield* fn(collection[index], index, collection) 42 | if (result && result[doReturn]) return result.value 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /dist/es6/group-by-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {groupBy} from './group-by' 3 | 4 | /** 5 | * Promises the creation of an object composed of keys generated from the results 6 | * of running each element of collection thru then supplied function. 7 | * The corresponding value of each key is an collection of the elements responsible 8 | * for generating the key. 9 | * 10 | * @param {Array|Object} collection 11 | * @param {Map} fn 12 | * @returns {Promise<{}>} 13 | */ 14 | export const groupByAsync = wrapAsPromiseAndYieldFn(groupBy) 15 | -------------------------------------------------------------------------------- /dist/es6/group-by.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates an object composed of keys generated from the results 3 | * of running each element of collection thru then supplied function. 4 | * The corresponding value of each key is an collection of the elements responsible 5 | * for generating the key. 6 | * 7 | * @param {Array|Object} collection 8 | * @param {Map} fn 9 | * @returns {Generator<*, {}, *>} a generator for the new object 10 | * @example 11 | * 12 | * let groups = yield * groupBy(records, yielding(v=>v.category)) 13 | * 14 | * ... 15 | * 16 | * console.log(groups['category1']) // -> [{id: 1, ...}, {id: 2, ...}] 17 | * 18 | */ 19 | export function* groupBy(collection, fn) { 20 | let result = {} 21 | let index = 0 22 | for (let item of collection) { 23 | let key = yield* fn(item, index++, collection) 24 | const array = (result[key] = result[key] || []) 25 | array.push(item) 26 | } 27 | return result 28 | } 29 | -------------------------------------------------------------------------------- /dist/es6/includes-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {includes} from './includes' 3 | 4 | /** 5 | * Returns a promise returning true if an array includes a value 6 | * @param array 7 | * @param value 8 | * @returns Promise 9 | * @example 10 | * if(await includesAsync(someArray, 'error')) { 11 | * ... 12 | * } 13 | */ 14 | export const includesAsync = wrapAsPromiseAndYieldFn(includes) 15 | -------------------------------------------------------------------------------- /dist/es6/includes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns true if an array includes a value 3 | * @param {Array} array 4 | * @param {any} value 5 | * @returns {Generator<*, boolean, *>} 6 | * @example 7 | * 8 | * prices = price * (yield * includes(items, yielding(v=>v.discount))) ? .4 : 1 9 | */ 10 | export function* includes(array, value) { 11 | for (let i = 0, l = array.length; i < l; i++) { 12 | if (array[i] === value) return true 13 | if ((i & 63) === 0) yield 14 | } 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /dist/es6/index-of-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {indexOf} from './index-of' 3 | 4 | /** 5 | * Returns a promise for the first index of an item in an array 6 | * @param array - the array to scan 7 | * @param value - the value to search for 8 | * @returns {Promise} 9 | */ 10 | export const indexOfAsync = wrapAsPromiseAndYieldFn(indexOf) 11 | -------------------------------------------------------------------------------- /dist/es6/index-of.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns a generator for an index of an item in an array 3 | * @param {Array} array - the array to scan 4 | * @param {*} value - the value to search for 5 | * @returns {Generator<*, number, *>} 6 | */ 7 | export function* indexOf(array, value) { 8 | for (let i = 0, l = array.length; i < l; i++) { 9 | if (array[i] === value) return i 10 | if ((i & 63) === 0) yield 11 | } 12 | return -1 13 | } 14 | -------------------------------------------------------------------------------- /dist/es6/is-object.js: -------------------------------------------------------------------------------- 1 | export function isObject(v) { 2 | return typeof v === 'object' && !Array.isArray(v) 3 | } 4 | -------------------------------------------------------------------------------- /dist/es6/key-by-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {keyBy} from './key-by' 3 | 4 | /** 5 | * Promises the creation an object composed of keys generated from the results 6 | * of running each element of collection thru then supplied function. 7 | * The corresponding value of each key is the last element responsible 8 | * for generating the key. 9 | * 10 | * @param {Array|Object} collection 11 | * @param {Map} fn 12 | * @returns {Promise<{}>} 13 | */ 14 | export const keyByAsync = wrapAsPromiseAndYieldFn(keyBy) 15 | -------------------------------------------------------------------------------- /dist/es6/key-by.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | 3 | /** 4 | * Creates an object composed of keys generated from the results 5 | * of running each element of collection thru then supplied function. 6 | * The corresponding value of each key is the last element responsible 7 | * for generating the key. 8 | * 9 | * @param {Array|Object} collection 10 | * @param {Map} fn 11 | * @returns {Generator<*, {}, *>} a generator for the new object 12 | * @example 13 | * 14 | * let lookup = yield * keyBy(records, yielding(r=>r.id)) 15 | * 16 | * ... 17 | * 18 | * let row = lookup[id] 19 | * 20 | */ 21 | export function* keyBy(collection, fn) { 22 | let result = {} 23 | yield* forEach(collection, function* (value, key) { 24 | let newKey = yield* fn(value, key, collection) 25 | result[newKey] = value 26 | }) 27 | return result 28 | } 29 | -------------------------------------------------------------------------------- /dist/es6/last-index-of-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {lastIndexOf} from './last-index-of' 3 | 4 | /** 5 | * Returns a promise for the last index of an item in an array 6 | * @param array - the array to scan 7 | * @param value - the value to search for 8 | * @returns {Promise} 9 | */ 10 | export const lastIndexOfAsync = wrapAsPromiseAndYieldFn(lastIndexOf) 11 | -------------------------------------------------------------------------------- /dist/es6/last-index-of.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns a generator for an index of an item in an array 3 | * @param {Array} array - the array to scan 4 | * @param {*} value - the value to search for 5 | * @returns {Generator<*, number, *>} 6 | * @example 7 | * 8 | * let last = yield * lastIndexOf(collection, record) 9 | * 10 | */ 11 | export function* lastIndexOf(array, value) { 12 | for (let i = array.length - 1; i >= 0; i--) { 13 | if (array[i] === value) return i 14 | if ((i & 63) === 0) yield 15 | } 16 | return -1 17 | } 18 | -------------------------------------------------------------------------------- /dist/es6/map-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {map} from './map' 3 | 4 | /** 5 | * Maps the contents of an array asynchronously 6 | * @function mapAsync 7 | * @param {Array} array 8 | * @param {Map} mapFn 9 | * @returns {Promise.} promise for the mapped array 10 | */ 11 | export const mapAsync = wrapAsPromiseAndYieldFn(map) 12 | -------------------------------------------------------------------------------- /dist/es6/map.js: -------------------------------------------------------------------------------- 1 | import {isObject} from './is-object' 2 | import {forEach} from './for-each' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Map} fn 8 | * @returns {Generator<*, Array|Object, *>} new collection of mapped values 9 | * @example 10 | * 11 | * const values = yield * map(array, yielding(v=>v ** 2)) 12 | * 13 | */ 14 | export function* map(collection, fn) { 15 | let result = isObject(collection) ? {} : [] 16 | yield* forEach(collection, function* (value, key) { 17 | result[key] = yield* fn(value, key, collection) 18 | }) 19 | return result 20 | } 21 | -------------------------------------------------------------------------------- /dist/es6/pipe.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Create a function that executes a pipeline of 5 | * functions asynchronously 6 | * @param {...(Function|Promise|Array<(Promise|Function|GeneratorFunction|AsyncFunction)>|GeneratorFunction|AsyncFunction)} fns - the pipeline to execute 7 | * @returns {AsyncFunction} an async function to execute the pipeline 8 | */ 9 | export function pipe(...fns) { 10 | return async function (params) { 11 | let result = params 12 | for (let fn of fns.flat(Infinity)) { 13 | if (!fn) continue 14 | let nextResult = fn.call(this, result) 15 | if (nextResult) { 16 | if (nextResult.next) { 17 | result = await run(nextResult) 18 | } else if (nextResult.then) { 19 | result = await nextResult 20 | } else { 21 | result = nextResult 22 | } 23 | } 24 | } 25 | return result 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /dist/es6/reduce-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {reduce} from './reduce' 3 | 4 | /** 5 | * Performs a reduce on an array asynchronously 6 | * @function reduceAsync 7 | * @param {Array} array 8 | * @param {Reduce} reduceFn 9 | * @param {any} initialValue 10 | * @returns {Promise.} a promise for the reduced value 11 | */ 12 | export const reduceAsync = wrapAsPromiseAndYieldFn(reduce) 13 | -------------------------------------------------------------------------------- /dist/es6/reduce.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | 3 | /** 4 | * @param {Array|Object} target 5 | * @param {Reduce} fn 6 | * @param {any} [initial] 7 | * @returns {Generator<*, *, *>} The result of processing the reduction function on all 8 | * of the items in the target 9 | * @example 10 | * 11 | * async function sumAge(items) { 12 | * const output = await reduceAsync(items, (acc,cur)=>acc += cur.age, 0) 13 | * } 14 | */ 15 | export function* reduce(target, fn, initial) { 16 | let result = initial !== undefined ? initial : target[0] 17 | let first = true 18 | yield* forEach(target, function* (item, key) { 19 | if (first && !initial) { 20 | result = item 21 | first = false 22 | } else { 23 | result = yield* fn(result, item, key, target) 24 | } 25 | }) 26 | return result 27 | } 28 | -------------------------------------------------------------------------------- /dist/es6/repeat.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Create a function that repeats a function multiple times 5 | * passing the output of each iteration as the input to the next 6 | * @param {Function} fn - the function to repeat 7 | * @param {Number} times - the number of times to repeat 8 | * @returns {AsyncFunction} - a async function that repeats the operation 9 | */ 10 | export function repeat(fn, times) { 11 | return async function (params) { 12 | let result = params 13 | for (let i = 0; i < times; i++) { 14 | result = fn.call(this, result) 15 | if (result.next) { 16 | result = await run(result) 17 | } else if (result.then) { 18 | result = await result 19 | } 20 | } 21 | return result 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /dist/es6/singleton.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Creates a singleton executor of a generator function. 5 | * If the function is currently running it will be 6 | * terminated with the defaultValue and a new one started. 7 | * 8 | * This would often be used with a UI to cancel a previous calculation 9 | * and begin updates on a new one. 10 | * 11 | * @param {Function} fn - the generator function to wrap 12 | * @param {any} [defaultValue] - a value to be returned if the current execution is 13 | * terminated by a new one starting 14 | * @returns {function(...[*]): Promise} a function to execute the 15 | * generator and return the value 16 | * @example 17 | * 18 | * const job = singleton(function * (array, value) { 19 | * let output = [] 20 | * for(let item of array) { 21 | * if(output.length % 100 === 0) yield 22 | * output.push(complexCalculation(array, value)) 23 | * } 24 | * return output 25 | * }, []) 26 | * 27 | * function doSomething(array) { 28 | * job(array, 2002).then(console.log) 29 | * } 30 | * 31 | * doSomething(bigArray) 32 | * doSomething(otherArray) // -> console.log([]) from first one 33 | * 34 | */ 35 | export function singleton(fn, defaultValue) { 36 | let promise = null 37 | let extraPromises = [] 38 | let result = (...params) => { 39 | if (promise) { 40 | extraPromises.forEach(p => p.terminate()) 41 | extraPromises = [] 42 | promise.terminate(defaultValue) 43 | } 44 | return promise = result._promise = run(fn(...params)) 45 | } 46 | result.join = function (promise) { 47 | extraPromises.push(promise) 48 | return promise 49 | } 50 | return result 51 | } 52 | -------------------------------------------------------------------------------- /dist/es6/some-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {some} from './some' 3 | 4 | /** 5 | * Asynchronously apply an array some operation 6 | * returning a promise for true if at least 7 | * one item matches 8 | * @function someAsync 9 | * @param {Array} array 10 | * @param {Filter} fn 11 | * @returns {Promise.} promise for true if at least one item matched the filter 12 | */ 13 | export const someAsync = wrapAsPromiseAndYieldFn(some) 14 | -------------------------------------------------------------------------------- /dist/es6/some.js: -------------------------------------------------------------------------------- 1 | import {forEach} from './for-each' 2 | import {exitWith} from './array-utilities' 3 | 4 | /** 5 | * @generator 6 | * @param {Array|Object} collection 7 | * @param {Filter} fn 8 | * @returns {Generator<*, boolean, *>} true if at least one item matched the filter 9 | * @example 10 | * 11 | * 12 | * if(yield * some(collection, yielding(v=>v > 2000)) { 13 | * ... 14 | * } 15 | */ 16 | export function* some(collection, fn) { 17 | let result = false 18 | yield* forEach(collection, function* (value, key) { 19 | if (yield* fn(value, key, collection)) { 20 | result = true 21 | return exitWith(true) 22 | } 23 | }) 24 | return result 25 | } 26 | -------------------------------------------------------------------------------- /dist/es6/sort-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromise} from './wrappers' 2 | import {sort} from './timsort' 3 | 4 | /** 5 | *

Sort an array (in place) by a sorting function

6 | *

Sorts an array in place asynchronously. This function is a yielding 7 | * implementation of Timsort (standard sort used in modern browsers). Timsort 8 | * is fast and stable making it ideal for multi-key sorts. It it not as fast 9 | * as Quicksort.

10 | * @function sortAsync 11 | * @param {Array} array - The array to sort 12 | * @param {SortFunction|ExtractFunction} sort - The method to sort the array 13 | * @returns {Promise.} a promise for the sorted array 14 | * @example 15 | * async function process(data) { 16 | * return await sortAsync(data, v=>v.someProperty) 17 | * } 18 | */ 19 | export const sortAsync = wrapAsPromise(sort) 20 | -------------------------------------------------------------------------------- /dist/es6/tap.js: -------------------------------------------------------------------------------- 1 | import run from './run' 2 | 3 | /** 4 | * Tap into a pipeline to call a function that will probably 5 | * perform side effects but should not modify the result, its 6 | * return value is ignored 7 | * @param {Function} fn - a function to be called at this point in 8 | * the pipeline 9 | * @returns {AsyncFunction} returning the passed in parameters 10 | */ 11 | export function tap(fn) { 12 | return async function (params) { 13 | let result = fn.call(this, params) 14 | if (result) { 15 | if (result.next) { 16 | await run(result) 17 | } else if (result.then) { 18 | await result 19 | } 20 | } 21 | return params 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /dist/es6/unique-by-async.js: -------------------------------------------------------------------------------- 1 | import {wrapAsPromiseAndYieldFn} from './async-wrapper-utils' 2 | import {uniqueBy} from './unique-by' 3 | 4 | /** 5 | * Promises the creation of an array with the unique values from the 6 | * input array, the routine is supplied with a 7 | * function that determines on what the array should 8 | * be made unique. 9 | * @param {Array} array 10 | * @param {Map} [fn] - the function to determine uniqueness, if 11 | * omitted then the item itself is used 12 | * @returns {Promise} unique array 13 | */ 14 | export const uniqueByAsync = wrapAsPromiseAndYieldFn(uniqueBy) 15 | -------------------------------------------------------------------------------- /dist/es6/unique-by.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create an array with the unique values from the 3 | * input array, the routine is supplied with a 4 | * function that determines on what the array should 5 | * be made unique. 6 | * @param {Array} array 7 | * @param {Map} [fn] - the function to determine uniqueness, if 8 | * omitted then the item itself is used 9 | * @returns {Generator<*, Array, *>} 10 | * @example 11 | * 12 | * const uniqueValues = yield * uniqueBy(records, yielding(r=>r.id)) 13 | * 14 | */ 15 | export function* uniqueBy(array, fn) { 16 | let set = new Set() 17 | let output = [] 18 | let index = 0 19 | for (let item of array) { 20 | if (fn) { 21 | let key = yield* fn(item, index++, array) 22 | if (!set.has(key)) { 23 | output.push(item) 24 | set.add(key) 25 | } 26 | } else { 27 | if (!set.has(item)) { 28 | output.push(item) 29 | set.add(item) 30 | } 31 | } 32 | } 33 | return output 34 | } 35 | -------------------------------------------------------------------------------- /dist/es6/update.js: -------------------------------------------------------------------------------- 1 | let requested = false 2 | let animationCallbacks = [] 3 | 4 | function nextAnimationFrame(fn) { 5 | if (typeof window === 'undefined') throw new Error('Cannot run without a browser') 6 | if (animationCallbacks.length === 0 && !requested) { 7 | requested = true 8 | requestAnimationFrame(process) 9 | } 10 | animationCallbacks.push(fn) 11 | if (animationCallbacks.length > 10000) animationCallbacks = animationCallbacks.slice(-9000) 12 | } 13 | 14 | function process() { 15 | let callbacks = animationCallbacks 16 | if (callbacks.length) { 17 | requestAnimationFrame(process) 18 | } else { 19 | requested = false 20 | } 21 | animationCallbacks = [] 22 | for (let callback of callbacks) { 23 | callback() 24 | } 25 | } 26 | 27 | /** 28 | * Start an animation coroutine, the animation will continue until 29 | * you return and will be broken up between frames by using a 30 | * yield. 31 | * 32 | * @param {AnimationCoroutine|Iterator} coroutine - The animation to run 33 | * @param {...*} [params] - Parameters to be passed to the animation function 34 | * @returns {Promise} a value that will be returned to the caller 35 | * when the animation is complete. 36 | * The promise returned by update has a terminate() method 37 | * that can be used to stop the routine. 38 | */ 39 | export function update(coroutine, ...params) { 40 | if (typeof window === 'undefined') throw new Error('Requires a browser to run') 41 | let terminated = false 42 | let resolver = null 43 | const result = new Promise(function (resolve, reject) { 44 | resolver = resolve 45 | const iterator = coroutine.next ? coroutine : coroutine(...params) 46 | nextAnimationFrame(run) 47 | 48 | function run() { 49 | if (terminated) { 50 | iterator.return() 51 | return 52 | } 53 | 54 | try { 55 | const {value, done} = iterator.next() 56 | if (done) { 57 | resolve(value) 58 | return 59 | } 60 | } catch (e) { 61 | reject(e) 62 | return 63 | } 64 | 65 | nextAnimationFrame(run) 66 | } 67 | }) 68 | result.terminate = function (result) { 69 | terminated = true 70 | if (resolver) { 71 | resolver(result) 72 | } 73 | } 74 | return result 75 | } 76 | -------------------------------------------------------------------------------- /dist/es6/useInternalEngine.js: -------------------------------------------------------------------------------- 1 | import {getCallback, getNodeCallback} from './polyfill' 2 | 3 | 4 | export let request = typeof window === 'undefined' ? getNodeCallback() : window.requestIdleCallback 5 | 6 | /** 7 | * Call with true to use the polyfilled version of 8 | * the idle callback, can be more stable in certain 9 | * circumstances 10 | * @param {Boolean} internal 11 | */ 12 | export function useInternalEngine(internal) { 13 | request = internal ? getCallback() : request 14 | } 15 | -------------------------------------------------------------------------------- /dist/es6/wrappers.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import run from './run' 4 | import {call} from './call' 5 | 6 | /** 7 | * Wraps a normal function into a generator function 8 | * that yields on a regular basis 9 | * @param {Function} fn - the function to be wrapped 10 | * @param {number} [frequency=8] - 11 | * the number of times the function should be called 12 | * before performing a yield 13 | * @returns {Coroutine} The wrapped yielding 14 | * version of the function passed 15 | */ 16 | export function yielding(fn, frequency = 16) { 17 | let yieldCount = 0; 18 | if(fn._yielding) return fn; 19 | let result = function* (...params) { 20 | let result = fn(...params); 21 | if(result && result.then) { 22 | result = yield result 23 | } 24 | if (yieldCount++ % frequency === 0) { 25 | yield; 26 | } 27 | return result; 28 | }; 29 | result._yielding = true 30 | return result 31 | } 32 | 33 | /** 34 | * @callback PromiseFn 35 | * @param {...*} [parameters] the parameters for the function 36 | * @return {Promise} a promise for the result of the function 37 | */ 38 | 39 | /** 40 | * Returns a function that will execute the passed 41 | * Coroutine and return a Promise for its result. The 42 | * returned function will take any number of parameters 43 | * and pass them on to the coroutine. 44 | * 45 | * @param {Coroutine} coroutine - The coroutine to run 46 | * @returns {PromiseFn|Function} a function that can be called to execute the coroutine 47 | * and return its result on completion 48 | */ 49 | export function wrapAsPromise(coroutine) { 50 | const result = function (...params) { 51 | return run(coroutine(...params)) 52 | }; 53 | result.with = function (...params) { 54 | return call(result, ...params) 55 | } 56 | return result 57 | } 58 | 59 | export function curryRight(fn, supplied, execute) { 60 | if(fn.length > supplied.length) { 61 | return function(...params) { 62 | return curryRight.call(this, fn, [...params, ...supplied], execute) 63 | } 64 | } 65 | return execute.apply(this, supplied) 66 | } 67 | -------------------------------------------------------------------------------- /dist/es6/yastjson/lib/expression.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 5u9ar (zhuyingda) 3 | * 4 | * The above copyright notice and this permission notice shall be included in all 5 | * copies or substantial portions of the Software. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 13 | * SOFTWARE. 14 | */ 15 | export const ExprType = { 16 | Json: "j", 17 | Array: "a", 18 | Object: "o", 19 | Prop: "p", 20 | Value: "v", 21 | }; 22 | -------------------------------------------------------------------------------- /dist/es6/yastjson/lib/parse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 5u9ar (zhuyingda) (c) 2020 Mike Talbot (Generator mods) 3 | * 4 | * The above copyright notice and this permission notice shall be included in all 5 | * copies or substantial portions of the Software. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 13 | * SOFTWARE. 14 | */ 15 | import { Tokenizer } from "./tokenizer"; 16 | import { AST } from "./ast"; 17 | import { ExprType } from "./expression"; 18 | import { TokenType } from "./token"; 19 | import { yielder } from "./yielder"; 20 | 21 | export class ASTParser { 22 | constructor(ast) { 23 | this.ast = ast; 24 | } 25 | 26 | *getJson() { 27 | return yield* this.handleValue(this.ast); 28 | } 29 | 30 | *handleJson(astNode) { 31 | if (astNode.type !== ExprType.Json) { 32 | throw new Error("[parse AST error] unexpected node type, expect Json"); 33 | } 34 | 35 | let output; 36 | let node = astNode.childNodeList[0]; 37 | if (node.type === ExprType.Array) { 38 | output = []; 39 | for (let item of node.childNodeList) { 40 | output.push(yield* this.handleValue(item.value)); 41 | } 42 | } else if (node.type === ExprType.Object) { 43 | output = {}; 44 | for (let item of node.childNodeList) { 45 | output[item.propName] = yield* this.handleValue( 46 | item.childNodeList[0].value 47 | ); 48 | } 49 | } else { 50 | throw new Error("[parse AST error] unexpected second node type"); 51 | } 52 | return output; 53 | } 54 | 55 | *handleValue(astNode) { 56 | if (yielder()) yield; 57 | let token; 58 | switch (astNode.type) { 59 | case TokenType.Null: 60 | return null; 61 | case TokenType.Boolean: 62 | token = astNode.tokens[0].text; 63 | return token === "true"; 64 | case TokenType.Number: 65 | let num = +astNode.tokens[0].text; 66 | return num; 67 | case TokenType.String: 68 | return astNode.tokens[0].text.slice(1, -1); 69 | case ExprType.Json: 70 | return yield* this.handleJson(astNode); 71 | default: 72 | throw new Error( 73 | "[parse AST error] unexpected node type, expect a valid Value node" 74 | ); 75 | } 76 | } 77 | } 78 | 79 | export function* parse(jsonString) { 80 | const tokenizer = new Tokenizer(); 81 | const tokens = yield* tokenizer.tokenize(jsonString); 82 | const astInst = new AST(tokens); 83 | const ast = yield* astInst.buildTree(); 84 | const astParser = new ASTParser(ast); 85 | return yield* astParser.getJson(); 86 | } 87 | -------------------------------------------------------------------------------- /dist/es6/yastjson/lib/token.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 5u9ar (zhuyingda) 3 | * 4 | * The above copyright notice and this permission notice shall be included in all 5 | * copies or substantial portions of the Software. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 13 | * SOFTWARE. 14 | */ 15 | export const TokenType = { 16 | LeftBrace: "{", 17 | RightBrace: "}", 18 | LeftBracket: "l", 19 | RightBracket: "r", 20 | Comma: "c", 21 | Colon: "n", 22 | Null: "0", 23 | Boolean: "t", 24 | Number: "n", 25 | String: "s", 26 | }; 27 | -------------------------------------------------------------------------------- /dist/es6/yastjson/lib/yielder.js: -------------------------------------------------------------------------------- 1 | let yieldCount = 0; 2 | export function yielder() { 3 | if (yieldCount++ > 100) { 4 | yieldCount = 0; 5 | return true; 6 | } 7 | return false; 8 | } 9 | -------------------------------------------------------------------------------- /dist/every.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.every=every;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_forEach=require("./for-each"),_arrayUtilities=require("./array-utilities"),_marked=_regeneratorRuntime2.mark(every);function every(a,b){var c;return _regenerator.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return c=!0,d.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function d(e,f){return _regenerator.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(b(e,f,a),"t0",1);case 1:if(d.t0){d.next=4;break}return c=!1,d.abrupt("return",(0,_arrayUtilities.exitWith)(!1));case 4:case"end":return d.stop();}},d)})),"t0",2);case 2:return d.abrupt("return",c);case 3:case"end":return d.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/filter-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.filterAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_filter=require("./filter"),filterAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_filter.filter);exports.filterAsync=filterAsync; -------------------------------------------------------------------------------- /dist/filter.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.filter=filter;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_isObject=require("./is-object"),_forEach=require("./for-each"),_marked=_regeneratorRuntime2.mark(filter);function filter(a,b){var c,d;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(0,_isObject.isObject)(a)){e.next=6;break}return c={},e.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function a(d,e,f){return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.delegateYield(b(d,e,f),"t0",1);case 1:if(!a.t0){a.next=3;break}c[e]=d;case 3:case"end":return a.stop();}},a)})),"t0",3);case 3:return e.abrupt("return",c);case 6:return d=[],e.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function a(c,e,f){return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.delegateYield(b(c,e,f),"t0",1);case 1:if(!a.t0){a.next=3;break}d.push(c);case 3:case"end":return a.stop();}},a)})),"t1",8);case 8:return e.abrupt("return",d);case 9:case"end":return e.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/find-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_find=require("./find"),findAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_find.find);exports.findAsync=findAsync; -------------------------------------------------------------------------------- /dist/find-index-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findIndexAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_findIndex=require("./find-index"),findIndexAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_findIndex.findIndex);exports.findIndexAsync=findIndexAsync; -------------------------------------------------------------------------------- /dist/find-index.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.findIndex=findIndex;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_forEach=require("./for-each"),_arrayUtilities=require("./array-utilities"),_marked=_regeneratorRuntime2.mark(findIndex);function findIndex(a,b,c){var d;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return d=-1,e.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function c(e,f){var g;return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.delegateYield(b(e,f,a),"t0",1);case 1:if(g=c.t0,!g){c.next=5;break}return d=f,c.abrupt("return",(0,_arrayUtilities.exitWith)(f));case 5:case"end":return c.stop();}},c)}),c),"t0",2);case 2:return e.abrupt("return",d);case 3:case"end":return e.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/find.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.find=find;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_forEach=require("./for-each"),_arrayUtilities=require("./array-utilities"),_marked=_regeneratorRuntime2.mark(find);function find(a,b,c){var d;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return d=void 0,e.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function c(e,f){var g;return _regenerator.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.delegateYield(b(e,f,a),"t0",1);case 1:if(g=c.t0,!g){c.next=5;break}return d=e,c.abrupt("return",(0,_arrayUtilities.exitWith)(e));case 5:case"end":return c.stop();}},c)}),c),"t0",2);case 2:return e.abrupt("return",d);case 3:case"end":return e.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/for-each-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.forEachAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_forEach=require("./for-each"),forEachAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_forEach.forEach);exports.forEachAsync=forEachAsync; -------------------------------------------------------------------------------- /dist/for-each.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.forEach=forEach;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_isObject=require("./is-object"),_arrayUtilities=require("./array-utilities"),_marked=_regenerator.default.mark(forEach);function forEach(a,b,c){var d,e,f,g,h,i;return _regenerator.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(!(0,_isObject.isObject)(a)){j.next=16;break}d=!c,j.t0=_regenerator.default.keys(a);case 3:if((j.t1=j.t0()).done){j.next=14;break}if(e=j.t1.value,d||(d=e===c),!d){j.next=12;break}if(!Object.prototype.hasOwnProperty.call(a,e)){j.next=12;break}return j.delegateYield(b(a[e],e,a),"t2",9);case 9:if(f=j.t2,!(f&&f[_arrayUtilities.doReturn])){j.next=12;break}return j.abrupt("return",f.value);case 12:j.next=3;break;case 14:j.next=25;break;case 16:g=c||0,h=a.length;case 17:if(!(g=o.length?{done:!0}:{done:!1,value:o[c++]}},e:function e(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f=!0,g=!1;return{s:function s(){b=o[Symbol.iterator]()},n:function n(){var a=b.next();return f=a.done,a},e:function e(a){g=!0,e=a},f:function f(){try{f||null==b.return||b.return()}finally{if(g)throw e}}}}function _unsupportedIterableToArray(o,a){if(o){if("string"==typeof o)return _arrayLikeToArray(o,a);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,a):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c=o.length?{done:!0}:{done:!1,value:o[c++]}},e:function e(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f=!0,g=!1;return{s:function s(){b=o[Symbol.iterator]()},n:function n(){var a=b.next();return f=a.done,a},e:function e(a){g=!0,e=a},f:function f(){try{f||null==b.return||b.return()}finally{if(g)throw e}}}}function _unsupportedIterableToArray(o,a){if(o){if("string"==typeof o)return _arrayLikeToArray(o,a);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,a):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);ci)){a.next=29;break}return a.t0=k,a.next=14,m;case 14:if(a.t1=a.sent,o=a.t0.next.call(a.t0,a.t1),p=o.value,q=o.done,m=void 0,!q){a.next=22;break}return f(p),a.abrupt("return");case 22:if(!0!==p){a.next=26;break}return a.abrupt("break",29);case 26:"number"==typeof p?(i=+p,isNaN(i)&&(i=minRemainingTime)):p&&p.then&&(m=p);case 27:a.next=10;break;case 29:a.next=36;break;case 31:return a.prev=31,a.t2=a["catch"](9),console.error(a.t2),g(a.t2),a.abrupt("return");case 36:(0,_useInternalEngine.request)(h),c&&(l=setTimeout(j,c));case 38:return a.prev=38,n=!1,a.finish(38);case 41:case"end":return a.stop();}},a,null,[[2,,38,41],[9,31]])})),i.apply(this,arguments)}function j(){var a=Date.now();h({timeout:!0,timeRemaining:function timeRemaining(){return 12.5-(Date.now()-a)}})}e=f;var k=a.next?a:a();(0,_useInternalEngine.request)(h);var l=0,m=void 0,n=!1});return f.terminate=function(a){d=!0,e&&e(a)},f}var _default=run;exports.default=_default; -------------------------------------------------------------------------------- /dist/singleton.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _run=_interopRequireDefault(require("./run"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.singleton=singleton;function singleton(a,b){var c=null,d=[],e=function(){return c&&(d.forEach(function(a){return a.terminate()}),d=[],c.terminate(b)),c=e._promise=(0,_run.default)(a.apply(void 0,arguments))};return e.join=function(a){return d.push(a),a},e} -------------------------------------------------------------------------------- /dist/some-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.someAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_some=require("./some"),someAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_some.some);exports.someAsync=someAsync; -------------------------------------------------------------------------------- /dist/some.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.some=some;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_forEach=require("./for-each"),_arrayUtilities=require("./array-utilities"),_marked=_regeneratorRuntime2.mark(some);function some(a,b){var c;return _regenerator.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return c=!1,d.delegateYield((0,_forEach.forEach)(a,_regenerator.default.mark(function d(e,f){return _regenerator.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(b(e,f,a),"t0",1);case 1:if(!d.t0){d.next=4;break}return c=!0,d.abrupt("return",(0,_arrayUtilities.exitWith)(!0));case 4:case"end":return d.stop();}},d)})),"t0",2);case 2:return d.abrupt("return",c);case 3:case"end":return d.stop();}},_marked)} -------------------------------------------------------------------------------- /dist/sort-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortAsync=void 0;var _wrappers=require("./wrappers"),_timsort=require("./timsort"),sortAsync=(0,_wrappers.wrapAsPromise)(_timsort.sort);exports.sortAsync=sortAsync; -------------------------------------------------------------------------------- /dist/tap.js: -------------------------------------------------------------------------------- 1 | "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.tap=tap;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_run=_interopRequireDefault(require("./run"));function tap(a){return function(){var b=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function b(c){var d;return _regenerator.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(d=a.call(this,c),!d){b.next=10;break}if(!d.next){b.next=7;break}return b.next=5,(0,_run.default)(d);case 5:b.next=10;break;case 7:if(!d.then){b.next=10;break}return b.next=10,d;case 10:return b.abrupt("return",c);case 11:case"end":return b.stop();}},b,this)}));return function(){return b.apply(this,arguments)}}()} -------------------------------------------------------------------------------- /dist/unique-by-async.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uniqueByAsync=void 0;var _asyncWrapperUtils=require("./async-wrapper-utils"),_uniqueBy=require("./unique-by"),uniqueByAsync=(0,_asyncWrapperUtils.wrapAsPromiseAndYieldFn)(_uniqueBy.uniqueBy);exports.uniqueByAsync=uniqueByAsync; -------------------------------------------------------------------------------- /dist/unique-by.js: -------------------------------------------------------------------------------- 1 | "use strict";var _regeneratorRuntime2=require("@babel/runtime/regenerator"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.uniqueBy=uniqueBy;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_marked=_regeneratorRuntime2.mark(uniqueBy);function _createForOfIteratorHelper(o,a){var b;if("undefined"==typeof Symbol||null==o[Symbol.iterator]){if(Array.isArray(o)||(b=_unsupportedIterableToArray(o))||a&&o&&"number"==typeof o.length){b&&(o=b);var c=0,d=function(){};return{s:d,n:function n(){return c>=o.length?{done:!0}:{done:!1,value:o[c++]}},e:function e(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f=!0,g=!1;return{s:function s(){b=o[Symbol.iterator]()},n:function n(){var a=b.next();return f=a.done,a},e:function e(a){g=!0,e=a},f:function f(){try{f||null==b.return||b.return()}finally{if(g)throw e}}}}function _unsupportedIterableToArray(o,a){if(o){if("string"==typeof o)return _arrayLikeToArray(o,a);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,a):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c=o.length?{done:!0}:{done:!1,value:o[c++]}},e:function e(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f=!0,g=!1;return{s:function s(){b=o[Symbol.iterator]()},n:function n(){var a=b.next();return f=a.done,a},e:function e(a){g=!0,e=a},f:function f(){try{f||null==b.return||b.return()}finally{if(g)throw e}}}}function _unsupportedIterableToArray(o,a){if(o){if("string"==typeof o)return _arrayLikeToArray(o,a);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,a):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);cb.length?function(){for(var d=arguments.length,e=Array(d),f=0;f