From e3d7111442f34dfaa3ae996a680b1be6cf39a3d3 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 06:49:19 -0700 Subject: [PATCH 01/33] ready to publish --- README.md | 15 +++++++++++---- package.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f0dcb33..391b1f5 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ JS challenge by @thdxr on X.com


`n-tuple-array` solution code
-[](./assets/demo-classic.svg) +[](https://github.com/chalu/n-tuple-array/blob/main/src/demo/demo-classic.ts#L6-L40)

`n-tuple-array` n-tuple-array solution demo
@@ -56,12 +56,13 @@ JS challenge by @thdxr on X.com
## Setup & Usage ```bash -npm install n-tuple-array +npm install @chalu/n-tuple-array ``` ```javascript import { tuplesFromArray } from 'n-tuple-array'; +// some setup const numbers = Array.from({length: 100}, (_, i) => i + 1); const isEven = (item) => { if ( @@ -73,8 +74,14 @@ const isEven = (item) => { return true; }; -for (const triplets of tuplesFromArray({list: numbers, maxItems: 3, match: isEven})) { - console.log(triplets); +// use the lib +const quintetIterator = tuplesFromArray({ + list: numbers, maxItems: 5, match: isEven +}); + +for (const quintet of quintetIterator) { + // prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] + console.log(quintet); } ``` diff --git a/package.json b/package.json index d98121b..897eb01 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "n-tuple-array", + "name": "@chalu/n-tuple-array", "version": "0.1", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that native arrays provide!", "main": "dist/index.js", From 51add333de5845b97eacb0b26a00b1579e90bbca Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 07:57:16 -0700 Subject: [PATCH 02/33] add CD workflow --- .github/workflows/CD.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/CD.yaml diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml new file mode 100644 index 0000000..8ce8733 --- /dev/null +++ b/.github/workflows/CD.yaml @@ -0,0 +1,24 @@ +name: CD +on: + pull_request: + types: [ closed ] + +jobs: + build-and-test: + if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Print ENV + run: | + echo ${ github.event.pull_request.base.ref } + echo ${ github.event.pull_request } + + # - name: Publish to Registry + # uses: JS-DevTools/npm-publish@v3 + # with: + # token: ${{ secrets.NPM_TOKEN }} + \ No newline at end of file From 16d3398acf08593eb0e561490632e0bff52eae05 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 07:58:50 -0700 Subject: [PATCH 03/33] lint only changed TS or JS files --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 897eb01..aa2d186 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "build": "tsc", "prebuild": "rm -rf dist/*", "postbuild": "rm -rf dist/demo/*.d.*", - "lint": "xo", - "lint:fix": "xo --fix", + "lint": "xo $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", + "lint:fix": "xo --fix $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", "test": "jest --runInBand", "pretest": "pnpm lint && pnpm build", "test:ci": "jest --ci --config='./jest.config.ci.ts'", From d0de98d58e799a93706bee0176614f6388607658 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 08:03:40 -0700 Subject: [PATCH 04/33] fix CD job name --- .github/workflows/CD.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 8ce8733..87083f6 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -4,7 +4,7 @@ on: types: [ closed ] jobs: - build-and-test: + publish-to-registry: if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true runs-on: ubuntu-latest From 83348c4aadee82d7b34f12283c3329a135ef8a2c Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 08:09:34 -0700 Subject: [PATCH 05/33] run CI only on PR to dev or main --- .github/workflows/CI.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 7a5502b..d355aee 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,9 +1,5 @@ name: CI on: - push: - branches: - - "!main" - - "*" pull_request: branches: - "dev" From d8979e9c8dfdbed2591ee53ad4092cd486544b9f Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 08:26:19 -0700 Subject: [PATCH 06/33] dry run package publishing --- .github/workflows/CD.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 87083f6..324e1ff 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -12,13 +12,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Print ENV - run: | - echo ${ github.event.pull_request.base.ref } - echo ${ github.event.pull_request } - - # - name: Publish to Registry - # uses: JS-DevTools/npm-publish@v3 - # with: - # token: ${{ secrets.NPM_TOKEN }} + - name: Publish to Registry + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + dry-run: true \ No newline at end of file From 2b39e3e8075486c0f8fe4e1443626d3f8c171d32 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 08:40:31 -0700 Subject: [PATCH 07/33] dry run publish on dev branch --- .github/workflows/CD.yaml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 324e1ff..d7adac2 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -5,7 +5,7 @@ on: jobs: publish-to-registry: - if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true + if: github.event.pull_request.base.ref == 'dev' && github.event.pull_request.merged == true runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index aa2d186..7224684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.1", + "version": "0.0.1", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that native arrays provide!", "main": "dist/index.js", "types": "dist/index.d.ts", From 0cfbc0326f87e4318d24c442b9d0eee635c1e1e2 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 10:53:02 -0700 Subject: [PATCH 08/33] get production ready --- .github/workflows/CI.yaml | 3 ++ .github/workflows/snyk.yml | 14 ++++++++ README.md | 2 +- __tests__/smoke.test.js | 2 +- dist/{ => cjs}/index.js | 0 dist/{ => cjs/types}/index.d.ts | 1 + dist/cjs/types/index.d.ts.map | 1 + dist/demo/demo-basics.js | 34 ------------------ dist/demo/demo-classic.js | 32 ----------------- dist/demo/demo-utils.js | 36 ------------------- dist/esm/index.mjs | 62 +++++++++++++++++++++++++++++++++ dist/esm/types/index.d.ts | 13 +++++++ dist/esm/types/index.d.ts.map | 1 + package.json | 38 +++++++++++++++----- tsconfig.base.json | 20 +++++++++++ tsconfig.cjs.json | 14 ++++++++ tsconfig.esm.json | 14 ++++++++ tsconfig.json | 24 ------------- 18 files changed, 174 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/snyk.yml rename dist/{ => cjs}/index.js (100%) rename dist/{ => cjs/types}/index.d.ts (92%) create mode 100644 dist/cjs/types/index.d.ts.map delete mode 100644 dist/demo/demo-basics.js delete mode 100644 dist/demo/demo-classic.js delete mode 100644 dist/demo/demo-utils.js create mode 100644 dist/esm/index.mjs create mode 100644 dist/esm/types/index.d.ts create mode 100644 dist/esm/types/index.d.ts.map create mode 100644 tsconfig.base.json create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json delete mode 100644 tsconfig.json diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index d355aee..30a9629 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,5 +1,8 @@ name: CI on: + push: + branches-ignore: + - "main" pull_request: branches: - "dev" diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml new file mode 100644 index 0000000..199ccdd --- /dev/null +++ b/.github/workflows/snyk.yml @@ -0,0 +1,14 @@ +name: Security Check + +on: [push, pull_request] + +jobs: + security-audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check for Security Vulnerabilities + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 391b1f5..9fcee3b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ npm install @chalu/n-tuple-array ``` ```javascript -import { tuplesFromArray } from 'n-tuple-array'; +const { tuplesFromArray } = require('@chalu/n-tuple-array'); // some setup const numbers = Array.from({length: 100}, (_, i) => i + 1); diff --git a/__tests__/smoke.test.js b/__tests__/smoke.test.js index 5a81cb3..acd34ce 100644 --- a/__tests__/smoke.test.js +++ b/__tests__/smoke.test.js @@ -1,4 +1,4 @@ -const {tuplesFromArray, InvalidInvocationParameterError} = require('../dist/index.js'); +const {tuplesFromArray, InvalidInvocationParameterError} = require('../dist/cjs/index.js'); describe('Smoke Tests', () => { it('should throw if input array is not specified', () => { diff --git a/dist/index.js b/dist/cjs/index.js similarity index 100% rename from dist/index.js rename to dist/cjs/index.js diff --git a/dist/index.d.ts b/dist/cjs/types/index.d.ts similarity index 92% rename from dist/index.d.ts rename to dist/cjs/types/index.d.ts index aea6b25..cb5aa72 100644 --- a/dist/index.d.ts +++ b/dist/cjs/types/index.d.ts @@ -10,3 +10,4 @@ export declare class InvalidInvocationParameterError extends Error { } export declare const tuplesFromArray: (config: TupleConfig) => Iterable>; export default tuplesFromArray; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/cjs/types/index.d.ts.map b/dist/cjs/types/index.d.ts.map new file mode 100644 index 0000000..8d87987 --- /dev/null +++ b/dist/cjs/types/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAC7B,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAG/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,mDAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/demo/demo-basics.js b/dist/demo/demo-basics.js deleted file mode 100644 index 6f01236..0000000 --- a/dist/demo/demo-basics.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const index_1 = require("../index"); -const demo_utils_1 = require("./demo-utils"); -console.log('----- Example 1 [10 Hex in twos. Used default param values] ------'); -for (const hexPair of (0, index_1.tuplesFromArray)({ list: (0, demo_utils_1.hexadecimals)(10) })) { - console.log(hexPair); -} -console.log('\n----- Example 2 [30 Hex in fives. Specified maxItems] ------'); -for (const hexQuintet of (0, index_1.tuplesFromArray)({ list: (0, demo_utils_1.hexadecimals)(30), maxItems: 5 })) { - console.log(hexQuintet); -} -console.log('\n----- Example 3 [Dates in twos. Filtered in by a match function] ------'); -// Create an array of 50 elements which include some dates -const data = [...(0, demo_utils_1.hexadecimals)(20), ...(0, demo_utils_1.dates)(10), ...(0, demo_utils_1.uuids)(20)]; -// Use a basic/weak shuffle algo to shuffle the array items -data.sort(() => Math.random() - 0.5); -for (const dateTriplet of (0, index_1.tuplesFromArray)({ list: data, match: demo_utils_1.isDate })) { - console.log(dateTriplet); -} -console.log('\n----- Example 4 [Tuples can be "remainders", see the last array/tuple] ------'); -for (const idTriplets of (0, index_1.tuplesFromArray)({ list: (0, demo_utils_1.uuids)(8), maxItems: 3 })) { - console.log(idTriplets); -} -const dozenHexValues = (0, demo_utils_1.hexadecimals)(12); -const hexIterable = (0, index_1.tuplesFromArray)({ list: dozenHexValues, maxItems: 2 }); -const hexPairs = Array.from(hexIterable); -console.log('Array.from( tuplesFromArray(...) ) is an Array:', Array.isArray(hexPairs)); -// Use native Array methods -hexPairs - .map(pair => pair.toString().toUpperCase().split(',')) - .forEach(pair => { - console.log(pair); -}); diff --git a/dist/demo/demo-classic.js b/dist/demo/demo-classic.js deleted file mode 100644 index cbcab33..0000000 --- a/dist/demo/demo-classic.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const index_1 = require("../index"); -const demo_utils_1 = require("./demo-utils"); -const processItem = async (item) => { - await (0, demo_utils_1.delay)(Math.random() * 500); // Simulate some async workload - const processed = (item instanceof Date && (0, demo_utils_1.isDate)(item)) ? demo_utils_1.canadaDateFormat.format(item) : item; - return processed; -}; -const parallelPool = async (tasks, prarallelSize) => { - const processed = []; - const parallelSizeAwareIterable = (0, index_1.tuplesFromArray)({ - list: tasks, - maxItems: prarallelSize, - }); - let count = 1; - for await (const cohort of parallelSizeAwareIterable) { - const results = await Promise.allSettled(cohort.map(async (itm) => processItem(itm))); - processed.push(...results); - console.log(`processed ${(0, demo_utils_1.formatCount)(count)} batch of <= ${prarallelSize} items`); - if ((count * prarallelSize) >= tasks.length) { - console.log('DONE!'); - } - count += 1; - } - return processed; -}; -(async () => { - const canadianDates = await parallelPool((0, demo_utils_1.dates)(12), 3); - console.log('-------------------'); - console.log(canadianDates); -})(); diff --git a/dist/demo/demo-utils.js b/dist/demo/demo-utils.js deleted file mode 100644 index ef25db0..0000000 --- a/dist/demo/demo-utils.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.delay = exports.formatCount = exports.canadaDateFormat = exports.isDate = exports.hexadecimals = exports.dates = exports.uuids = void 0; -const faker_1 = require("@faker-js/faker"); -/** - * Some Helper Functions - */ -const factory = (generator, howMany = 20) => faker_1.simpleFaker.helpers.multiple(generator, { count: howMany }); -const uuids = (howMany) => factory(faker_1.simpleFaker.string.uuid, howMany); -exports.uuids = uuids; -const dates = (howMany) => factory(faker_1.simpleFaker.date.birthdate, howMany); -exports.dates = dates; -const hexadecimals = (howMany) => factory(faker_1.simpleFaker.string.hexadecimal, howMany); -exports.hexadecimals = hexadecimals; -const isDate = (date) => (date instanceof Date) && !Number.isNaN(date.getTime()); -exports.isDate = isDate; -exports.canadaDateFormat = new Intl.DateTimeFormat('en-CA', { - dateStyle: 'medium', -}); -const plural = new Intl.PluralRules('en-US', { type: 'ordinal' }); -const suffixes = new Map([ - ['one', 'st'], - ['two', 'nd'], - ['few', 'rd'], - ['other', 'th'], -]); -const formatCount = (n) => { - const rule = plural.select(n); - const suffix = suffixes.get(rule); - return `${n}${suffix}`; -}; -exports.formatCount = formatCount; -const delay = async (ms) => new Promise(resolve => { - setTimeout(resolve, ms); -}); -exports.delay = delay; diff --git a/dist/esm/index.mjs b/dist/esm/index.mjs new file mode 100644 index 0000000..927cbf0 --- /dev/null +++ b/dist/esm/index.mjs @@ -0,0 +1,62 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.tuplesFromArray = exports.InvalidInvocationParameterError = void 0; +class InvalidInvocationParameterError extends Error { +} +exports.InvalidInvocationParameterError = InvalidInvocationParameterError; +const validateParametersOrThrow = (list, maxItems, match) => { + if (!list || !Array.isArray(list)) { + throw new InvalidInvocationParameterError('expected list to be an array'); + } + if (typeof maxItems !== 'number' + || (typeof maxItems === 'number' && maxItems <= 0)) { + const message = 'expected maxItems (when provided) to be a positive integer (1 and above)'; + throw new InvalidInvocationParameterError(message); + } + if (match !== undefined && typeof match !== 'function') { + const message = 'expected match (when provided) to be a function'; + throw new InvalidInvocationParameterError(message); + } +}; +const tuplesFromArray = (config) => { + const { list, match, maxItems = 2 } = config; + validateParametersOrThrow(list, maxItems, match); + let cursor = 0; + const maxItemSize = Number.parseInt(`${maxItems}`, 10); + const proceedNext = () => { + const items = []; + if (cursor >= list.length) { + return { done: true, value: [] }; + } + const endIndex = match === undefined + // A match funtion was provided. Okay to run to array end + // or until we've matched maxItemSize elements + ? Math.min(cursor + maxItemSize, list.length) + // No match function was provided. We should run till we are + // out of items (list.length) or till we gotten the next set + // of maxItemSize items + : list.length; + while (cursor < endIndex) { + const item = list[cursor]; + cursor += 1; + if (match && !match(item)) { + continue; + } + items.push(item); + if (match && items.length === maxItemSize) { + break; + } + } + return { value: items, done: items.length === 0 }; + }; + const iterable = { + [Symbol.iterator]() { + return { + next: proceedNext, + }; + }, + }; + return iterable; +}; +exports.tuplesFromArray = tuplesFromArray; +exports.default = exports.tuplesFromArray; diff --git a/dist/esm/types/index.d.ts b/dist/esm/types/index.d.ts new file mode 100644 index 0000000..cb5aa72 --- /dev/null +++ b/dist/esm/types/index.d.ts @@ -0,0 +1,13 @@ +type Item = T | undefined; +type Value = Array>; +export type Matcher = (item: T | unknown) => boolean; +export type TupleConfig = { + list: T[]; + maxItems?: number; + match?: Matcher; +}; +export declare class InvalidInvocationParameterError extends Error { +} +export declare const tuplesFromArray: (config: TupleConfig) => Iterable>; +export default tuplesFromArray; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/esm/types/index.d.ts.map b/dist/esm/types/index.d.ts.map new file mode 100644 index 0000000..8d87987 --- /dev/null +++ b/dist/esm/types/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAC7B,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAG/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,mDAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 7224684..2d79c9b 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,36 @@ { "name": "@chalu/n-tuple-array", "version": "0.0.1", - "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that native arrays provide!", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", + "main": "./dist/cjs/index.js", + "types": "./dist/cjs/types/index.d.ts", "files": [ - "/dist" + "dist/**/*" ], + "exports": { + ".": { + "import": { + "types": "./dist/esm/types/index.d.ts", + "default": "./dist/esm/index.mjs" + }, + "require": { + "types": "./dist/cjs/types/index.d.ts", + "default": "./dist/cjs/index.js" + } + } + }, "scripts": { - "build": "tsc", - "prebuild": "rm -rf dist/*", - "postbuild": "rm -rf dist/demo/*.d.*", + "build": "pnpm build:esm && pnpm build:cjs", + "prebuild": "rm -rf dist", + "build:esm": "tsc -p tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs", + "build:cjs": "tsc -p tsconfig.cjs.json", "lint": "xo $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", "lint:fix": "xo --fix $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", - "test": "jest --runInBand", + "test": "jest", "pretest": "pnpm lint && pnpm build", "test:ci": "jest --ci --config='./jest.config.ci.ts'", - "prepare": "husky" + "prepare": "husky", + "prepack": "pnpm build" }, "keywords": ["array", "tuple", "arrays", "tuples", "iterables", "iterators", "symbol.iterator", "javascript", "typescript"], "author": "Charles Odili ", @@ -32,5 +46,11 @@ "ts-node": "^10.9.2", "typescript": "^5.3.3", "xo": "^0.57.0" + }, + "release": { + "branches": ["main"] + }, + "publishConfig": { + "access": "public" } } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..aa3027b --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "strict": true, + "rootDir": "./src", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "checkJs": true, + "allowJs": true, + "declaration": true, + "declarationMap": true, + "allowSyntheticDefaultImports": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "src/demo/**" + ] +} \ No newline at end of file diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..5d35037 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": [ + "ES2022", + "DOM" + ], + "target": "ES2022", + "module": "CommonJS", + "moduleResolution": "Node", + "outDir": "dist/cjs", + "declarationDir": "dist/cjs/types" + } +} \ No newline at end of file diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..8beeb6a --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": [ + "ES2022", + "DOM" + ], + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist/esm", + "declarationDir": "dist/esm/types" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index f86599f..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Language and Environment */ - "lib": ["ES2022", "dom"], - "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - "rootDir": "./src", /* Specify the root folder within your source files. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ /* Ensure that casing is correct in imports. */ - "moduleResolution": "node", - "resolveJsonModule": true, - /* Type Checking */ - "strict": true, /* Skip type checking all .d.ts files. */ - "noUncheckedIndexedAccess": true, - "skipLibCheck": true - }, - "include": [ - "src/**/*" - ] -} \ No newline at end of file From bbf5f0b2d16115c856b7f4215d3b85256a7e6312 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 10:53:40 -0700 Subject: [PATCH 09/33] make a default tsconfig from the ESM config --- tsconfig.base.json | 1 + tsconfig.json | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 tsconfig.json diff --git a/tsconfig.base.json b/tsconfig.base.json index aa3027b..211db10 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,6 +9,7 @@ "allowJs": true, "declaration": true, "declarationMap": true, + "noUncheckedIndexedAccess": true, "allowSyntheticDefaultImports": true }, "include": [ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..166936b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./tsconfig.esm.json" +} \ No newline at end of file From 41ba737f2dc804c64daaa54b0729b74a6be29f02 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 12:08:43 -0700 Subject: [PATCH 10/33] dry run release from GHA --- .github/workflows/CD.yaml | 9 +++++++-- package.json | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index d7adac2..3966c02 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -1,10 +1,11 @@ -name: CD +name: Release + on: pull_request: types: [ closed ] jobs: - publish-to-registry: + release: if: github.event.pull_request.base.ref == 'dev' && github.event.pull_request.merged == true runs-on: ubuntu-latest @@ -12,6 +13,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - uses: jaywcjlove/github-action-package@main + with: + unset: scripts.prepare + - name: Publish to Registry uses: JS-DevTools/npm-publish@v3 with: diff --git a/package.json b/package.json index 2d79c9b..7b2c5cc 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,17 @@ "prepare": "husky", "prepack": "pnpm build" }, - "keywords": ["array", "tuple", "arrays", "tuples", "iterables", "iterators", "symbol.iterator", "javascript", "typescript"], + "keywords": [ + "array", + "tuple", + "arrays", + "tuples", + "iterables", + "iterators", + "symbol.iterator", + "javascript", + "typescript" + ], "author": "Charles Odili ", "license": "MIT", "devDependencies": { @@ -48,9 +58,15 @@ "xo": "^0.57.0" }, "release": { - "branches": ["main"] + "branches": [ + "main" + ] }, "publishConfig": { "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/chalu/n-tuple-array.git" } } From d706086e39f24bb01df1439cc8ebf9e2f3b466d7 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 12:16:44 -0700 Subject: [PATCH 11/33] prune GHA runs --- .github/workflows/CI.yaml | 1 + .github/workflows/snyk.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 30a9629..369eac9 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -3,6 +3,7 @@ on: push: branches-ignore: - "main" + - "dev" pull_request: branches: - "dev" diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml index 199ccdd..fb3f98f 100644 --- a/.github/workflows/snyk.yml +++ b/.github/workflows/snyk.yml @@ -1,6 +1,6 @@ name: Security Check -on: [push, pull_request] +on: [pull_request] jobs: security-audit: From 0d3d8b1552d9176942640afa2538006bb3be275f Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 12:24:18 -0700 Subject: [PATCH 12/33] attempt release from GHA --- .github/workflows/CD.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 3966c02..8e04669 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -21,5 +21,4 @@ jobs: uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - dry-run: true \ No newline at end of file From 670b7c1fa8e01d9e8a347acbfb14e3439332434e Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 12:52:41 -0700 Subject: [PATCH 13/33] attempt release from GHA --- .github/workflows/CD.yaml | 10 +++++++++- package.json | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 8e04669..4ad91a8 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -13,12 +13,20 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: jaywcjlove/github-action-package@main + - name: PKG Info + id: pkg + uses: jaywcjlove/github-action-package@main with: unset: scripts.prepare - name: Publish to Registry + id: publish uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} + tag: ${{ steps.pkg.outputs.version }} + + - name: Release Status + if: ${{ steps.publish.outputs.type }} + run: echo "Published v${{ steps.pkg.outputs.version }}" \ No newline at end of file diff --git a/package.json b/package.json index 7b2c5cc..fddd638 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.0.1", + "version": "0.0.2", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", @@ -67,6 +67,6 @@ }, "repository": { "type": "git", - "url": "https://github.com/chalu/n-tuple-array.git" + "url": "git+https://github.com/chalu/n-tuple-array.git" } } From b528f0c489b3df26d802df9b157725cd7c7f32a5 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:00:23 -0700 Subject: [PATCH 14/33] fix package json file --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9178e5a..fddd638 100644 --- a/package.json +++ b/package.json @@ -68,4 +68,5 @@ "repository": { "type": "git", "url": "git+https://github.com/chalu/n-tuple-array.git" + } } From f0a3f5ff6f2e8ca8393ae417bb71b0a1a6ed07f7 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:11:02 -0700 Subject: [PATCH 15/33] fix version --- .github/workflows/CD.yaml | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 4ad91a8..42ae78c 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -2,7 +2,9 @@ name: Release on: pull_request: - types: [ closed ] + branches: + - "dev" + # types: [ closed ] jobs: release: @@ -25,6 +27,7 @@ jobs: with: token: ${{ secrets.NPM_TOKEN }} tag: ${{ steps.pkg.outputs.version }} + dry-run: true - name: Release Status if: ${{ steps.publish.outputs.type }} diff --git a/package.json b/package.json index fddd638..1c18dbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.0.2", + "version": "1.0.1", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", From 2a291043ed7c6bf556f097a2d8e1fcea70c2ee33 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:19:12 -0700 Subject: [PATCH 16/33] remove merged condition --- .github/workflows/CD.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index ad5cbe0..0fbaacf 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -8,7 +8,6 @@ on: jobs: release: - if: github.event.pull_request.base.ref == 'dev' && github.event.pull_request.merged == true runs-on: ubuntu-latest steps: From db425450eed5873b243e8d49f76fba4b3bbadadd Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:21:28 -0700 Subject: [PATCH 17/33] fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c18dbd..7488627 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "1.0.1", + "version": "1.0.0", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", From f176ab09937cae6e98b877c4befd5729b142312d Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:27:41 -0700 Subject: [PATCH 18/33] fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7488627..468cce4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "1.0.0", + "version": "0.1.3", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", From 1d5adb1cf0e0b832fa8d219527a42052df5402a0 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:30:20 -0700 Subject: [PATCH 19/33] use latest tag --- .github/workflows/CD.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 0fbaacf..362505f 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -25,8 +25,6 @@ jobs: uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - tag: ${{ steps.pkg.outputs.version }} - dry-run: true - name: Release Status if: ${{ steps.publish.outputs.type }} From 387b3e2c99e5d1e8a1032c4a5d7078cff546305b Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 13:37:04 -0700 Subject: [PATCH 20/33] fix release workflow --- .github/workflows/CD.yaml | 13 +++++-------- package.json | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 362505f..884c28e 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -2,12 +2,13 @@ name: Release on: pull_request: - branches: - - "dev" - # types: [ closed ] + branches: + - "dev" + types: [ closed ] jobs: release: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: @@ -25,8 +26,4 @@ jobs: uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - - - name: Release Status - if: ${{ steps.publish.outputs.type }} - run: echo "Published v${{ steps.pkg.outputs.version }}" - \ No newline at end of file + \ No newline at end of file diff --git a/package.json b/package.json index 468cce4..c30e1b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.1.3", + "version": "0.1.4", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", From dd323c07618009541e6e9f3308651c58b530b32a Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 14:01:12 -0700 Subject: [PATCH 21/33] prepare first public release --- .github/workflows/CD.yaml | 2 +- README.md | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index 884c28e..35588d9 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -3,7 +3,7 @@ name: Release on: pull_request: branches: - - "dev" + - "main" types: [ closed ] jobs: diff --git a/README.md b/README.md index 9fcee3b..f385ae2 100644 --- a/README.md +++ b/README.md @@ -29,26 +29,33 @@ const coordPairs = Array.from(coordIterable); console.log(Array.isArray(coordPairs)); // true // prints ["5.7225", "-9.6273"] ... coordPairs - .map(pair => myTransform(pair)) - .forEach((pair) => placeOnMap(pair)); + .map(pair => { + return myTransform(pair); + }) + .forEach((pair) => { + placeOnMap(pair); + }); ``` ### Some Real World Examples -> I first had this idea and tried my hands on it when [building wole-joko](https://github.com/chalu/wole-joko/blob/dev/src/js/utils.js#L57-L92), a live coding task I was asked to do in an engineering manager interview. It was a simulation of people entering an event hall to get seated, but only two could get it/be attended to at a time. I later took some time to [bring the project to live](https://wole-joko.netlify.app/) -> The below example was adapted for more concise terminal output +#### Wole Joko -
+I first tried my hands on this concept when [building wole-joko](https://github.com/chalu/wole-joko/blob/dev/src/js/utils.js#L57-L92), a _live coding task_ I was asked to do in an engineering manager interview :man_shrugging. It was a simulation of people entering an event hall to get seated, but only two could get in at a time. I later took some time to [give the project more life](https://wole-joko.netlify.app/) -JS challenge by @thdxr on X.com
+#### Execute max of X tasks in parallel + +JS challenge by [@thdxr on X.com](https://twitter.com/thdxr)
![](./assets/the-dax-js-challenge.png "JS challenge by @thdxr")

-`n-tuple-array` solution code
-[](https://github.com/chalu/n-tuple-array/blob/main/src/demo/demo-classic.ts#L6-L40) +> The below was adapted for more concise terminal output + +`n-tuple-array` solution. View [code here](https://github.com/chalu/n-tuple-array/blob/main/src/demo/demo-classic.ts#L6-L40)
+![](./assets/demo-classic.png "n-tuple-array solution")

-`n-tuple-array` n-tuple-array solution demo
+`n-tuple-array` solution demo
![](./assets/ntuple-array-demo-optimized.gif "n-tuple-array solution demo") From 33b91833eaf0a5198b3ad1ad8f1d97d967ba3955 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Sun, 18 Feb 2024 14:02:01 -0700 Subject: [PATCH 22/33] set first public release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c30e1b0..882e94a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.1.4", + "version": "0.1.5", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "types": "./dist/cjs/types/index.d.ts", From dba7f3ec2c763222bcee20ec161edae8d1b1ae25 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Wed, 28 Feb 2024 11:12:25 -0700 Subject: [PATCH 23/33] remove files filter from lint script --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 882e94a..26aa3c1 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "prebuild": "rm -rf dist", "build:esm": "tsc -p tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs", "build:cjs": "tsc -p tsconfig.cjs.json", - "lint": "xo $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", - "lint:fix": "xo --fix $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", + "lint": "xo", + "lint:fix": "xo --fix", "test": "jest", "pretest": "pnpm lint && pnpm build", "test:ci": "jest --ci --config='./jest.config.ci.ts'", From 95e196ee5314b16d8a561f523d60ee28a62d7f2b Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Wed, 28 Feb 2024 11:14:24 -0700 Subject: [PATCH 24/33] simplify types used --- src/index.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6adea2f..3bebe49 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,4 @@ -type Item = T | undefined; -type Value = Array>; -type Result = IteratorResult, Value>; +type Result = IteratorResult, Array>; export type Matcher = (item: T | unknown) => boolean; export type TupleConfig = { @@ -38,7 +36,7 @@ export const tuplesFromArray = (config: TupleConfig) => { const maxItemSize = Number.parseInt(`${maxItems}`, 10); const proceedNext = (): Result => { - const items: Value = []; + const items: Array = []; if (cursor >= list.length) { return {done: true, value: []}; @@ -72,11 +70,11 @@ export const tuplesFromArray = (config: TupleConfig) => { return {value: items, done: items.length === 0}; }; - const iterable: Iterable> = { - [Symbol.iterator](): Iterator> { - return { - next: proceedNext, - }; + const iterable: IterableIterator> = { + next: proceedNext, + + [Symbol.iterator](): IterableIterator> { + return this; }, }; From 6f6a4ade1e6d12b969756d9a77d8be1fb4c6260a Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 11:06:59 -0700 Subject: [PATCH 25/33] refine lint script for pre-commit hook --- .husky/pre-commit | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 009b3f8..859bd52 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -pnpm lint +pnpm lint:MA diff --git a/package.json b/package.json index 26aa3c1..c46e2fb 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build:esm": "tsc -p tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs", "build:cjs": "tsc -p tsconfig.cjs.json", "lint": "xo", - "lint:fix": "xo --fix", + "lint:MA": "xo $(git diff --name-only --diff-filter=MA HEAD | grep -E 'src/.+\\.(ts|js)$' | xargs)", "test": "jest", "pretest": "pnpm lint && pnpm build", "test:ci": "jest --ci --config='./jest.config.ci.ts'", From b41eb1416ce1f44043586326777fe90e3c6e1ae4 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 13:42:14 -0700 Subject: [PATCH 26/33] fix cjs and esm modules --- README.md | 43 ++++++++++--------- fix-pkgs | 11 +++++ package.json | 3 +- src/examples/js/basic.js | 25 +++++++++++ src/examples/js/basic.mjs | 23 ++++++++++ .../demo-basics.ts => examples/ts/basic.ts} | 4 +- .../ts/classic.ts} | 4 +- .../demo-utils.ts => examples/ts/utils.ts} | 0 tsconfig.base.json | 26 ++++++++--- tsconfig.cjs.json | 5 --- tsconfig.esm.json | 9 +--- 11 files changed, 110 insertions(+), 43 deletions(-) create mode 100755 fix-pkgs create mode 100644 src/examples/js/basic.js create mode 100644 src/examples/js/basic.mjs rename src/{demo/demo-basics.ts => examples/ts/basic.ts} (95%) rename src/{demo/demo-classic.ts => examples/ts/classic.ts} (94%) rename src/{demo/demo-utils.ts => examples/ts/utils.ts} (100%) diff --git a/README.md b/README.md index f385ae2..926aeb9 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,60 @@ # n-tuple-array -Get a specified amount of items when iterating over a JavaScript array, instead of the single item that arrays provide per iteration, by default. +Get a **`configurable`** amount of items when iterating over a JavaScript array, instead of a single item that arrays provide per iteration, by default. ## Motivation -Imagine that you received a collection of coordinates (latitude and longitude), but they were sent -as a flat array of values to speed up the data transfers. +Imagine that you received a large collection of coordinates (latitude and longitude), but they were sent +as a flat array of values to speed up the data transfer. -`n-tuple-array` can help you get out the coordinates in pairs (their logical representation), such that you'd go **from** +`n-tuple-array` can help you get out the coordinates in pairs (i.e their logical representation), such that you'd go + +**from** ```json -// flatCoords +// flat coordinates ["5.7225", "-9.6273", "2.68452", "-30.9501", ...] ``` **to** ```javascript -// generate pairs by default -const coordIterable = tuplesFromArray({ list: flatCoords }); +// the iterable will generate pairs by default +const coordsIterable = tuplesFromArray({ list: flatCoords }); // using for..of, get pairs as ["5.7225", "-9.6273"] ... -for (const pair of coordIterable) { +for (const pair of coordsIterable) { console.log(pair); } -// OR manipulate pairs with regular array functions -const coordPairs = Array.from(coordIterable); -console.log(Array.isArray(coordPairs)); // true -// prints ["5.7225", "-9.6273"] ... -coordPairs +// OR manipulate pairs with regular array +// functions like map, filter, forEach ... +const coordsInPairs = Array.from(coordsIterable); +console.log(Array.isArray(coordsInPairs)); // true +coordsInPairs .map(pair => { + // pair is ["5.7225", "-9.6273"] ... return myTransform(pair); }) .forEach((pair) => { + // pair is ["5.7225", "-9.6273"] ... placeOnMap(pair); }); ``` ### Some Real World Examples -#### Wole Joko +#### 1. Wole Joko -I first tried my hands on this concept when [building wole-joko](https://github.com/chalu/wole-joko/blob/dev/src/js/utils.js#L57-L92), a _live coding task_ I was asked to do in an engineering manager interview :man_shrugging. It was a simulation of people entering an event hall to get seated, but only two could get in at a time. I later took some time to [give the project more life](https://wole-joko.netlify.app/) +I first tried my hands on this concept when [fleshing out wole-joko](https://github.com/chalu/wole-joko/blob/dev/src/js/utils.js#L57-L92), which strated as a _live coding task_ I was asked to do in an engineering manager interview :man_shrugging +It was a simulation of people entering an event hall to get seated, but **only two** could get in at a time - https://wole-joko.netlify.app/ -#### Execute max of X tasks in parallel +#### 2. Execute max of `N` async tasks -JS challenge by [@thdxr on X.com](https://twitter.com/thdxr)
![](./assets/the-dax-js-challenge.png "JS challenge by @thdxr") -

> The below was adapted for more concise terminal output -`n-tuple-array` solution. View [code here](https://github.com/chalu/n-tuple-array/blob/main/src/demo/demo-classic.ts#L6-L40)
+`n-tuple-array` solution. View [code here](https://github.com/chalu/n-tuple-array/blob/main/src/examples/classic.ts#L6-L40)
![](./assets/demo-classic.png "n-tuple-array solution")

@@ -92,5 +95,5 @@ for (const quintet of quintetIterator) { } ``` -See more examples in [src/demo](./src/demo/) +See more examples in [src/examples](./src/examples/) diff --git a/fix-pkgs b/fix-pkgs new file mode 100755 index 0000000..e1f4413 --- /dev/null +++ b/fix-pkgs @@ -0,0 +1,11 @@ +cat >dist/cjs/package.json <dist/esm/package.json < i + 1); +const isEven = item => { + if ( + !item + || typeof item !== 'number' + || item % 2 !== 0 + ) { + return false; + } + + return true; +}; + +// Use the lib +const quintetIterator = tuplesFromArray({ + list: numbers, maxItems: 5, match: isEven, +}); + +for (const quintet of quintetIterator) { + // Prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] + console.log(quintet); +} diff --git a/src/examples/js/basic.mjs b/src/examples/js/basic.mjs new file mode 100644 index 0000000..6374be8 --- /dev/null +++ b/src/examples/js/basic.mjs @@ -0,0 +1,23 @@ +import tuplesFromArray from '../../../dist/esm/index.mjs'; + +// some setup +const numbers = Array.from({length: 100}, (_, i) => i + 1); +const isEven = (item) => { + if ( + !item + || typeof item !== 'number' + || item % 2 !== 0 + ) return false; + + return true; +}; + +// use the lib +const quintetIterator = tuplesFromArray({ + list: numbers, maxItems: 5, match: isEven +}); + +for (const quintet of quintetIterator) { + // prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] + console.log(quintet); +} \ No newline at end of file diff --git a/src/demo/demo-basics.ts b/src/examples/ts/basic.ts similarity index 95% rename from src/demo/demo-basics.ts rename to src/examples/ts/basic.ts index e0c13df..68fb5e9 100644 --- a/src/demo/demo-basics.ts +++ b/src/examples/ts/basic.ts @@ -1,7 +1,7 @@ -import {tuplesFromArray} from '../index'; +import {tuplesFromArray} from '../../index'; import { hexadecimals, isDate, dates, uuids, -} from './demo-utils'; +} from './utils'; console.log('----- Example 1 [10 Hex in twos. Used default param values] ------'); for (const hexPair of tuplesFromArray({list: hexadecimals(10)})) { diff --git a/src/demo/demo-classic.ts b/src/examples/ts/classic.ts similarity index 94% rename from src/demo/demo-classic.ts rename to src/examples/ts/classic.ts index e191584..922f8f2 100644 --- a/src/demo/demo-classic.ts +++ b/src/examples/ts/classic.ts @@ -1,7 +1,7 @@ -import {tuplesFromArray} from '../index'; +import {tuplesFromArray} from '../../index'; import { isDate, dates, canadaDateFormat, delay, formatCount, -} from './demo-utils'; +} from './utils'; const processItem = async (item: T | undefined) => { await delay(Math.random() * 500); // Simulate some async workload diff --git a/src/demo/demo-utils.ts b/src/examples/ts/utils.ts similarity index 100% rename from src/demo/demo-utils.ts rename to src/examples/ts/utils.ts diff --git a/tsconfig.base.json b/tsconfig.base.json index 211db10..18ddf57 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,21 +1,35 @@ { "compilerOptions": { "strict": true, - "rootDir": "./src", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, + "pretty": true, "checkJs": true, "allowJs": true, + "rootDir": "./src", + "skipLibCheck": true, "declaration": true, + "esModuleInterop": true, "declarationMap": true, + "sourceMap": true, + "inlineSourceMap": false, + "resolveJsonModule": true, + "moduleResolution": "Node", + "moduleDetection": "force", "noUncheckedIndexedAccess": true, - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "lib": [ + "ES2022", + "DOM", + "DOM.Iterable" + ] }, "include": [ "src/**/*" ], "exclude": [ - "src/demo/**" + "src/examples/**", + "node_modules", + "dist" ] } \ No newline at end of file diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 5d35037..5801811 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,13 +1,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "lib": [ - "ES2022", - "DOM" - ], "target": "ES2022", "module": "CommonJS", - "moduleResolution": "Node", "outDir": "dist/cjs", "declarationDir": "dist/cjs/types" } diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 8beeb6a..bed57b6 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,13 +1,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "lib": [ - "ES2022", - "DOM" - ], - "target": "ES2022", - "module": "NodeNext", - "moduleResolution": "NodeNext", + "target": "ESNext", + "module": "ESNext", "outDir": "dist/esm", "declarationDir": "dist/esm/types" } From ba0f9006027583fd503f9923cebf2b38688d6b2a Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 13:47:11 -0700 Subject: [PATCH 27/33] add updated build --- dist/cjs/index.js | 6 +++--- dist/cjs/index.js.map | 1 + dist/cjs/package.json | 3 +++ dist/cjs/types/index.d.ts | 4 +--- dist/cjs/types/index.d.ts.map | 2 +- dist/esm/index.js.map | 1 + dist/esm/index.mjs | 17 ++++++----------- dist/esm/package.json | 3 +++ dist/esm/types/index.d.ts | 4 +--- dist/esm/types/index.d.ts.map | 2 +- 10 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 dist/cjs/index.js.map create mode 100644 dist/cjs/package.json create mode 100644 dist/esm/index.js.map create mode 100644 dist/esm/package.json diff --git a/dist/cjs/index.js b/dist/cjs/index.js index 927cbf0..0f9c2e9 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -50,13 +50,13 @@ const tuplesFromArray = (config) => { return { value: items, done: items.length === 0 }; }; const iterable = { + next: proceedNext, [Symbol.iterator]() { - return { - next: proceedNext, - }; + return this; }, }; return iterable; }; exports.tuplesFromArray = tuplesFromArray; exports.default = exports.tuplesFromArray; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/cjs/index.js.map b/dist/cjs/index.js.map new file mode 100644 index 0000000..201cde8 --- /dev/null +++ b/dist/cjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AASA,MAAa,+BAAgC,SAAQ,KAAK;CAAG;AAA7D,0EAA6D;AAE7D,MAAM,yBAAyB,GAAG,CAAI,IAAS,EAAE,QAAgB,EAAE,KAA6B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AAM,GAAG,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;YAE7C,4DAA4D;YAC5D,4DAA4D;YAC5D,uBAAuB;YACvB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAEf,OAAO,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,CAAC;YAEZ,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEjB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;QACF,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAA2C;QACxD,IAAI,EAAE,WAAW;QAEjB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAnDW,QAAA,eAAe,mBAmD1B;AAEF,kBAAe,uBAAe,CAAC"} \ No newline at end of file diff --git a/dist/cjs/package.json b/dist/cjs/package.json new file mode 100644 index 0000000..1cd945a --- /dev/null +++ b/dist/cjs/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/dist/cjs/types/index.d.ts b/dist/cjs/types/index.d.ts index cb5aa72..05345e4 100644 --- a/dist/cjs/types/index.d.ts +++ b/dist/cjs/types/index.d.ts @@ -1,5 +1,3 @@ -type Item = T | undefined; -type Value = Array>; export type Matcher = (item: T | unknown) => boolean; export type TupleConfig = { list: T[]; @@ -8,6 +6,6 @@ export type TupleConfig = { }; export declare class InvalidInvocationParameterError extends Error { } -export declare const tuplesFromArray: (config: TupleConfig) => Iterable>; +export declare const tuplesFromArray: (config: TupleConfig) => IterableIterator<(T | undefined)[]>; export default tuplesFromArray; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/cjs/types/index.d.ts.map b/dist/cjs/types/index.d.ts.map index 8d87987..d9ec426 100644 --- a/dist/cjs/types/index.d.ts.map +++ b/dist/cjs/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAC7B,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAG/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,mDAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/esm/index.js.map b/dist/esm/index.js.map new file mode 100644 index 0000000..6ca0fe6 --- /dev/null +++ b/dist/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,+BAAgC,SAAQ,KAAK;CAAG;AAE7D,MAAM,yBAAyB,GAAG,CAAI,IAAS,EAAE,QAAgB,EAAE,KAA6B,EAAE,EAAE;IACnG,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,+BAA+B,CAAC,8BAA8B,CAAC,CAAC;IAC3E,CAAC;IAED,IACC,OAAO,QAAQ,KAAK,QAAQ;WACnB,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,CAAC,CAAC,EACvD,CAAC;QACF,MAAM,OAAO,GAAG,0EAA0E,CAAC;QAC3F,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,iDAAiD,CAAC;QAClE,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,MAAsB,EAAE,EAAE;IAC5D,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAC,GAAG,MAAM,CAAC;IAC3C,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEjD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,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AC"} \ No newline at end of file diff --git a/dist/esm/index.mjs b/dist/esm/index.mjs index 927cbf0..08c7f8e 100644 --- a/dist/esm/index.mjs +++ b/dist/esm/index.mjs @@ -1,9 +1,5 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.tuplesFromArray = exports.InvalidInvocationParameterError = void 0; -class InvalidInvocationParameterError extends Error { +export class InvalidInvocationParameterError extends Error { } -exports.InvalidInvocationParameterError = InvalidInvocationParameterError; const validateParametersOrThrow = (list, maxItems, match) => { if (!list || !Array.isArray(list)) { throw new InvalidInvocationParameterError('expected list to be an array'); @@ -18,7 +14,7 @@ const validateParametersOrThrow = (list, maxItems, match) => { throw new InvalidInvocationParameterError(message); } }; -const tuplesFromArray = (config) => { +export const tuplesFromArray = (config) => { const { list, match, maxItems = 2 } = config; validateParametersOrThrow(list, maxItems, match); let cursor = 0; @@ -50,13 +46,12 @@ const tuplesFromArray = (config) => { return { value: items, done: items.length === 0 }; }; const iterable = { + next: proceedNext, [Symbol.iterator]() { - return { - next: proceedNext, - }; + return this; }, }; return iterable; }; -exports.tuplesFromArray = tuplesFromArray; -exports.default = exports.tuplesFromArray; +export default tuplesFromArray; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/esm/package.json b/dist/esm/package.json new file mode 100644 index 0000000..4720025 --- /dev/null +++ b/dist/esm/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/dist/esm/types/index.d.ts b/dist/esm/types/index.d.ts index cb5aa72..05345e4 100644 --- a/dist/esm/types/index.d.ts +++ b/dist/esm/types/index.d.ts @@ -1,5 +1,3 @@ -type Item = T | undefined; -type Value = Array>; export type Matcher = (item: T | unknown) => boolean; export type TupleConfig = { list: T[]; @@ -8,6 +6,6 @@ export type TupleConfig = { }; export declare class InvalidInvocationParameterError extends Error { } -export declare const tuplesFromArray: (config: TupleConfig) => Iterable>; +export declare const tuplesFromArray: (config: TupleConfig) => IterableIterator<(T | undefined)[]>; export default tuplesFromArray; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/esm/types/index.d.ts.map b/dist/esm/types/index.d.ts.map index 8d87987..d9ec426 100644 --- a/dist/esm/types/index.d.ts.map +++ b/dist/esm/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAC7B,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAG/B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,mDAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file From 994f562735fd8da8924ca2692cdd67f8a002ed1d Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 13:49:51 -0700 Subject: [PATCH 28/33] fix lint errors in esm example code --- src/examples/js/basic.mjs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/examples/js/basic.mjs b/src/examples/js/basic.mjs index 6374be8..72d27df 100644 --- a/src/examples/js/basic.mjs +++ b/src/examples/js/basic.mjs @@ -1,23 +1,25 @@ import tuplesFromArray from '../../../dist/esm/index.mjs'; -// some setup +// Some setup const numbers = Array.from({length: 100}, (_, i) => i + 1); -const isEven = (item) => { - if ( - !item +const isEven = item => { + if ( + !item || typeof item !== 'number' || item % 2 !== 0 - ) return false; + ) { + return false; + } - return true; + return true; }; -// use the lib +// Use the lib const quintetIterator = tuplesFromArray({ - list: numbers, maxItems: 5, match: isEven + list: numbers, maxItems: 5, match: isEven, }); for (const quintet of quintetIterator) { - // prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] + // Prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] console.log(quintet); -} \ No newline at end of file +} From 854d60467b6f8d7483ee360f70ea48aedc0539ec Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 20:07:27 -0700 Subject: [PATCH 29/33] add more JS examples --- .xo-config.json | 1 + src/examples/js/concurrent.js | 39 +++++++++++++++++++++++++ src/examples/js/with-lib.mjs | 43 ++++++++++++++++++++++++++++ src/examples/js/without-lib.js | 52 ++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 src/examples/js/concurrent.js create mode 100644 src/examples/js/with-lib.mjs create mode 100644 src/examples/js/without-lib.js diff --git a/.xo-config.json b/.xo-config.json index 1a87094..bfe3926 100644 --- a/.xo-config.json +++ b/.xo-config.json @@ -1,6 +1,7 @@ { "env": ["jest", "node"], "rules": { + "no-await-in-loop": "off", "import/extensions": "off", "unicorn/prefer-module": "off", "unicorn/no-array-for-each": "off", diff --git a/src/examples/js/concurrent.js b/src/examples/js/concurrent.js new file mode 100644 index 0000000..0ad348e --- /dev/null +++ b/src/examples/js/concurrent.js @@ -0,0 +1,39 @@ +const indexToDate = (index = 0) => batchId => new Promise(resolve => { + console.log(`[Batch ${batchId}] task ${index + 1} starting`); + const delay = Math.random() * 3000; + const dt = new Date(`2024-07-${(index + 1) % 30}`); + setTimeout(() => { + console.log(`[Batch ${batchId}] task ${index + 1} completed in ${delay.toFixed(2)} ms`); + resolve(dt); + }, delay); +}); + +const processTask = async (todo, batchId) => { + const out = await todo(batchId); + return out; +}; + +const executeConcurrent = async (todos, maxBatchSize) => { + const done = []; + const todosCopy = todos.slice(); + const worker = async (_, batchIndex) => { + let todo = todosCopy.shift(); + while (todo) { + const [result] = await Promise.allSettled([processTask(todo, batchIndex + 1)]); + done.push(result); + todo = todosCopy.shift(); + } + }; + + const batchStarters = Array.from({length: maxBatchSize}, worker); + await Promise.all(batchStarters); + return done; +}; + +(async () => { + const tasks = Array.from({length: 5}, (_, i) => indexToDate(i)); + const maxTasksPerTime = 2; + + const allDone = await executeConcurrent(tasks, maxTasksPerTime); + console.log(allDone); +})(); diff --git a/src/examples/js/with-lib.mjs b/src/examples/js/with-lib.mjs new file mode 100644 index 0000000..02a5c6f --- /dev/null +++ b/src/examples/js/with-lib.mjs @@ -0,0 +1,43 @@ +import tuplesFromArray from '../../../dist/esm/index.mjs'; + +const indexToDate = (index = 0) => batchId => new Promise(resolve => { + console.log(`[Batch ${batchId}] task ${index + 1} starting`); + const delay = Math.random() * 3000; + const dt = new Date(`2024-07-${(index + 1) % 30}`); + setTimeout(() => { + console.log(`[Batch ${batchId}] task ${index + 1} completed in ${delay.toFixed(2)} ms`); + resolve(dt); + }, delay); +}); + +const processTask = async (todo, batchId) => { + const out = await todo(batchId); + return out; +}; + +const executeWitLibrary = async (todos, maxBatchSize) => { + console.log(`do <= ${maxBatchSize} of ${todos.length} tasks, at any given time`); + const done = []; + + let batchIndex = 1; + const todosBatchIterable = tuplesFromArray({list: todos, maxItems: maxBatchSize}); + for (const batch of todosBatchIterable) { + console.log(`----- starting batch [${batchIndex}], ${batch.length} todos`); + const results = await Promise.allSettled( + batch.map(todo => processTask(todo, batchIndex)), + ); + done.push(...results); + + batchIndex += 1; + } + + return done; +}; + +(async () => { + const tasks = Array.from({length: 5}, (_, i) => indexToDate(i)); + const maxTasksPerTime = 2; + + const allDone = await executeWitLibrary(tasks, maxTasksPerTime); + console.log(allDone); +})(); diff --git a/src/examples/js/without-lib.js b/src/examples/js/without-lib.js new file mode 100644 index 0000000..e9803b7 --- /dev/null +++ b/src/examples/js/without-lib.js @@ -0,0 +1,52 @@ +const indexToDate = (index = 0) => batchId => new Promise(resolve => { + console.log(`[Batch ${batchId}] task ${index + 1} starting`); + const delay = Math.random() * 3000; + const dt = new Date(`2024-07-${(index + 1) % 30}`); + setTimeout(() => { + console.log(`[Batch ${batchId}] task ${index + 1} completed in ${delay.toFixed(2)} ms`); + resolve(dt); + }, delay); +}); + +const processTask = async (todo, batchId) => { + const out = await todo(batchId); + return out; +}; + +// Everywhere start/end is used is repititive and error prone +const executeWithoutLibrary = async (todos, maxBatchSize) => { + console.log(`do <= ${maxBatchSize} of ${todos.length} tasks, at any given time`); + const done = []; + + let start = 0; + let end = start + maxBatchSize; + let batchIndex = 1; + let batch = todos.slice(start, end); + while (batch.length > 0) { + console.log(`----- starting batch [${batchIndex}], ${batch.length} todos`); + const results = await Promise.allSettled( + batch.map(todo => processTask(todo, batchIndex)), + ); + done.push(...results); + + start = end; + if (start >= todos.length) { + break; + } + + end = Math.min(start + maxBatchSize, todos.length); + batch = todos.slice(start, end); + + batchIndex += 1; + } + + return done; +}; + +(async () => { + const tasks = Array.from({length: 5}, (_, i) => indexToDate(i)); + const maxTasksPerTime = 2; + + const allDone = await executeWithoutLibrary(tasks, maxTasksPerTime); + console.log(allDone); +})(); From b0f35e3fac1587589b41b4125be1e123f23ec9c7 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 21:41:34 -0700 Subject: [PATCH 30/33] document what is exported --- dist/cjs/index.js | 32 +++++++++++++++++++++ dist/cjs/index.js.map | 2 +- dist/cjs/types/index.d.ts | 51 ++++++++++++++++++++++++++++++++-- dist/cjs/types/index.d.ts.map | 2 +- dist/esm/index.js.map | 2 +- dist/esm/index.mjs | 32 +++++++++++++++++++++ dist/esm/types/index.d.ts | 51 ++++++++++++++++++++++++++++++++-- dist/esm/types/index.d.ts.map | 2 +- src/index.ts | 52 ++++++++++++++++++++++++++++++++++- 9 files changed, 217 insertions(+), 9 deletions(-) diff --git a/dist/cjs/index.js b/dist/cjs/index.js index 0f9c2e9..f442bee 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -1,6 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tuplesFromArray = exports.InvalidInvocationParameterError = void 0; +; +/** + * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + */ class InvalidInvocationParameterError extends Error { } exports.InvalidInvocationParameterError = InvalidInvocationParameterError; @@ -18,6 +23,33 @@ const validateParametersOrThrow = (list, maxItems, match) => { throw new InvalidInvocationParameterError(message); } }; +/** + * Returns an iterable iterator that ouputs a configured + * list of items when iterating over a given array + * + * @typeParam T - Type of items the input list contains + * + * @param config - An object to indicate the input array `config.list`, and set the + * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` + * as a function that should return true to filter in items from the input array + * (or false to filter them out) when deciding what items is to be included per iteration + * + * @function + * @throws InvalidInvocationParameterError + * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + * + * @returns an IterableIterator + * + * @example + * Here is an example that will get max of 3 items from + * each iteration on the returned iterable + * ```javascript + * const iterable = tuplesFromArray({ + * list:[], maxSize: 3, match: (itm) => !!itm + * }); + * ``` + */ const tuplesFromArray = (config) => { const { list, match, maxItems = 2 } = config; validateParametersOrThrow(list, maxItems, match); diff --git a/dist/cjs/index.js.map b/dist/cjs/index.js.map index 201cde8..7e53e9e 100644 --- a/dist/cjs/index.js.map +++ b/dist/cjs/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AASA,MAAa,+BAAgC,SAAQ,KAAK;CAAG;AAA7D,0EAA6D;AAE7D,MAAM,yBAAyB,GAAG,CAAI,IAAS,EAAE,QAAgB,EAAE,KAA6B,EAAE,EAAE;IACnG,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,+BAA+B,CAAC,8BAA8B,CAAC,CAAC;IAC3E,CAAC;IAED,IACC,OAAO,QAAQ,KAAK,QAAQ;WACnB,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,CAAC,CAAC,EACvD,CAAC;QACF,MAAM,OAAO,GAAG,0EAA0E,CAAC;QAC3F,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,iDAAiD,CAAC;QAClE,MAAM,IAAI,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;AACF,CAAC,CAAC;AAEK,MAAM,eAAe,GAAG,CAAI,MAAsB,EAAE,EAAE;IAC5D,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAC,GAAG,MAAM,CAAC;IAC3C,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEjD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAEvD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AE,CAAC;YAC3B,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC;QAChC,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS;YACnC,yDAAyD;YACzD,8CAA8C;YAC9C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;YAE7C,4DAA4D;YAC5D,4DAA4D;YAC5D,uBAAuB;YACvB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAEf,OAAO,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,CAAC;YAEZ,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEjB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;QACF,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAA2C;QACxD,IAAI,EAAE,WAAW;QAEjB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAnDW,QAAA,eAAe,mBAmD1B;AAEF,kBAAe,uBAAe,CAAC"} \ No newline at end of file diff --git a/dist/cjs/types/index.d.ts b/dist/cjs/types/index.d.ts index 05345e4..a2ca17f 100644 --- a/dist/cjs/types/index.d.ts +++ b/dist/cjs/types/index.d.ts @@ -1,11 +1,58 @@ export type Matcher = (item: T | unknown) => boolean; -export type TupleConfig = { +/** + * The invocation argument type + * + * @typeParam T - Type of items the input list contains + */ +export interface TupleConfig { + /** + * The input array to use + */ list: T[]; + /** + * The max number of items to return from the input array, per iteration + * @defaultValue 2 + */ maxItems?: number; + /** + * When provided, a function used to determine which items in the input array + * are eligible to be included, per iteration + */ match?: Matcher; -}; +} +/** + * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + */ export declare class InvalidInvocationParameterError extends Error { } +/** + * Returns an iterable iterator that ouputs a configured + * list of items when iterating over a given array + * + * @typeParam T - Type of items the input list contains + * + * @param config - An object to indicate the input array `config.list`, and set the + * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` + * as a function that should return true to filter in items from the input array + * (or false to filter them out) when deciding what items is to be included per iteration + * + * @function + * @throws InvalidInvocationParameterError + * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + * + * @returns an IterableIterator + * + * @example + * Here is an example that will get max of 3 items from + * each iteration on the returned iterable + * ```javascript + * const iterable = tuplesFromArray({ + * list:[], maxSize: 3, match: (itm) => !!itm + * }); + * ``` + */ export declare const tuplesFromArray: (config: TupleConfig) => IterableIterator<(T | undefined)[]>; export default tuplesFromArray; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/cjs/types/index.d.ts.map b/dist/cjs/types/index.d.ts.map index d9ec426..14ead46 100644 --- a/dist/cjs/types/index.d.ts.map +++ b/dist/cjs/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/esm/index.js.map b/dist/esm/index.js.map index 6ca0fe6..a32d11c 100644 --- a/dist/esm/index.js.map +++ b/dist/esm/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,+BAAgC,SAAQ,KAAK;CAAG;AAE7D,MAAM,yBAAyB,GAAG,CAAI,IAAS,EAAE,QAAgB,EAAE,KAA6B,EAAE,EAAE;IACnG,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,+BAA+B,CAAC,8BAA8B,CAAC,CAAC;IAC3E,CAAC;IAED,IACC,OAAO,QAAQ,KAAK,QAAQ;WACnB,CAAC,OAAO,QAAQ,KAAK,QAAQ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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEjB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;QACF,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAA2C;QACxD,IAAI,EAAE,WAAW;QAEjB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/esm/index.mjs b/dist/esm/index.mjs index 08c7f8e..91c1b69 100644 --- a/dist/esm/index.mjs +++ b/dist/esm/index.mjs @@ -1,3 +1,8 @@ +; +/** + * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + */ export class InvalidInvocationParameterError extends Error { } const validateParametersOrThrow = (list, maxItems, match) => { @@ -14,6 +19,33 @@ const validateParametersOrThrow = (list, maxItems, match) => { throw new InvalidInvocationParameterError(message); } }; +/** + * Returns an iterable iterator that ouputs a configured + * list of items when iterating over a given array + * + * @typeParam T - Type of items the input list contains + * + * @param config - An object to indicate the input array `config.list`, and set the + * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` + * as a function that should return true to filter in items from the input array + * (or false to filter them out) when deciding what items is to be included per iteration + * + * @function + * @throws InvalidInvocationParameterError + * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + * + * @returns an IterableIterator + * + * @example + * Here is an example that will get max of 3 items from + * each iteration on the returned iterable + * ```javascript + * const iterable = tuplesFromArray({ + * list:[], maxSize: 3, match: (itm) => !!itm + * }); + * ``` + */ export const tuplesFromArray = (config) => { const { list, match, maxItems = 2 } = config; validateParametersOrThrow(list, maxItems, match); diff --git a/dist/esm/types/index.d.ts b/dist/esm/types/index.d.ts index 05345e4..a2ca17f 100644 --- a/dist/esm/types/index.d.ts +++ b/dist/esm/types/index.d.ts @@ -1,11 +1,58 @@ export type Matcher = (item: T | unknown) => boolean; -export type TupleConfig = { +/** + * The invocation argument type + * + * @typeParam T - Type of items the input list contains + */ +export interface TupleConfig { + /** + * The input array to use + */ list: T[]; + /** + * The max number of items to return from the input array, per iteration + * @defaultValue 2 + */ maxItems?: number; + /** + * When provided, a function used to determine which items in the input array + * are eligible to be included, per iteration + */ match?: Matcher; -}; +} +/** + * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + */ export declare class InvalidInvocationParameterError extends Error { } +/** + * Returns an iterable iterator that ouputs a configured + * list of items when iterating over a given array + * + * @typeParam T - Type of items the input list contains + * + * @param config - An object to indicate the input array `config.list`, and set the + * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` + * as a function that should return true to filter in items from the input array + * (or false to filter them out) when deciding what items is to be included per iteration + * + * @function + * @throws InvalidInvocationParameterError + * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + * + * @returns an IterableIterator + * + * @example + * Here is an example that will get max of 3 items from + * each iteration on the returned iterable + * ```javascript + * const iterable = tuplesFromArray({ + * list:[], maxSize: 3, match: (itm) => !!itm + * }); + * ``` + */ export declare const tuplesFromArray: (config: TupleConfig) => IterableIterator<(T | undefined)[]>; export default tuplesFromArray; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/esm/types/index.d.ts.map b/dist/esm/types/index.d.ts.map index d9ec426..14ead46 100644 --- a/dist/esm/types/index.d.ts.map +++ b/dist/esm/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 3bebe49..aff3840 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,35 @@ type Result = IteratorResult, Array>; export type Matcher = (item: T | unknown) => boolean; -export type TupleConfig = { + +/** + * The invocation argument type + * + * @typeParam T - Type of items the input list contains + */ +export interface TupleConfig { + /** + * The input array to use + */ list: T[]; + + /** + * The max number of items to return from the input array, per iteration + * @defaultValue 2 + */ maxItems?: number; + + /** + * When provided, a function used to determine which items in the input array + * are eligible to be included, per iteration + */ match?: Matcher; }; +/** + * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + */ export class InvalidInvocationParameterError extends Error {} const validateParametersOrThrow = (list: T[], maxItems: number, match: Matcher | undefined) => { @@ -28,6 +51,33 @@ const validateParametersOrThrow = (list: T[], maxItems: number, match: Matche } }; +/** + * Returns an iterable iterator that ouputs a configured + * list of items when iterating over a given array + * + * @typeParam T - Type of items the input list contains + * + * @param config - An object to indicate the input array `config.list`, and set the + * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` + * as a function that should return true to filter in items from the input array + * (or false to filter them out) when deciding what items is to be included per iteration + * + * @function + * @throws InvalidInvocationParameterError + * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not + * a number, or `match` is not a function + * + * @returns an IterableIterator + * + * @example + * Here is an example that will get max of 3 items from + * each iteration on the returned iterable + * ```javascript + * const iterable = tuplesFromArray({ + * list:[], maxSize: 3, match: (itm) => !!itm + * }); + * ``` + */ export const tuplesFromArray = (config: TupleConfig) => { const {list, match, maxItems = 2} = config; validateParametersOrThrow(list, maxItems, match); From d076ec381ee0129d2b8f331031dc32d383562234 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 21:42:06 -0700 Subject: [PATCH 31/33] document what is exported --- src/index.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index aff3840..ea90e85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,12 +2,7 @@ type Result = IteratorResult, Array>; export type Matcher = (item: T | unknown) => boolean; -/** - * The invocation argument type - * - * @typeParam T - Type of items the input list contains - */ -export interface TupleConfig { +export type TupleConfig = { /** * The input array to use */ @@ -52,25 +47,25 @@ const validateParametersOrThrow = (list: T[], maxItems: number, match: Matche }; /** - * Returns an iterable iterator that ouputs a configured + * Returns an iterable iterator that ouputs a configured * list of items when iterating over a given array - * + * * @typeParam T - Type of items the input list contains - * + * * @param config - An object to indicate the input array `config.list`, and set the * max size of items per interation `config.maxItems`. You can also optionally specify `config.match` - * as a function that should return true to filter in items from the input array + * as a function that should return true to filter in items from the input array * (or false to filter them out) when deciding what items is to be included per iteration - * + * * @function * @throws InvalidInvocationParameterError * This exception is thrown if there is no input array, `maxItems` is <= 0 or is not * a number, or `match` is not a function - * + * * @returns an IterableIterator - * + * * @example - * Here is an example that will get max of 3 items from + * Here is an example that will get max of 3 items from * each iteration on the returned iterable * ```javascript * const iterable = tuplesFromArray({ From 1e8584a13a0d5d49be2ee0ff7a554494daf58668 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 21:53:18 -0700 Subject: [PATCH 32/33] update build --- dist/cjs/index.js | 1 - dist/cjs/index.js.map | 2 +- dist/cjs/types/index.d.ts | 9 ++------- dist/cjs/types/index.d.ts.map | 2 +- dist/esm/index.js.map | 2 +- dist/esm/index.mjs | 1 - dist/esm/types/index.d.ts | 9 ++------- dist/esm/types/index.d.ts.map | 2 +- 8 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dist/cjs/index.js b/dist/cjs/index.js index f442bee..8d4c23e 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tuplesFromArray = exports.InvalidInvocationParameterError = void 0; -; /** * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not * a number, or `match` is not a function diff --git a/dist/cjs/index.js.map b/dist/cjs/index.js.map index 7e53e9e..402b09c 100644 --- a/dist/cjs/index.js.map +++ b/dist/cjs/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA0BC,CAAC;AAEF;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,KAAK;CAAG;AAA7D,0EAA6D;AAE7D,MAAM,yBAAyB,GAAG,CAAI,IAAS,EAAE,QAAgB,EAAE,KAA6B,EAAE,EAAE;IACnG,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,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O,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,CAAC;YAEZ,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEjB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;QACF,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAA2C;QACxD,IAAI,EAAE,WAAW;QAEjB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAnDW,QAAA,eAAe,mBAmD1B;AAEF,kBAAe,uBAAe,CAAC"} \ No newline at end of file diff --git a/dist/cjs/types/index.d.ts b/dist/cjs/types/index.d.ts index a2ca17f..cbe5290 100644 --- a/dist/cjs/types/index.d.ts +++ b/dist/cjs/types/index.d.ts @@ -1,10 +1,5 @@ export type Matcher = (item: T | unknown) => boolean; -/** - * The invocation argument type - * - * @typeParam T - Type of items the input list contains - */ -export interface TupleConfig { +export type TupleConfig = { /** * The input array to use */ @@ -19,7 +14,7 @@ export interface TupleConfig { * are eligible to be included, per iteration */ match?: Matcher; -} +}; /** * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not * a number, or `match` is not a function diff --git a/dist/cjs/types/index.d.ts.map b/dist/cjs/types/index.d.ts.map index 14ead46..cb8e02a 100644 --- a/dist/cjs/types/index.d.ts.map +++ b/dist/cjs/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/esm/index.js.map b/dist/esm/index.js.map index a32d11c..c284d3b 100644 --- a/dist/esm/index.js.map +++ b/dist/esm/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":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DAAyD;YACzD,8CAA8C;YAC9C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;YAE7C,4DAA4D;YAC5D,4DAA4D;YAC5D,uBAAuB;YACvB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAEf,OAAO,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,CAAC;YAEZ,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEjB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;QACF,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAA2C;QACxD,IAAI,EAAE,WAAW;QAEjB,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file diff --git a/dist/esm/index.mjs b/dist/esm/index.mjs index 91c1b69..5bd2ab4 100644 --- a/dist/esm/index.mjs +++ b/dist/esm/index.mjs @@ -1,4 +1,3 @@ -; /** * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not * a number, or `match` is not a function diff --git a/dist/esm/types/index.d.ts b/dist/esm/types/index.d.ts index a2ca17f..cbe5290 100644 --- a/dist/esm/types/index.d.ts +++ b/dist/esm/types/index.d.ts @@ -1,10 +1,5 @@ export type Matcher = (item: T | unknown) => boolean; -/** - * The invocation argument type - * - * @typeParam T - Type of items the input list contains - */ -export interface TupleConfig { +export type TupleConfig = { /** * The input array to use */ @@ -19,7 +14,7 @@ export interface TupleConfig { * are eligible to be included, per iteration */ match?: Matcher; -} +}; /** * An exception than can be thrown if there is no input array, `maxItems` is <= 0 or is not * a number, or `match` is not a function diff --git a/dist/esm/types/index.d.ts.map b/dist/esm/types/index.d.ts.map index 14ead46..cb8e02a 100644 --- a/dist/esm/types/index.d.ts.map +++ b/dist/esm/types/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;AAExD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;CAAG;AAqB7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,oEAmD3B,CAAC;AAEF,eAAe,eAAe,CAAC"} \ No newline at end of file From 6f347fb96819576b858e0cda3429c8550576d324 Mon Sep 17 00:00:00 2001 From: Charles Opute Odili Date: Tue, 5 Mar 2024 21:59:02 -0700 Subject: [PATCH 33/33] bump patch version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 246dd6f..bebbbcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chalu/n-tuple-array", - "version": "0.1.5", + "version": "0.1.6", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that arrays provide!", "main": "./dist/cjs/index.js", "module": "dist/esm/index.mjs",