From d2908f888331d0093cf0a0a159c3c667ad755dc6 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 08:06:01 +0100 Subject: [PATCH 1/8] feat!: convert to typescript Converts all modules to typescript. BREAKING CHANGE: all modules are now published as ESM-only --- package.json | 4 +- packages/blob-to-it/.npmignore | 8 ---- packages/blob-to-it/package.json | 37 ++++++++++--------- .../blob-to-it/{index.js => src/index.ts} | 2 +- .../{test.js => test/index.spec.ts} | 2 +- packages/blob-to-it/tsconfig.json | 10 +++-- .../browser-readablestream-to-it/.npmignore | 8 ---- .../browser-readablestream-to-it/package.json | 17 +++++---- .../{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 2 +- .../tsconfig.json | 10 +++-- packages/it-all/.npmignore | 8 ---- packages/it-all/package.json | 14 ++++--- packages/it-all/{index.js => src/index.ts} | 0 .../it-all/{test.js => test/index.spec.ts} | 0 packages/it-all/tsconfig.json | 10 +++-- packages/it-batch/.npmignore | 8 ---- packages/it-batch/package.json | 16 ++++---- packages/it-batch/{index.js => src/index.ts} | 0 .../it-batch/{test.js => test/index.spec.ts} | 2 +- packages/it-batch/tsconfig.json | 10 +++-- packages/it-buffer-stream/.npmignore | 8 ---- packages/it-buffer-stream/package.json | 16 ++++---- .../{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-buffer-stream/tsconfig.json | 10 +++-- packages/it-drain/.npmignore | 8 ---- packages/it-drain/package.json | 14 ++++--- packages/it-drain/{index.js => src/index.ts} | 0 .../it-drain/{test.js => test/index.spec.ts} | 0 packages/it-drain/tsconfig.json | 10 +++-- packages/it-filter/.npmignore | 8 ---- packages/it-filter/package.json | 16 ++++---- packages/it-filter/{index.js => src/index.ts} | 0 .../it-filter/{test.js => test/index.spec.ts} | 0 packages/it-filter/tsconfig.json | 10 +++-- packages/it-first/.npmignore | 8 ---- packages/it-first/package.json | 14 ++++--- packages/it-first/{index.js => src/index.ts} | 0 .../it-first/{test.js => test/index.spec.ts} | 0 packages/it-first/tsconfig.json | 10 +++-- packages/it-flat-batch/.npmignore | 8 ---- packages/it-flat-batch/package.json | 16 ++++---- .../it-flat-batch/{index.js => src/ index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-flat-batch/tsconfig.json | 10 +++-- packages/it-foreach/.npmignore | 8 ---- packages/it-foreach/package.json | 16 ++++---- .../it-foreach/{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-foreach/tsconfig.json | 10 +++-- packages/it-glob/.npmignore | 8 ---- packages/it-glob/package.json | 16 ++++---- packages/it-glob/{index.js => src/index.ts} | 0 .../it-glob/{test.js => test/index.spec.ts} | 0 packages/it-glob/tsconfig.json | 10 +++-- packages/it-last/.npmignore | 8 ---- packages/it-last/package.json | 14 ++++--- packages/it-last/{index.js => src/index.ts} | 0 .../it-last/{test.js => test/index.spec.ts} | 0 packages/it-last/tsconfig.json | 10 +++-- packages/it-length/.npmignore | 8 ---- packages/it-length/package.json | 14 ++++--- packages/it-length/{index.js => src/index.ts} | 0 .../it-length/{test.js => test/index.spec.ts} | 2 +- packages/it-length/tsconfig.json | 10 +++-- packages/it-map/.npmignore | 8 ---- packages/it-map/package.json | 14 ++++--- packages/it-map/{index.js => src/index.ts} | 0 .../it-map/{test.js => test/index.spec.ts} | 0 packages/it-map/tsconfig.json | 10 +++-- packages/it-merge/.npmignore | 8 ---- packages/it-merge/package.json | 16 ++++---- packages/it-merge/{index.js => src/index.ts} | 0 .../it-merge/{test.js => test/index.spec.ts} | 0 packages/it-merge/tsconfig.json | 10 +++-- packages/it-multipart/.npmignore | 8 ---- packages/it-multipart/package.json | 16 ++++---- .../it-multipart/{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-multipart/tsconfig.json | 10 +++-- packages/it-ndjson/.npmignore | 8 ---- packages/it-ndjson/package.json | 16 ++++---- packages/it-ndjson/{index.js => src/index.ts} | 0 packages/it-ndjson/{parse.js => src/parse.ts} | 0 .../{stringify.js => src/stringify.ts} | 0 .../it-ndjson/{test.js => test/index.spec.ts} | 0 packages/it-ndjson/tsconfig.json | 10 +++-- packages/it-parallel-batch/.npmignore | 8 ---- packages/it-parallel-batch/package.json | 14 ++++--- .../{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 2 +- packages/it-parallel-batch/tsconfig.json | 10 +++-- packages/it-parallel/.npmignore | 8 ---- packages/it-parallel/package.json | 14 ++++--- .../it-parallel/{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 2 +- packages/it-parallel/tsconfig.json | 10 +++-- packages/it-peekable/.npmignore | 8 ---- packages/it-peekable/package.json | 16 ++++---- .../it-peekable/{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-peekable/tsconfig.json | 10 +++-- packages/it-reduce/.npmignore | 8 ---- packages/it-reduce/package.json | 14 ++++--- packages/it-reduce/{index.js => src/index.ts} | 0 .../it-reduce/{test.js => test/index.spec.ts} | 0 packages/it-reduce/tsconfig.json | 10 +++-- packages/it-skip/.npmignore | 8 ---- packages/it-skip/package.json | 16 ++++---- packages/it-skip/{index.js => src/index.ts} | 0 .../it-skip/{test.js => test/index.spec.ts} | 0 packages/it-skip/tsconfig.json | 10 +++-- packages/it-sort/.npmignore | 8 ---- packages/it-sort/package.json | 14 ++++--- packages/it-sort/{index.js => src/index.ts} | 0 .../it-sort/{test.js => test/index.spec.ts} | 0 packages/it-sort/tsconfig.json | 10 +++-- packages/it-split/.npmignore | 8 ---- packages/it-split/package.json | 16 ++++---- packages/it-split/{index.js => src/index.ts} | 0 .../it-split/{test.js => test/index.spec.ts} | 0 packages/it-split/tsconfig.json | 10 +++-- packages/it-take/.npmignore | 8 ---- packages/it-take/package.json | 16 ++++---- packages/it-take/{index.js => src/index.ts} | 0 .../it-take/{test.js => test/index.spec.ts} | 0 packages/it-take/tsconfig.json | 10 +++-- .../it-to-browser-readablestream/.npmignore | 8 ---- .../it-to-browser-readablestream/package.json | 14 ++++--- .../{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 .../tsconfig.json | 10 +++-- packages/it-to-buffer/.npmignore | 8 ---- packages/it-to-buffer/package.json | 16 ++++---- .../it-to-buffer/{index.js => src/index.ts} | 0 .../{test.js => test/index.spec.ts} | 0 packages/it-to-buffer/tsconfig.json | 10 +++-- 138 files changed, 441 insertions(+), 495 deletions(-) delete mode 100644 packages/blob-to-it/.npmignore rename packages/blob-to-it/{index.js => src/index.ts} (97%) rename packages/blob-to-it/{test.js => test/index.spec.ts} (92%) delete mode 100644 packages/browser-readablestream-to-it/.npmignore rename packages/browser-readablestream-to-it/{index.js => src/index.ts} (100%) rename packages/browser-readablestream-to-it/{test.js => test/index.spec.ts} (99%) delete mode 100644 packages/it-all/.npmignore rename packages/it-all/{index.js => src/index.ts} (100%) rename packages/it-all/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-batch/.npmignore rename packages/it-batch/{index.js => src/index.ts} (100%) rename packages/it-batch/{test.js => test/index.spec.ts} (97%) delete mode 100644 packages/it-buffer-stream/.npmignore rename packages/it-buffer-stream/{index.js => src/index.ts} (100%) rename packages/it-buffer-stream/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-drain/.npmignore rename packages/it-drain/{index.js => src/index.ts} (100%) rename packages/it-drain/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-filter/.npmignore rename packages/it-filter/{index.js => src/index.ts} (100%) rename packages/it-filter/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-first/.npmignore rename packages/it-first/{index.js => src/index.ts} (100%) rename packages/it-first/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-flat-batch/.npmignore rename packages/it-flat-batch/{index.js => src/ index.ts} (100%) rename packages/it-flat-batch/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-foreach/.npmignore rename packages/it-foreach/{index.js => src/index.ts} (100%) rename packages/it-foreach/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-glob/.npmignore rename packages/it-glob/{index.js => src/index.ts} (100%) rename packages/it-glob/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-last/.npmignore rename packages/it-last/{index.js => src/index.ts} (100%) rename packages/it-last/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-length/.npmignore rename packages/it-length/{index.js => src/index.ts} (100%) rename packages/it-length/{test.js => test/index.spec.ts} (84%) delete mode 100644 packages/it-map/.npmignore rename packages/it-map/{index.js => src/index.ts} (100%) rename packages/it-map/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-merge/.npmignore rename packages/it-merge/{index.js => src/index.ts} (100%) rename packages/it-merge/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-multipart/.npmignore rename packages/it-multipart/{index.js => src/index.ts} (100%) rename packages/it-multipart/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-ndjson/.npmignore rename packages/it-ndjson/{index.js => src/index.ts} (100%) rename packages/it-ndjson/{parse.js => src/parse.ts} (100%) rename packages/it-ndjson/{stringify.js => src/stringify.ts} (100%) rename packages/it-ndjson/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-parallel-batch/.npmignore rename packages/it-parallel-batch/{index.js => src/index.ts} (100%) rename packages/it-parallel-batch/{test.js => test/index.spec.ts} (98%) delete mode 100644 packages/it-parallel/.npmignore rename packages/it-parallel/{index.js => src/index.ts} (100%) rename packages/it-parallel/{test.js => test/index.spec.ts} (99%) delete mode 100644 packages/it-peekable/.npmignore rename packages/it-peekable/{index.js => src/index.ts} (100%) rename packages/it-peekable/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-reduce/.npmignore rename packages/it-reduce/{index.js => src/index.ts} (100%) rename packages/it-reduce/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-skip/.npmignore rename packages/it-skip/{index.js => src/index.ts} (100%) rename packages/it-skip/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-sort/.npmignore rename packages/it-sort/{index.js => src/index.ts} (100%) rename packages/it-sort/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-split/.npmignore rename packages/it-split/{index.js => src/index.ts} (100%) rename packages/it-split/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-take/.npmignore rename packages/it-take/{index.js => src/index.ts} (100%) rename packages/it-take/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-to-browser-readablestream/.npmignore rename packages/it-to-browser-readablestream/{index.js => src/index.ts} (100%) rename packages/it-to-browser-readablestream/{test.js => test/index.spec.ts} (100%) delete mode 100644 packages/it-to-buffer/.npmignore rename packages/it-to-buffer/{index.js => src/index.ts} (100%) rename packages/it-to-buffer/{test.js => test/index.spec.ts} (100%) diff --git a/package.json b/package.json index bf31d096..33e119ec 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "publish": "lerna publish" }, "devDependencies": { - "coveralls-lerna": "0.0.5", - "lerna": "^4.0.0" + "coveralls-lerna": "^0.0.5", + "lerna": "^6.0.0" } } diff --git a/packages/blob-to-it/.npmignore b/packages/blob-to-it/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/blob-to-it/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/blob-to-it/package.json b/packages/blob-to-it/package.json index db15751d..64f685d0 100644 --- a/packages/blob-to-it/package.json +++ b/packages/blob-to-it/package.json @@ -2,20 +2,22 @@ "name": "blob-to-it", "version": "1.0.4", "description": "Turns a blob into an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/blob-to-it#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "playwright-test", - "lint": "standard", - "coverage": "playwright-test", - "clean": "rm -rf dist", - "check": "npm run build:dep:types && tsc --noEmit", - "build": "npm run build:types", - "build:dep:types": "cd node_modules/browser-readablestream-to-it && npm run build:types", - "build:types": "npm run build:dep:types && tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", @@ -23,12 +25,13 @@ "browser-readablestream-to-it": "^1.0.3" }, "devDependencies": { - "chai": "^4.2.0", - "it-all": "^1.0.6", - "mocha": "8.0.1", - "playwright-test": "^0.7.1", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/blob-to-it/index.js b/packages/blob-to-it/src/index.ts similarity index 97% rename from packages/blob-to-it/index.js rename to packages/blob-to-it/src/index.ts index c3d090be..84294a8c 100644 --- a/packages/blob-to-it/index.js +++ b/packages/blob-to-it/src/index.ts @@ -2,7 +2,7 @@ 'use strict' -const browserReadableStreamToIt = require('browser-readablestream-to-it') +const browserReadableStreamToIt = require('browser-readablestream-to-it/src') /** * @param {Blob} blob diff --git a/packages/blob-to-it/test.js b/packages/blob-to-it/test/index.spec.ts similarity index 92% rename from packages/blob-to-it/test.js rename to packages/blob-to-it/test/index.spec.ts index 5b02f5b7..bdc6f2ff 100644 --- a/packages/blob-to-it/test.js +++ b/packages/blob-to-it/test/index.spec.ts @@ -2,7 +2,7 @@ 'use strict' -const all = require('it-all') +const all = require('it-all/src') const { expect } = require('chai') const toIt = require('./index') diff --git a/packages/blob-to-it/tsconfig.json b/packages/blob-to-it/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/blob-to-it/tsconfig.json +++ b/packages/blob-to-it/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/browser-readablestream-to-it/.npmignore b/packages/browser-readablestream-to-it/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/browser-readablestream-to-it/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/browser-readablestream-to-it/package.json b/packages/browser-readablestream-to-it/package.json index 2258c2de..6d289009 100644 --- a/packages/browser-readablestream-to-it/package.json +++ b/packages/browser-readablestream-to-it/package.json @@ -2,7 +2,7 @@ "name": "browser-readablestream-to-it", "version": "1.0.3", "description": "Turns a browser readble stream into an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/browser-readablestream-to-it#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,12 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "chai": "^4.2.0", - "it-all": "^1.0.6", - "mocha": "8.0.1", - "playwright-test": "^0.7.1", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/browser-readablestream-to-it/index.js b/packages/browser-readablestream-to-it/src/index.ts similarity index 100% rename from packages/browser-readablestream-to-it/index.js rename to packages/browser-readablestream-to-it/src/index.ts diff --git a/packages/browser-readablestream-to-it/test.js b/packages/browser-readablestream-to-it/test/index.spec.ts similarity index 99% rename from packages/browser-readablestream-to-it/test.js rename to packages/browser-readablestream-to-it/test/index.spec.ts index 80f34398..b920c51f 100644 --- a/packages/browser-readablestream-to-it/test.js +++ b/packages/browser-readablestream-to-it/test/index.spec.ts @@ -2,7 +2,7 @@ 'use strict' -const all = require('it-all') +const all = require('it-all/src') const { expect } = require('chai') const toIt = require('./index') diff --git a/packages/browser-readablestream-to-it/tsconfig.json b/packages/browser-readablestream-to-it/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/browser-readablestream-to-it/tsconfig.json +++ b/packages/browser-readablestream-to-it/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-all/.npmignore b/packages/it-all/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-all/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-all/package.json b/packages/it-all/package.json index a9b614ba..1998097e 100644 --- a/packages/it-all/package.json +++ b/packages/it-all/package.json @@ -2,7 +2,7 @@ "name": "it-all", "version": "1.0.6", "description": "Collects all values from an async iterator and returns them as an array", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-all#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-all/index.js b/packages/it-all/src/index.ts similarity index 100% rename from packages/it-all/index.js rename to packages/it-all/src/index.ts diff --git a/packages/it-all/test.js b/packages/it-all/test/index.spec.ts similarity index 100% rename from packages/it-all/test.js rename to packages/it-all/test/index.spec.ts diff --git a/packages/it-all/tsconfig.json b/packages/it-all/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-all/tsconfig.json +++ b/packages/it-all/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-batch/.npmignore b/packages/it-batch/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-batch/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-batch/package.json b/packages/it-batch/package.json index c146f1f7..0f7be519 100644 --- a/packages/it-batch/package.json +++ b/packages/it-batch/package.json @@ -2,7 +2,7 @@ "name": "it-batch", "version": "1.0.9", "description": "Takes an async iterator that emits things and emits them as fixed size batches", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-batch/index.js b/packages/it-batch/src/index.ts similarity index 100% rename from packages/it-batch/index.js rename to packages/it-batch/src/index.ts diff --git a/packages/it-batch/test.js b/packages/it-batch/test/index.spec.ts similarity index 97% rename from packages/it-batch/test.js rename to packages/it-batch/test/index.spec.ts index 57b694c9..469b5363 100644 --- a/packages/it-batch/test.js +++ b/packages/it-batch/test/index.spec.ts @@ -1,4 +1,4 @@ -const batch = require('./') +const batch = require('../dist') const test = require('ava') const all = require('it-all') diff --git a/packages/it-batch/tsconfig.json b/packages/it-batch/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-batch/tsconfig.json +++ b/packages/it-batch/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-buffer-stream/.npmignore b/packages/it-buffer-stream/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-buffer-stream/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-buffer-stream/package.json b/packages/it-buffer-stream/package.json index 1ed65ae0..1a18149f 100644 --- a/packages/it-buffer-stream/package.json +++ b/packages/it-buffer-stream/package.json @@ -2,7 +2,7 @@ "name": "it-buffer-stream", "version": "2.0.2", "description": "An async iterator that emits buffers containing bytes up to a certain length", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-buffer-stream#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,14 +19,16 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2", - "uint8arrays": "^3.0.0" + "aegir": "^37.5.0", + "uint8arrays": "^4.0.2" }, "dependencies": { "iso-random-stream": "^1.1.1" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-buffer-stream/index.js b/packages/it-buffer-stream/src/index.ts similarity index 100% rename from packages/it-buffer-stream/index.js rename to packages/it-buffer-stream/src/index.ts diff --git a/packages/it-buffer-stream/test.js b/packages/it-buffer-stream/test/index.spec.ts similarity index 100% rename from packages/it-buffer-stream/test.js rename to packages/it-buffer-stream/test/index.spec.ts diff --git a/packages/it-buffer-stream/tsconfig.json b/packages/it-buffer-stream/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-buffer-stream/tsconfig.json +++ b/packages/it-buffer-stream/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-drain/.npmignore b/packages/it-drain/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-drain/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-drain/package.json b/packages/it-drain/package.json index 2fdcb787..a70d622c 100644 --- a/packages/it-drain/package.json +++ b/packages/it-drain/package.json @@ -2,7 +2,7 @@ "name": "it-drain", "version": "1.0.5", "description": "Empties an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-drain#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-drain/index.js b/packages/it-drain/src/index.ts similarity index 100% rename from packages/it-drain/index.js rename to packages/it-drain/src/index.ts diff --git a/packages/it-drain/test.js b/packages/it-drain/test/index.spec.ts similarity index 100% rename from packages/it-drain/test.js rename to packages/it-drain/test/index.spec.ts diff --git a/packages/it-drain/tsconfig.json b/packages/it-drain/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-drain/tsconfig.json +++ b/packages/it-drain/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-filter/.npmignore b/packages/it-filter/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-filter/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-filter/package.json b/packages/it-filter/package.json index 904b0b72..7ec79005 100644 --- a/packages/it-filter/package.json +++ b/packages/it-filter/package.json @@ -2,7 +2,7 @@ "name": "it-filter", "version": "1.0.3", "description": "Filters the passed iterable by using the filter function", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-filter#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-filter/index.js b/packages/it-filter/src/index.ts similarity index 100% rename from packages/it-filter/index.js rename to packages/it-filter/src/index.ts diff --git a/packages/it-filter/test.js b/packages/it-filter/test/index.spec.ts similarity index 100% rename from packages/it-filter/test.js rename to packages/it-filter/test/index.spec.ts diff --git a/packages/it-filter/tsconfig.json b/packages/it-filter/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-filter/tsconfig.json +++ b/packages/it-filter/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-first/.npmignore b/packages/it-first/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-first/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-first/package.json b/packages/it-first/package.json index b906ddbf..2ea18f35 100644 --- a/packages/it-first/package.json +++ b/packages/it-first/package.json @@ -2,7 +2,7 @@ "name": "it-first", "version": "1.0.7", "description": "Returns the first result from an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-first#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-first/index.js b/packages/it-first/src/index.ts similarity index 100% rename from packages/it-first/index.js rename to packages/it-first/src/index.ts diff --git a/packages/it-first/test.js b/packages/it-first/test/index.spec.ts similarity index 100% rename from packages/it-first/test.js rename to packages/it-first/test/index.spec.ts diff --git a/packages/it-first/tsconfig.json b/packages/it-first/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-first/tsconfig.json +++ b/packages/it-first/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-flat-batch/.npmignore b/packages/it-flat-batch/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-flat-batch/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-flat-batch/package.json b/packages/it-flat-batch/package.json index ba2bbb17..d3a073f9 100644 --- a/packages/it-flat-batch/package.json +++ b/packages/it-flat-batch/package.json @@ -2,7 +2,7 @@ "name": "it-flat-batch", "version": "1.0.7", "description": "Takes an async iterator that emits variable length arrays and emits them as fixed size batches", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-flat-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-flat-batch/index.js b/packages/it-flat-batch/src/ index.ts similarity index 100% rename from packages/it-flat-batch/index.js rename to packages/it-flat-batch/src/ index.ts diff --git a/packages/it-flat-batch/test.js b/packages/it-flat-batch/test/index.spec.ts similarity index 100% rename from packages/it-flat-batch/test.js rename to packages/it-flat-batch/test/index.spec.ts diff --git a/packages/it-flat-batch/tsconfig.json b/packages/it-flat-batch/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-flat-batch/tsconfig.json +++ b/packages/it-flat-batch/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-foreach/.npmignore b/packages/it-foreach/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-foreach/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-foreach/package.json b/packages/it-foreach/package.json index eaba9f04..527c929b 100644 --- a/packages/it-foreach/package.json +++ b/packages/it-foreach/package.json @@ -2,7 +2,7 @@ "name": "it-foreach", "version": "0.1.1", "description": "Invokes the passed function for each item in an iterable", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-foreach#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-foreach/index.js b/packages/it-foreach/src/index.ts similarity index 100% rename from packages/it-foreach/index.js rename to packages/it-foreach/src/index.ts diff --git a/packages/it-foreach/test.js b/packages/it-foreach/test/index.spec.ts similarity index 100% rename from packages/it-foreach/test.js rename to packages/it-foreach/test/index.spec.ts diff --git a/packages/it-foreach/tsconfig.json b/packages/it-foreach/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-foreach/tsconfig.json +++ b/packages/it-foreach/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-glob/.npmignore b/packages/it-glob/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-glob/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-glob/package.json b/packages/it-glob/package.json index e46467d3..a3c69aba 100644 --- a/packages/it-glob/package.json +++ b/packages/it-glob/package.json @@ -2,7 +2,7 @@ "name": "it-glob", "version": "1.0.2", "description": "Async iterable filename pattern matcher", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-glob#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -23,15 +23,17 @@ "minimatch": "^3.0.4" }, "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, "browser": { "fs": false, "path": false }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-glob/index.js b/packages/it-glob/src/index.ts similarity index 100% rename from packages/it-glob/index.js rename to packages/it-glob/src/index.ts diff --git a/packages/it-glob/test.js b/packages/it-glob/test/index.spec.ts similarity index 100% rename from packages/it-glob/test.js rename to packages/it-glob/test/index.spec.ts diff --git a/packages/it-glob/tsconfig.json b/packages/it-glob/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-glob/tsconfig.json +++ b/packages/it-glob/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-last/.npmignore b/packages/it-last/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-last/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-last/package.json b/packages/it-last/package.json index 53597092..809cffaa 100644 --- a/packages/it-last/package.json +++ b/packages/it-last/package.json @@ -2,7 +2,7 @@ "name": "it-last", "version": "1.0.6", "description": "Returns the last result from an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-last#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-last/index.js b/packages/it-last/src/index.ts similarity index 100% rename from packages/it-last/index.js rename to packages/it-last/src/index.ts diff --git a/packages/it-last/test.js b/packages/it-last/test/index.spec.ts similarity index 100% rename from packages/it-last/test.js rename to packages/it-last/test/index.spec.ts diff --git a/packages/it-last/tsconfig.json b/packages/it-last/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-last/tsconfig.json +++ b/packages/it-last/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-length/.npmignore b/packages/it-length/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-length/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-length/package.json b/packages/it-length/package.json index 3e22dfe2..f7346b73 100644 --- a/packages/it-length/package.json +++ b/packages/it-length/package.json @@ -2,7 +2,7 @@ "name": "it-length", "version": "1.0.4", "description": "Counts the number of items in an async iterable", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-length#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-length/index.js b/packages/it-length/src/index.ts similarity index 100% rename from packages/it-length/index.js rename to packages/it-length/src/index.ts diff --git a/packages/it-length/test.js b/packages/it-length/test/index.spec.ts similarity index 84% rename from packages/it-length/test.js rename to packages/it-length/test/index.spec.ts index 8d4f6191..80da64bd 100644 --- a/packages/it-length/test.js +++ b/packages/it-length/test/index.spec.ts @@ -1,4 +1,4 @@ -const length = require('./') +const length = require('../dist') const test = require('ava') test('Should count the items in an async iterator', async (t) => { diff --git a/packages/it-length/tsconfig.json b/packages/it-length/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-length/tsconfig.json +++ b/packages/it-length/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-map/.npmignore b/packages/it-map/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-map/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-map/package.json b/packages/it-map/package.json index 867c430e..774a7e37 100644 --- a/packages/it-map/package.json +++ b/packages/it-map/package.json @@ -2,7 +2,7 @@ "name": "it-map", "version": "1.0.6", "description": "Maps the values yielded by an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-map#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-map/index.js b/packages/it-map/src/index.ts similarity index 100% rename from packages/it-map/index.js rename to packages/it-map/src/index.ts diff --git a/packages/it-map/test.js b/packages/it-map/test/index.spec.ts similarity index 100% rename from packages/it-map/test.js rename to packages/it-map/test/index.spec.ts diff --git a/packages/it-map/tsconfig.json b/packages/it-map/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-map/tsconfig.json +++ b/packages/it-map/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-merge/.npmignore b/packages/it-merge/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-merge/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-merge/package.json b/packages/it-merge/package.json index 2e90ea19..6f1da8c9 100644 --- a/packages/it-merge/package.json +++ b/packages/it-merge/package.json @@ -2,7 +2,7 @@ "name": "it-merge", "version": "1.0.4", "description": "Treat one or more iterables as a single iterable", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-merge#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -22,11 +22,13 @@ "it-pushable": "^1.4.0" }, "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-merge/index.js b/packages/it-merge/src/index.ts similarity index 100% rename from packages/it-merge/index.js rename to packages/it-merge/src/index.ts diff --git a/packages/it-merge/test.js b/packages/it-merge/test/index.spec.ts similarity index 100% rename from packages/it-merge/test.js rename to packages/it-merge/test/index.spec.ts diff --git a/packages/it-merge/tsconfig.json b/packages/it-merge/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-merge/tsconfig.json +++ b/packages/it-merge/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-multipart/.npmignore b/packages/it-multipart/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-multipart/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index 2156a0b0..ef6e9e14 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -2,7 +2,7 @@ "name": "it-multipart", "version": "2.0.2", "description": "Async iterable http multipart message parser", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-multipart#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -24,12 +24,14 @@ }, "devDependencies": { "@types/formidable": "^1.2.1", - "ava": "^3.12.1", + "aegir": "^37.5.0", "form-data": "^3.0.0", - "node-fetch": "^2.6.0", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "undici": "^5.11.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-multipart/index.js b/packages/it-multipart/src/index.ts similarity index 100% rename from packages/it-multipart/index.js rename to packages/it-multipart/src/index.ts diff --git a/packages/it-multipart/test.js b/packages/it-multipart/test/index.spec.ts similarity index 100% rename from packages/it-multipart/test.js rename to packages/it-multipart/test/index.spec.ts diff --git a/packages/it-multipart/tsconfig.json b/packages/it-multipart/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-multipart/tsconfig.json +++ b/packages/it-multipart/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-ndjson/.npmignore b/packages/it-ndjson/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-ndjson/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-ndjson/package.json b/packages/it-ndjson/package.json index e82b190e..a1a043e2 100644 --- a/packages/it-ndjson/package.json +++ b/packages/it-ndjson/package.json @@ -2,7 +2,7 @@ "name": "it-ndjson", "version": "0.1.1", "description": "Parse iterators as ndjson and transform iterators to ndjson", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-ndjson#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,12 +19,14 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", + "aegir": "^37.5.0", "buffer": "^6.0.3", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-ndjson/index.js b/packages/it-ndjson/src/index.ts similarity index 100% rename from packages/it-ndjson/index.js rename to packages/it-ndjson/src/index.ts diff --git a/packages/it-ndjson/parse.js b/packages/it-ndjson/src/parse.ts similarity index 100% rename from packages/it-ndjson/parse.js rename to packages/it-ndjson/src/parse.ts diff --git a/packages/it-ndjson/stringify.js b/packages/it-ndjson/src/stringify.ts similarity index 100% rename from packages/it-ndjson/stringify.js rename to packages/it-ndjson/src/stringify.ts diff --git a/packages/it-ndjson/test.js b/packages/it-ndjson/test/index.spec.ts similarity index 100% rename from packages/it-ndjson/test.js rename to packages/it-ndjson/test/index.spec.ts diff --git a/packages/it-ndjson/tsconfig.json b/packages/it-ndjson/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-ndjson/tsconfig.json +++ b/packages/it-ndjson/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-parallel-batch/.npmignore b/packages/it-parallel-batch/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-parallel-batch/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-parallel-batch/package.json b/packages/it-parallel-batch/package.json index fdeec56f..383f7ac7 100644 --- a/packages/it-parallel-batch/package.json +++ b/packages/it-parallel-batch/package.json @@ -2,7 +2,7 @@ "name": "it-parallel-batch", "version": "1.0.11", "description": "Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -20,12 +20,9 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", + "aegir": "^37.5.0", "delay": "^4.3.0", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "it-all": "^1.0.6" }, "dependencies": { "it-batch": "^1.0.9" @@ -37,5 +34,10 @@ "dist/*" ] } + }, + "exports": { + ".": { + "import": "./dist/src/index.js" + } } } diff --git a/packages/it-parallel-batch/index.js b/packages/it-parallel-batch/src/index.ts similarity index 100% rename from packages/it-parallel-batch/index.js rename to packages/it-parallel-batch/src/index.ts diff --git a/packages/it-parallel-batch/test.js b/packages/it-parallel-batch/test/index.spec.ts similarity index 98% rename from packages/it-parallel-batch/test.js rename to packages/it-parallel-batch/test/index.spec.ts index bc2b7b2c..3b590d1e 100644 --- a/packages/it-parallel-batch/test.js +++ b/packages/it-parallel-batch/test/index.spec.ts @@ -1,6 +1,6 @@ 'use strict' -const parallelBatch = require('./') +const parallelBatch = require('../dist') const test = require('ava') const all = require('it-all') const delay = require('delay') diff --git a/packages/it-parallel-batch/tsconfig.json b/packages/it-parallel-batch/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-parallel-batch/tsconfig.json +++ b/packages/it-parallel-batch/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-parallel/.npmignore b/packages/it-parallel/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-parallel/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-parallel/package.json b/packages/it-parallel/package.json index bc96644d..46877202 100644 --- a/packages/it-parallel/package.json +++ b/packages/it-parallel/package.json @@ -2,7 +2,7 @@ "name": "it-parallel", "version": "2.0.2", "description": "Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,12 +19,9 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", + "aegir": "^37.5.0", "delay": "^4.3.0", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "it-all": "^1.0.6" }, "dependencies": { "p-defer": "^3.0.0" @@ -36,5 +33,10 @@ "dist/*" ] } + }, + "exports": { + ".": { + "import": "./dist/src/index.js" + } } } diff --git a/packages/it-parallel/index.js b/packages/it-parallel/src/index.ts similarity index 100% rename from packages/it-parallel/index.js rename to packages/it-parallel/src/index.ts diff --git a/packages/it-parallel/test.js b/packages/it-parallel/test/index.spec.ts similarity index 99% rename from packages/it-parallel/test.js rename to packages/it-parallel/test/index.spec.ts index bb8a9a24..80e5f7b1 100644 --- a/packages/it-parallel/test.js +++ b/packages/it-parallel/test/index.spec.ts @@ -1,6 +1,6 @@ 'use strict' -const parallel = require('./') +const parallel = require('../dist') const test = require('ava') const all = require('it-all') const delay = require('delay') diff --git a/packages/it-parallel/tsconfig.json b/packages/it-parallel/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-parallel/tsconfig.json +++ b/packages/it-parallel/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-peekable/.npmignore b/packages/it-peekable/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-peekable/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-peekable/package.json b/packages/it-peekable/package.json index 4fa33aca..d5897447 100644 --- a/packages/it-peekable/package.json +++ b/packages/it-peekable/package.json @@ -2,7 +2,7 @@ "name": "it-peekable", "version": "1.0.3", "description": "Allows peeking/pushing an iterable", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-peekable#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-peekable/index.js b/packages/it-peekable/src/index.ts similarity index 100% rename from packages/it-peekable/index.js rename to packages/it-peekable/src/index.ts diff --git a/packages/it-peekable/test.js b/packages/it-peekable/test/index.spec.ts similarity index 100% rename from packages/it-peekable/test.js rename to packages/it-peekable/test/index.spec.ts diff --git a/packages/it-peekable/tsconfig.json b/packages/it-peekable/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-peekable/tsconfig.json +++ b/packages/it-peekable/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-reduce/.npmignore b/packages/it-reduce/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-reduce/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-reduce/package.json b/packages/it-reduce/package.json index 423ff56c..08181332 100644 --- a/packages/it-reduce/package.json +++ b/packages/it-reduce/package.json @@ -2,7 +2,7 @@ "name": "it-reduce", "version": "1.0.6", "description": "Reduces the values yielded from an async iterator", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-reduce#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-reduce/index.js b/packages/it-reduce/src/index.ts similarity index 100% rename from packages/it-reduce/index.js rename to packages/it-reduce/src/index.ts diff --git a/packages/it-reduce/test.js b/packages/it-reduce/test/index.spec.ts similarity index 100% rename from packages/it-reduce/test.js rename to packages/it-reduce/test/index.spec.ts diff --git a/packages/it-reduce/tsconfig.json b/packages/it-reduce/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-reduce/tsconfig.json +++ b/packages/it-reduce/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-skip/.npmignore b/packages/it-skip/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-skip/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-skip/package.json b/packages/it-skip/package.json index 062202f7..002c9a22 100644 --- a/packages/it-skip/package.json +++ b/packages/it-skip/package.json @@ -2,7 +2,7 @@ "name": "it-skip", "version": "1.0.2", "description": "Skip items from an iterable", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-skip#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-skip/index.js b/packages/it-skip/src/index.ts similarity index 100% rename from packages/it-skip/index.js rename to packages/it-skip/src/index.ts diff --git a/packages/it-skip/test.js b/packages/it-skip/test/index.spec.ts similarity index 100% rename from packages/it-skip/test.js rename to packages/it-skip/test/index.spec.ts diff --git a/packages/it-skip/tsconfig.json b/packages/it-skip/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-skip/tsconfig.json +++ b/packages/it-skip/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-sort/.npmignore b/packages/it-sort/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-sort/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-sort/package.json b/packages/it-sort/package.json index 2d2228bc..51158fe7 100644 --- a/packages/it-sort/package.json +++ b/packages/it-sort/package.json @@ -2,7 +2,7 @@ "name": "it-sort", "version": "1.0.1", "description": "Collects all values from an async iterator, sorts them using the passed function and yields them", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-sort#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -22,10 +22,12 @@ "it-all": "^1.0.6" }, "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-sort/index.js b/packages/it-sort/src/index.ts similarity index 100% rename from packages/it-sort/index.js rename to packages/it-sort/src/index.ts diff --git a/packages/it-sort/test.js b/packages/it-sort/test/index.spec.ts similarity index 100% rename from packages/it-sort/test.js rename to packages/it-sort/test/index.spec.ts diff --git a/packages/it-sort/tsconfig.json b/packages/it-sort/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-sort/tsconfig.json +++ b/packages/it-sort/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-split/.npmignore b/packages/it-split/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-split/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-split/package.json b/packages/it-split/package.json index 8330e582..80451b25 100644 --- a/packages/it-split/package.json +++ b/packages/it-split/package.json @@ -2,7 +2,7 @@ "name": "it-split", "version": "1.0.2", "description": "Splits Uint8Arrays emitted by an (async) iterable by a delimiter", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-split#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -23,12 +23,14 @@ }, "devDependencies": { "@types/bl": "^5.0.1", - "ava": "^3.12.1", + "aegir": "^37.5.0", "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-split/index.js b/packages/it-split/src/index.ts similarity index 100% rename from packages/it-split/index.js rename to packages/it-split/src/index.ts diff --git a/packages/it-split/test.js b/packages/it-split/test/index.spec.ts similarity index 100% rename from packages/it-split/test.js rename to packages/it-split/test/index.spec.ts diff --git a/packages/it-split/tsconfig.json b/packages/it-split/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-split/tsconfig.json +++ b/packages/it-split/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-take/.npmignore b/packages/it-take/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-take/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-take/package.json b/packages/it-take/package.json index 15f55ec4..3b74342f 100644 --- a/packages/it-take/package.json +++ b/packages/it-take/package.json @@ -2,7 +2,7 @@ "name": "it-take", "version": "1.0.2", "description": "Stop iteration after n items have been received", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-take#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,11 +19,13 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "it-all": "^1.0.6", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0", + "it-all": "^1.0.6" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-take/index.js b/packages/it-take/src/index.ts similarity index 100% rename from packages/it-take/index.js rename to packages/it-take/src/index.ts diff --git a/packages/it-take/test.js b/packages/it-take/test/index.spec.ts similarity index 100% rename from packages/it-take/test.js rename to packages/it-take/test/index.spec.ts diff --git a/packages/it-take/tsconfig.json b/packages/it-take/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-take/tsconfig.json +++ b/packages/it-take/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-to-browser-readablestream/.npmignore b/packages/it-to-browser-readablestream/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-to-browser-readablestream/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-to-browser-readablestream/package.json b/packages/it-to-browser-readablestream/package.json index 81814a56..ba0f3abf 100644 --- a/packages/it-to-browser-readablestream/package.json +++ b/packages/it-to-browser-readablestream/package.json @@ -2,7 +2,7 @@ "name": "it-to-browser-readablestream", "version": "1.0.4", "description": "Takes an async iterator and turns it into a browser readable stream", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-browser-readablestream#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,10 +19,12 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-to-browser-readablestream/index.js b/packages/it-to-browser-readablestream/src/index.ts similarity index 100% rename from packages/it-to-browser-readablestream/index.js rename to packages/it-to-browser-readablestream/src/index.ts diff --git a/packages/it-to-browser-readablestream/test.js b/packages/it-to-browser-readablestream/test/index.spec.ts similarity index 100% rename from packages/it-to-browser-readablestream/test.js rename to packages/it-to-browser-readablestream/test/index.spec.ts diff --git a/packages/it-to-browser-readablestream/tsconfig.json b/packages/it-to-browser-readablestream/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-to-browser-readablestream/tsconfig.json +++ b/packages/it-to-browser-readablestream/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} diff --git a/packages/it-to-buffer/.npmignore b/packages/it-to-buffer/.npmignore deleted file mode 100644 index 9bb01f4b..00000000 --- a/packages/it-to-buffer/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -*.log -.DS_Store -Thumbs.db -.vscode -.nyc_output -coverage -bin diff --git a/packages/it-to-buffer/package.json b/packages/it-to-buffer/package.json index 1b5dcf0a..2378d8bd 100644 --- a/packages/it-to-buffer/package.json +++ b/packages/it-to-buffer/package.json @@ -2,7 +2,7 @@ "name": "it-to-buffer", "version": "2.0.2", "description": "Takes an async iterator that yields buffers and concatenates them all together", - "main": "index.js", + "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-buffer#readme", "bugs": "https://github.com/achingbrain/it/issues", @@ -19,13 +19,15 @@ "author": "Alex Potsides ", "license": "ISC", "devDependencies": { - "ava": "^3.12.1", - "nyc": "^15.1.0", - "standard": "^16.0.3", - "typescript": "^4.0.2" + "aegir": "^37.5.0" }, "dependencies": { - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/src/index.js" + } + } } diff --git a/packages/it-to-buffer/index.js b/packages/it-to-buffer/src/index.ts similarity index 100% rename from packages/it-to-buffer/index.js rename to packages/it-to-buffer/src/index.ts diff --git a/packages/it-to-buffer/test.js b/packages/it-to-buffer/test/index.spec.ts similarity index 100% rename from packages/it-to-buffer/test.js rename to packages/it-to-buffer/test/index.spec.ts diff --git a/packages/it-to-buffer/tsconfig.json b/packages/it-to-buffer/tsconfig.json index f5e4524f..13a35996 100644 --- a/packages/it-to-buffer/tsconfig.json +++ b/packages/it-to-buffer/tsconfig.json @@ -1,6 +1,10 @@ { - "extends": "../../typescript.json", + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, "include": [ - "." + "src", + "test" ] -} \ No newline at end of file +} From 6cede874b4e9b02c5e570a503b876da3c7e71d5b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 08:18:57 +0100 Subject: [PATCH 2/8] chore: wip --- packages/blob-to-it/README.md | 2 +- packages/blob-to-it/src/index.ts | 12 ++--------- packages/blob-to-it/test/index.spec.ts | 8 +++---- .../browser-readablestream-to-it/README.md | 2 +- .../browser-readablestream-to-it/package.json | 19 ++++++++++------- .../browser-readablestream-to-it/src/index.ts | 14 +++++-------- .../test/index.spec.ts | 8 +++---- packages/it-all/README.md | 2 +- packages/it-all/package.json | 21 +++++++++++-------- packages/it-all/src/index.ts | 10 ++------- packages/it-all/test/index.spec.ts | 16 ++++++++------ packages/it-batch/README.md | 2 +- packages/it-batch/package.json | 19 ++++++++++------- packages/it-batch/test/index.spec.ts | 2 +- packages/it-buffer-stream/package.json | 19 ++++++++++------- packages/it-drain/package.json | 19 ++++++++++------- packages/it-filter/README.md | 2 +- packages/it-filter/package.json | 19 ++++++++++------- packages/it-filter/test/index.spec.ts | 2 +- packages/it-first/package.json | 19 ++++++++++------- packages/it-flat-batch/README.md | 2 +- packages/it-flat-batch/package.json | 19 ++++++++++------- packages/it-flat-batch/test/index.spec.ts | 2 +- packages/it-foreach/package.json | 19 ++++++++++------- packages/it-foreach/test/index.spec.ts | 2 +- packages/it-glob/package.json | 19 ++++++++++------- packages/it-glob/test/index.spec.ts | 2 +- packages/it-last/package.json | 19 ++++++++++------- packages/it-length/package.json | 19 ++++++++++------- packages/it-map/package.json | 19 ++++++++++------- packages/it-merge/package.json | 19 ++++++++++------- packages/it-merge/test/index.spec.ts | 2 +- packages/it-multipart/package.json | 19 ++++++++++------- packages/it-ndjson/README.md | 2 +- packages/it-ndjson/package.json | 19 ++++++++++------- packages/it-ndjson/test/index.spec.ts | 2 +- packages/it-parallel-batch/README.md | 2 +- packages/it-parallel-batch/package.json | 20 ++++++++++-------- packages/it-parallel-batch/test/index.spec.ts | 2 +- packages/it-parallel/README.md | 2 +- packages/it-parallel/package.json | 19 ++++++++++------- packages/it-parallel/test/index.spec.ts | 2 +- packages/it-peekable/package.json | 19 ++++++++++------- packages/it-peekable/test/index.spec.ts | 2 +- packages/it-reduce/package.json | 19 ++++++++++------- packages/it-skip/README.md | 2 +- packages/it-skip/package.json | 19 ++++++++++------- packages/it-skip/test/index.spec.ts | 2 +- packages/it-sort/README.md | 2 +- packages/it-sort/package.json | 19 ++++++++++------- packages/it-sort/src/index.ts | 2 +- packages/it-sort/test/index.spec.ts | 2 +- packages/it-split/package.json | 19 ++++++++++------- packages/it-split/test/index.spec.ts | 2 +- packages/it-take/README.md | 2 +- packages/it-take/package.json | 19 ++++++++++------- packages/it-take/test/index.spec.ts | 2 +- .../it-to-browser-readablestream/package.json | 19 ++++++++++------- packages/it-to-buffer/package.json | 19 ++++++++++------- packages/it-to-buffer/test/index.spec.ts | 2 +- 60 files changed, 340 insertions(+), 281 deletions(-) diff --git a/packages/blob-to-it/README.md b/packages/blob-to-it/README.md index 5aa9a0d3..701b0401 100644 --- a/packages/blob-to-it/README.md +++ b/packages/blob-to-it/README.md @@ -14,7 +14,7 @@ $ npm install --save blob-to-it ```javascript const toIt = require('blob-to-it') -const all = require('it-all') +import all from 'it-all' const content = [ Uint8Array.from([0, 1, 2, 3, 4]) ] const blob = new Blob(content) diff --git a/packages/blob-to-it/src/index.ts b/packages/blob-to-it/src/index.ts index 84294a8c..d0042190 100644 --- a/packages/blob-to-it/src/index.ts +++ b/packages/blob-to-it/src/index.ts @@ -1,14 +1,8 @@ /* eslint-env browser */ -'use strict' +import browserReadableStreamToIt from 'browser-readablestream-to-it' -const browserReadableStreamToIt = require('browser-readablestream-to-it/src') - -/** - * @param {Blob} blob - * @returns {AsyncIterable} - */ -function blobToIt (blob) { +export default function blobToIt (blob: Blob): AsyncIterable { if (typeof blob.stream === 'function') { // @ts-ignore missing some properties return browserReadableStreamToIt(blob.stream()) @@ -18,5 +12,3 @@ function blobToIt (blob) { // @ts-ignore - response.body is optional, but in practice it's a stream. return browserReadableStreamToIt(new Response(blob).body) } - -module.exports = blobToIt diff --git a/packages/blob-to-it/test/index.spec.ts b/packages/blob-to-it/test/index.spec.ts index bdc6f2ff..8fbf3188 100644 --- a/packages/blob-to-it/test/index.spec.ts +++ b/packages/blob-to-it/test/index.spec.ts @@ -1,10 +1,8 @@ /* eslint-env mocha, browser */ -'use strict' - -const all = require('it-all/src') -const { expect } = require('chai') -const toIt = require('./index') +import all from 'it-all' +import { expect } from 'aegir/chai' +import toIt from '../src/index.js' describe('blob-to-it', () => { it('should convert a blob to an async iterator', async () => { diff --git a/packages/browser-readablestream-to-it/README.md b/packages/browser-readablestream-to-it/README.md index 8f9ce89c..ce04003d 100644 --- a/packages/browser-readablestream-to-it/README.md +++ b/packages/browser-readablestream-to-it/README.md @@ -14,7 +14,7 @@ $ npm install --save browser-readablestream-to-it ```javascript const toIt = require('browser-readablestream-to-it') -const all = require('it-all') +import all from 'it-all' const content = [0, 1, 2, 3, 4] diff --git a/packages/browser-readablestream-to-it/package.json b/packages/browser-readablestream-to-it/package.json index 6d289009..dec0ae4b 100644 --- a/packages/browser-readablestream-to-it/package.json +++ b/packages/browser-readablestream-to-it/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/browser-readablestream-to-it#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "playwright-test", - "lint": "standard", - "coverage": "playwright-test", - "check": "tsc --noEmit", - "clean": "rm -rf dist", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/browser-readablestream-to-it/src/index.ts b/packages/browser-readablestream-to-it/src/index.ts index 15e5395f..c9fb0bc6 100644 --- a/packages/browser-readablestream-to-it/src/index.ts +++ b/packages/browser-readablestream-to-it/src/index.ts @@ -1,4 +1,7 @@ -'use strict' + +export interface BrowserReadableStreamToItOptions { + preventCancel?: boolean +} /** * Turns a browser readable stream into an async iterable. Async iteration over @@ -6,13 +9,8 @@ * acquiring a reader. The lock will be released if iteration loop is broken. To * prevent stream cancelling optional `{ preventCancel: true }` could be passed * as a second argument. - * @template T - * @param {ReadableStream} stream - * @param {Object} [options] - * @param {boolean} [options.preventCancel=boolean] - * @returns {AsyncIterable} */ -async function * browserReadableStreamToIt (stream, options = {}) { +export default async function * browserReadableStreamToIt (stream: ReadableStream, options: BrowserReadableStreamToItOptions = {}): AsyncGenerator { const reader = stream.getReader() try { @@ -33,5 +31,3 @@ async function * browserReadableStreamToIt (stream, options = {}) { reader.releaseLock() } } - -module.exports = browserReadableStreamToIt diff --git a/packages/browser-readablestream-to-it/test/index.spec.ts b/packages/browser-readablestream-to-it/test/index.spec.ts index b920c51f..770879a5 100644 --- a/packages/browser-readablestream-to-it/test/index.spec.ts +++ b/packages/browser-readablestream-to-it/test/index.spec.ts @@ -1,10 +1,8 @@ /* eslint-env mocha, browser */ -'use strict' - -const all = require('it-all/src') -const { expect } = require('chai') -const toIt = require('./index') +import all from 'it-all' +import { expect } from 'aegir/chai' +import toIt from '../src/index.js' describe('browser-readablestream-to-it', () => { it('should convert a readablestream to an async iterator', async () => { diff --git a/packages/it-all/README.md b/packages/it-all/README.md index c7faf3cb..786524ef 100644 --- a/packages/it-all/README.md +++ b/packages/it-all/README.md @@ -15,7 +15,7 @@ $ npm install --save it-all ## Usage ```javascript -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-all/package.json b/packages/it-all/package.json index 1998097e..be415e2b 100644 --- a/packages/it-all/package.json +++ b/packages/it-all/package.json @@ -1,20 +1,23 @@ { "name": "it-all", "version": "1.0.6", - "description": "Collects all values from an async iterator and returns them as an array", + "description": "Collects all values from an (async) iterable and returns them as an array", "type": "module", "repository": "github:achingbrain/it", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-all#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-all/src/index.ts b/packages/it-all/src/index.ts index f938d233..1e734de0 100644 --- a/packages/it-all/src/index.ts +++ b/packages/it-all/src/index.ts @@ -1,12 +1,8 @@ -'use strict' /** - * Collects all values from an (async) iterable into an array and returns it. - * - * @template T - * @param {AsyncIterable|Iterable} source + * Collects all values from an (async) iterable and returns them as an array */ -const all = async (source) => { +export default async function all (source: AsyncIterable|Iterable): Promise { const arr = [] for await (const entry of source) { @@ -15,5 +11,3 @@ const all = async (source) => { return arr } - -module.exports = all diff --git a/packages/it-all/test/index.spec.ts b/packages/it-all/test/index.spec.ts index 30914a75..b85f5487 100644 --- a/packages/it-all/test/index.spec.ts +++ b/packages/it-all/test/index.spec.ts @@ -1,10 +1,14 @@ -const all = require('./') -const test = require('ava') +/* eslint-env mocha */ -test('Should collect all entries of an async iterator as an array', async (t) => { - const values = [0, 1, 2, 3, 4] +import { expect } from 'aegir/chai' +import all from '../src/index.js' - const res = await all(values) +describe('it-all', () => { + it('Should collect all entries of an async iterator as an array', async () => { + const values = [0, 1, 2, 3, 4] - t.deepEqual(res, values) + const res = await all(values) + + expect(res).to.deep.equal(values) + }) }) diff --git a/packages/it-batch/README.md b/packages/it-batch/README.md index 3927ab77..aa23a2fd 100644 --- a/packages/it-batch/README.md +++ b/packages/it-batch/README.md @@ -16,7 +16,7 @@ $ npm install --save it-batch ```javascript const batch = require('it-batch') -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-batch/package.json b/packages/it-batch/package.json index 0f7be519..aad7b562 100644 --- a/packages/it-batch/package.json +++ b/packages/it-batch/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-batch/test/index.spec.ts b/packages/it-batch/test/index.spec.ts index 469b5363..3e46b4e1 100644 --- a/packages/it-batch/test/index.spec.ts +++ b/packages/it-batch/test/index.spec.ts @@ -1,6 +1,6 @@ const batch = require('../dist') const test = require('ava') -const all = require('it-all') +import all from 'it-all' test('Should batch up entries', async (t) => { const values = [0, 1, 2, 3, 4] diff --git a/packages/it-buffer-stream/package.json b/packages/it-buffer-stream/package.json index 1a18149f..3651704f 100644 --- a/packages/it-buffer-stream/package.json +++ b/packages/it-buffer-stream/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-buffer-stream#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-drain/package.json b/packages/it-drain/package.json index a70d622c..b452b731 100644 --- a/packages/it-drain/package.json +++ b/packages/it-drain/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-drain#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-filter/README.md b/packages/it-filter/README.md index d3092306..6e45d1f8 100644 --- a/packages/it-filter/README.md +++ b/packages/it-filter/README.md @@ -13,7 +13,7 @@ $ npm install --save it-filter ## Usage ```javascript -const all = require('it-all') +import all from 'it-all' const filter = require('it-filter') // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-filter/package.json b/packages/it-filter/package.json index 7ec79005..5ef43fa3 100644 --- a/packages/it-filter/package.json +++ b/packages/it-filter/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-filter#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-filter/test/index.spec.ts b/packages/it-filter/test/index.spec.ts index 2c157e59..97f4387a 100644 --- a/packages/it-filter/test/index.spec.ts +++ b/packages/it-filter/test/index.spec.ts @@ -1,4 +1,4 @@ -const all = require('it-all') +import all from 'it-all' const filter = require('./') const test = require('ava') diff --git a/packages/it-first/package.json b/packages/it-first/package.json index 2ea18f35..5c1a18db 100644 --- a/packages/it-first/package.json +++ b/packages/it-first/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-first#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-flat-batch/README.md b/packages/it-flat-batch/README.md index 430d3e90..8c8642ae 100644 --- a/packages/it-flat-batch/README.md +++ b/packages/it-flat-batch/README.md @@ -16,7 +16,7 @@ $ npm install --save it-flat-batch ```javascript const batch = require('it-flat-batch') -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [[0, 1, 2], [3], [4]] diff --git a/packages/it-flat-batch/package.json b/packages/it-flat-batch/package.json index d3a073f9..5a91ab2b 100644 --- a/packages/it-flat-batch/package.json +++ b/packages/it-flat-batch/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-flat-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-flat-batch/test/index.spec.ts b/packages/it-flat-batch/test/index.spec.ts index 3a9c3b30..cc1b2893 100644 --- a/packages/it-flat-batch/test/index.spec.ts +++ b/packages/it-flat-batch/test/index.spec.ts @@ -1,6 +1,6 @@ const batch = require('./') const test = require('ava') -const all = require('it-all') +import all from 'it-all' test('Should batch up emitted arrays', async (t) => { const values = [[0, 1, 2], [3], [4]] diff --git a/packages/it-foreach/package.json b/packages/it-foreach/package.json index 527c929b..8321c270 100644 --- a/packages/it-foreach/package.json +++ b/packages/it-foreach/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-foreach#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-foreach/test/index.spec.ts b/packages/it-foreach/test/index.spec.ts index 54219090..458c426f 100644 --- a/packages/it-foreach/test/index.spec.ts +++ b/packages/it-foreach/test/index.spec.ts @@ -1,5 +1,5 @@ const each = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') test('Should iterate over every value', async (t) => { diff --git a/packages/it-glob/package.json b/packages/it-glob/package.json index a3c69aba..2cdd231d 100644 --- a/packages/it-glob/package.json +++ b/packages/it-glob/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-glob#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-glob/test/index.spec.ts b/packages/it-glob/test/index.spec.ts index f11ee81d..f655d61a 100644 --- a/packages/it-glob/test/index.spec.ts +++ b/packages/it-glob/test/index.spec.ts @@ -1,5 +1,5 @@ const test = require('ava') -const all = require('it-all') +import all from 'it-all' const glob = require('.') const path = require('path') diff --git a/packages/it-last/package.json b/packages/it-last/package.json index 809cffaa..8438f7e0 100644 --- a/packages/it-last/package.json +++ b/packages/it-last/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-last#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-length/package.json b/packages/it-length/package.json index f7346b73..92576e0e 100644 --- a/packages/it-length/package.json +++ b/packages/it-length/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-length#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-map/package.json b/packages/it-map/package.json index 774a7e37..b9515e98 100644 --- a/packages/it-map/package.json +++ b/packages/it-map/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-map#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-merge/package.json b/packages/it-merge/package.json index 6f1da8c9..6623ca44 100644 --- a/packages/it-merge/package.json +++ b/packages/it-merge/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-merge#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-merge/test/index.spec.ts b/packages/it-merge/test/index.spec.ts index bb4c21fe..20807f83 100644 --- a/packages/it-merge/test/index.spec.ts +++ b/packages/it-merge/test/index.spec.ts @@ -1,5 +1,5 @@ const merge = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') test('Should merge multiple arrays', async (t) => { diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index ef6e9e14..259d5420 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-multipart#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-ndjson/README.md b/packages/it-ndjson/README.md index 45b2b995..304920ea 100644 --- a/packages/it-ndjson/README.md +++ b/packages/it-ndjson/README.md @@ -14,7 +14,7 @@ $ npm install --save it-ndjson ```javascript const ndjson = require('it-ndjson') -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-ndjson/package.json b/packages/it-ndjson/package.json index a1a043e2..b3cb8cb8 100644 --- a/packages/it-ndjson/package.json +++ b/packages/it-ndjson/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-ndjson#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-ndjson/test/index.spec.ts b/packages/it-ndjson/test/index.spec.ts index f58a7e4d..b31099dd 100644 --- a/packages/it-ndjson/test/index.spec.ts +++ b/packages/it-ndjson/test/index.spec.ts @@ -1,7 +1,7 @@ const test = require('ava') const ndjson = require('.') const { Buffer } = require('buffer') -const all = require('it-all') +import all from 'it-all' /** * @template T diff --git a/packages/it-parallel-batch/README.md b/packages/it-parallel-batch/README.md index ce191201..3eeb6da8 100644 --- a/packages/it-parallel-batch/README.md +++ b/packages/it-parallel-batch/README.md @@ -16,7 +16,7 @@ $ npm install --save it-parallel-batch ```javascript const parallelBatch = require('it-parallel-batch') -const all = require('it-all') +import all from 'it-all' const delay = require('delay') // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-parallel-batch/package.json b/packages/it-parallel-batch/package.json index 383f7ac7..3f3498f4 100644 --- a/packages/it-parallel-batch/package.json +++ b/packages/it-parallel-batch/package.json @@ -7,15 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel-batch#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "npm run build:dep:types && tsc --noEmit", - "build": "npm run build:types", - "build:dep:types": "cd node_modules/it-batch && npm run build:types", - "build:types": "npm run build:dep:types && tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-parallel-batch/test/index.spec.ts b/packages/it-parallel-batch/test/index.spec.ts index 3b590d1e..a7158388 100644 --- a/packages/it-parallel-batch/test/index.spec.ts +++ b/packages/it-parallel-batch/test/index.spec.ts @@ -2,7 +2,7 @@ const parallelBatch = require('../dist') const test = require('ava') -const all = require('it-all') +import all from 'it-all' const delay = require('delay') test('Should batch up emitted arrays', async (t) => { diff --git a/packages/it-parallel/README.md b/packages/it-parallel/README.md index b425f29f..b2855037 100644 --- a/packages/it-parallel/README.md +++ b/packages/it-parallel/README.md @@ -14,7 +14,7 @@ $ npm install --save it-parallel ```javascript const parallel = require('it-parallel') -const all = require('it-all') +import all from 'it-all' const delay = require('delay') // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-parallel/package.json b/packages/it-parallel/package.json index 46877202..95872803 100644 --- a/packages/it-parallel/package.json +++ b/packages/it-parallel/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-parallel/test/index.spec.ts b/packages/it-parallel/test/index.spec.ts index 80e5f7b1..68bbb582 100644 --- a/packages/it-parallel/test/index.spec.ts +++ b/packages/it-parallel/test/index.spec.ts @@ -2,7 +2,7 @@ const parallel = require('../dist') const test = require('ava') -const all = require('it-all') +import all from 'it-all' const delay = require('delay') const createFn = (ms, result) => { diff --git a/packages/it-peekable/package.json b/packages/it-peekable/package.json index d5897447..655a65f3 100644 --- a/packages/it-peekable/package.json +++ b/packages/it-peekable/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-peekable#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-peekable/test/index.spec.ts b/packages/it-peekable/test/index.spec.ts index 5faa3a10..5dd3b8fb 100644 --- a/packages/it-peekable/test/index.spec.ts +++ b/packages/it-peekable/test/index.spec.ts @@ -1,6 +1,6 @@ const peekableIt = require('./') const test = require('ava') -const all = require('it-all') +import all from 'it-all' test('Should peek at an iterable', async (t) => { const iterable = [0, 1, 2, 3] diff --git a/packages/it-reduce/package.json b/packages/it-reduce/package.json index 08181332..3874e523 100644 --- a/packages/it-reduce/package.json +++ b/packages/it-reduce/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-reduce#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-skip/README.md b/packages/it-skip/README.md index d83b2847..766ede0b 100644 --- a/packages/it-skip/README.md +++ b/packages/it-skip/README.md @@ -16,7 +16,7 @@ $ npm install --save it-skip ```javascript const take = require('it-skip') -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-skip/package.json b/packages/it-skip/package.json index 002c9a22..6f286041 100644 --- a/packages/it-skip/package.json +++ b/packages/it-skip/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-skip#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-skip/test/index.spec.ts b/packages/it-skip/test/index.spec.ts index 72c2fd6b..c902abc5 100644 --- a/packages/it-skip/test/index.spec.ts +++ b/packages/it-skip/test/index.spec.ts @@ -1,5 +1,5 @@ const skip = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') test('Should skip values from an iterable', async (t) => { diff --git a/packages/it-sort/README.md b/packages/it-sort/README.md index 712f0579..83da85a5 100644 --- a/packages/it-sort/README.md +++ b/packages/it-sort/README.md @@ -14,7 +14,7 @@ $ npm install --save it-sort ```javascript const sort = require('it-sort') -const all = require('it-all') +import all from 'it-all' const sorter = (a, b) => { return a.localeCompare(b) diff --git a/packages/it-sort/package.json b/packages/it-sort/package.json index 51158fe7..ae2edd62 100644 --- a/packages/it-sort/package.json +++ b/packages/it-sort/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-sort#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-sort/src/index.ts b/packages/it-sort/src/index.ts index eaa0162c..51cb2213 100644 --- a/packages/it-sort/src/index.ts +++ b/packages/it-sort/src/index.ts @@ -1,6 +1,6 @@ 'use strict' -const all = require('it-all') +import all from 'it-all' /** * Collects all values from an async iterator, sorts them diff --git a/packages/it-sort/test/index.spec.ts b/packages/it-sort/test/index.spec.ts index 36a224e7..042ce5e6 100644 --- a/packages/it-sort/test/index.spec.ts +++ b/packages/it-sort/test/index.spec.ts @@ -1,5 +1,5 @@ const sort = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') test('Should sort all entries of an array', async (t) => { diff --git a/packages/it-split/package.json b/packages/it-split/package.json index 80451b25..a6d5a92b 100644 --- a/packages/it-split/package.json +++ b/packages/it-split/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-split#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-split/test/index.spec.ts b/packages/it-split/test/index.spec.ts index 2182a084..48040a48 100644 --- a/packages/it-split/test/index.spec.ts +++ b/packages/it-split/test/index.spec.ts @@ -1,5 +1,5 @@ const split = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') const { toString } = require('uint8arrays/to-string') diff --git a/packages/it-take/README.md b/packages/it-take/README.md index 22a38d68..10d8ba84 100644 --- a/packages/it-take/README.md +++ b/packages/it-take/README.md @@ -16,7 +16,7 @@ $ npm install --save it-take ```javascript const take = require('it-take') -const all = require('it-all') +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-take/package.json b/packages/it-take/package.json index 3b74342f..e544bd55 100644 --- a/packages/it-take/package.json +++ b/packages/it-take/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-take#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-take/test/index.spec.ts b/packages/it-take/test/index.spec.ts index d4ccea24..f2147073 100644 --- a/packages/it-take/test/index.spec.ts +++ b/packages/it-take/test/index.spec.ts @@ -1,5 +1,5 @@ const take = require('./') -const all = require('it-all') +import all from 'it-all' const test = require('ava') test('Should limit the number of values returned from an iterable', async (t) => { diff --git a/packages/it-to-browser-readablestream/package.json b/packages/it-to-browser-readablestream/package.json index ba0f3abf..993fa3e2 100644 --- a/packages/it-to-browser-readablestream/package.json +++ b/packages/it-to-browser-readablestream/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-browser-readablestream#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage dist", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-to-buffer/package.json b/packages/it-to-buffer/package.json index 2378d8bd..3a643cda 100644 --- a/packages/it-to-buffer/package.json +++ b/packages/it-to-buffer/package.json @@ -7,14 +7,17 @@ "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-buffer#readme", "bugs": "https://github.com/achingbrain/it/issues", "scripts": { - "test": "ava", - "lint": "standard", - "coverage": "nyc --reporter html --reporter lcov ava", - "clean": "rm -rf .nyc_output coverage", - "check": "tsc --noEmit", - "build": "npm run build:types", - "build:types": "tsc --emitDeclarationOnly --declarationDir dist", - "prepublishOnly": "npm run build" + "build": "aegir build", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "clean": "aegir clean", + "test": "aegir test", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "release": "aegir release" }, "author": "Alex Potsides ", "license": "ISC", diff --git a/packages/it-to-buffer/test/index.spec.ts b/packages/it-to-buffer/test/index.spec.ts index 85fdc540..ce1746d4 100644 --- a/packages/it-to-buffer/test/index.spec.ts +++ b/packages/it-to-buffer/test/index.spec.ts @@ -1,4 +1,4 @@ -const toBuffer = require('./') +const toBuffer = require('../dist') const test = require('ava') test('Should turn a generator that yields buffers into a buffer', async (t) => { From e31629a3689902c99b166bc353994aae5152cf80 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 12:29:34 +0100 Subject: [PATCH 3/8] chore: tests passing --- .github/dependabot.yml | 11 + .github/workflows/automerge.yml | 8 + .github/workflows/js-test-and-release.yml | 145 ++++++ LICENSE | 4 + LICENSE-APACHE | 5 + LICENSE-MIT | 19 + README.md | 114 +++-- lerna.json | 14 +- package.json | 25 +- packages/blob-to-it/LICENSE | 4 + packages/blob-to-it/LICENSE-APACHE | 5 + packages/blob-to-it/LICENSE-MIT | 19 + packages/blob-to-it/README.md | 29 +- packages/blob-to-it/package.json | 136 +++++- packages/blob-to-it/tsconfig.json | 8 + packages/browser-readablestream-to-it/LICENSE | 4 + .../LICENSE-APACHE | 5 + .../browser-readablestream-to-it/LICENSE-MIT | 19 + .../browser-readablestream-to-it/README.md | 30 +- .../browser-readablestream-to-it/package.json | 134 +++++- .../browser-readablestream-to-it/src/index.ts | 2 +- .../test/index.spec.ts | 8 +- .../tsconfig.json | 5 + packages/it-all/LICENSE | 4 + packages/it-all/LICENSE-APACHE | 5 + packages/it-all/LICENSE-MIT | 19 + packages/it-all/README.md | 31 +- packages/it-all/package.json | 129 ++++- packages/it-batch/LICENSE | 4 + packages/it-batch/LICENSE-APACHE | 5 + packages/it-batch/LICENSE-MIT | 19 + packages/it-batch/README.md | 31 +- packages/it-batch/package.json | 131 ++++- packages/it-batch/src/index.ts | 16 +- packages/it-batch/test/index.spec.ts | 77 +-- packages/it-batch/tsconfig.json | 5 + packages/it-buffer-stream/LICENSE | 4 + packages/it-buffer-stream/LICENSE-APACHE | 5 + packages/it-buffer-stream/LICENSE-MIT | 19 + packages/it-buffer-stream/README.md | 29 +- packages/it-buffer-stream/package.json | 135 +++++- packages/it-buffer-stream/src/index.ts | 39 +- packages/it-buffer-stream/test/index.spec.ts | 130 ++--- packages/it-drain/LICENSE | 4 + packages/it-drain/LICENSE-APACHE | 5 + packages/it-drain/LICENSE-MIT | 19 + packages/it-drain/README.md | 31 +- packages/it-drain/package.json | 129 ++++- packages/it-drain/src/index.ts | 12 +- packages/it-drain/test/index.spec.ts | 26 +- packages/it-filter/LICENSE | 4 + packages/it-filter/LICENSE-APACHE | 5 + packages/it-filter/LICENSE-MIT | 19 + packages/it-filter/README.md | 29 +- packages/it-filter/package.json | 131 ++++- packages/it-filter/src/index.ts | 9 +- packages/it-filter/test/index.spec.ts | 24 +- packages/it-filter/tsconfig.json | 5 + packages/it-first/LICENSE | 4 + packages/it-first/LICENSE-APACHE | 5 + packages/it-first/LICENSE-MIT | 19 + packages/it-first/README.md | 31 +- packages/it-first/package.json | 129 ++++- packages/it-first/src/index.ts | 10 +- packages/it-first/test/index.spec.ts | 14 +- packages/it-flat-batch/LICENSE | 4 + packages/it-flat-batch/LICENSE-APACHE | 5 + packages/it-flat-batch/LICENSE-MIT | 19 + packages/it-flat-batch/README.md | 31 +- packages/it-flat-batch/package.json | 131 ++++- .../it-flat-batch/src/{ index.ts => index.ts} | 17 +- packages/it-flat-batch/test/index.spec.ts | 103 ++-- packages/it-flat-batch/tsconfig.json | 5 + packages/it-foreach/LICENSE | 4 + packages/it-foreach/LICENSE-APACHE | 5 + packages/it-foreach/LICENSE-MIT | 19 + packages/it-foreach/README.md | 29 +- packages/it-foreach/package.json | 131 ++++- packages/it-foreach/src/index.ts | 9 +- packages/it-foreach/test/index.spec.ts | 56 +-- packages/it-foreach/tsconfig.json | 5 + packages/it-glob/LICENSE | 4 + packages/it-glob/LICENSE-APACHE | 5 + packages/it-glob/LICENSE-MIT | 19 + packages/it-glob/README.md | 29 +- packages/it-glob/package.json | 139 +++++- packages/it-glob/src/index.ts | 50 +- packages/it-glob/test/index.spec.ts | 110 +++-- packages/it-glob/tsconfig.json | 5 + packages/it-last/LICENSE | 4 + packages/it-last/LICENSE-APACHE | 5 + packages/it-last/LICENSE-MIT | 19 + packages/it-last/README.md | 31 +- packages/it-last/package.json | 129 ++++- packages/it-last/src/index.ts | 11 +- packages/it-last/test/index.spec.ts | 22 +- packages/it-length/LICENSE | 4 + packages/it-length/LICENSE-APACHE | 5 + packages/it-length/LICENSE-MIT | 19 + packages/it-length/README.md | 31 +- packages/it-length/package.json | 129 ++++- packages/it-length/src/index.ts | 11 +- packages/it-length/test/index.spec.ts | 14 +- packages/it-map/LICENSE | 4 + packages/it-map/LICENSE-APACHE | 5 + packages/it-map/LICENSE-MIT | 19 + packages/it-map/README.md | 28 +- packages/it-map/package.json | 129 ++++- packages/it-map/src/index.ts | 13 +- packages/it-map/test/index.spec.ts | 36 +- packages/it-merge/LICENSE | 4 + packages/it-merge/LICENSE-APACHE | 5 + packages/it-merge/LICENSE-MIT | 19 + packages/it-merge/README.md | 31 +- packages/it-merge/package.json | 133 ++++- packages/it-merge/src/index.ts | 16 +- packages/it-merge/test/index.spec.ts | 16 +- packages/it-merge/tsconfig.json | 5 + packages/it-multipart/LICENSE | 4 + packages/it-multipart/LICENSE-APACHE | 5 + packages/it-multipart/LICENSE-MIT | 19 + packages/it-multipart/README.md | 31 +- packages/it-multipart/package.json | 140 +++++- packages/it-multipart/src/index.ts | 29 +- packages/it-multipart/test/index.spec.ts | 210 ++++---- packages/it-ndjson/LICENSE | 4 + packages/it-ndjson/LICENSE-APACHE | 5 + packages/it-ndjson/LICENSE-MIT | 19 + packages/it-ndjson/README.md | 27 +- packages/it-ndjson/package.json | 131 ++++- packages/it-ndjson/src/index.ts | 8 +- packages/it-ndjson/src/parse.ts | 8 +- packages/it-ndjson/src/stringify.ts | 7 +- packages/it-ndjson/test/index.spec.ts | 115 +++-- packages/it-ndjson/tsconfig.json | 5 + packages/it-parallel-batch/LICENSE | 4 + packages/it-parallel-batch/LICENSE-APACHE | 5 + packages/it-parallel-batch/LICENSE-MIT | 19 + packages/it-parallel-batch/README.md | 33 +- packages/it-parallel-batch/package.json | 144 +++++- packages/it-parallel-batch/src/index.ts | 36 +- packages/it-parallel-batch/test/index.spec.ts | 434 ++++++++--------- packages/it-parallel-batch/tsconfig.json | 8 + packages/it-parallel/LICENSE | 4 + packages/it-parallel/LICENSE-APACHE | 5 + packages/it-parallel/LICENSE-MIT | 19 + packages/it-parallel/README.md | 29 +- packages/it-parallel/package.json | 144 +++++- packages/it-parallel/src/index.ts | 44 +- packages/it-parallel/test/index.spec.ts | 454 +++++++++--------- packages/it-parallel/tsconfig.json | 5 + packages/it-peekable/LICENSE | 4 + packages/it-peekable/LICENSE-APACHE | 5 + packages/it-peekable/LICENSE-MIT | 19 + packages/it-peekable/README.md | 31 +- packages/it-peekable/package.json | 131 ++++- packages/it-peekable/src/index.ts | 59 +-- packages/it-peekable/test/index.spec.ts | 86 ++-- packages/it-peekable/tsconfig.json | 5 + packages/it-reduce/LICENSE | 4 + packages/it-reduce/LICENSE-APACHE | 5 + packages/it-reduce/LICENSE-MIT | 19 + packages/it-reduce/README.md | 31 +- packages/it-reduce/package.json | 129 ++++- packages/it-reduce/src/index.ts | 10 +- packages/it-reduce/test/index.spec.ts | 22 +- packages/it-skip/LICENSE | 4 + packages/it-skip/LICENSE-APACHE | 5 + packages/it-skip/LICENSE-MIT | 19 + packages/it-skip/README.md | 31 +- packages/it-skip/package.json | 131 ++++- packages/it-skip/src/index.ts | 12 +- packages/it-skip/test/index.spec.ts | 14 +- packages/it-skip/tsconfig.json | 5 + packages/it-sort/LICENSE | 4 + packages/it-sort/LICENSE-APACHE | 5 + packages/it-sort/LICENSE-MIT | 19 + packages/it-sort/README.md | 27 +- packages/it-sort/package.json | 131 ++++- packages/it-sort/src/index.ts | 14 +- packages/it-sort/test/index.spec.ts | 20 +- packages/it-sort/tsconfig.json | 5 + packages/it-split/LICENSE | 4 + packages/it-split/LICENSE-APACHE | 5 + packages/it-split/LICENSE-MIT | 19 + packages/it-split/README.md | 27 +- packages/it-split/package.json | 132 ++++- packages/it-split/src/index.ts | 21 +- packages/it-split/test/index.spec.ts | 63 +-- packages/it-split/tsconfig.json | 5 + packages/it-take/LICENSE | 4 + packages/it-take/LICENSE-APACHE | 5 + packages/it-take/LICENSE-MIT | 19 + packages/it-take/README.md | 31 +- packages/it-take/package.json | 131 ++++- packages/it-take/src/index.ts | 12 +- packages/it-take/test/index.spec.ts | 14 +- packages/it-take/tsconfig.json | 5 + packages/it-to-browser-readablestream/LICENSE | 4 + .../LICENSE-APACHE | 5 + .../it-to-browser-readablestream/LICENSE-MIT | 19 + .../it-to-browser-readablestream/README.md | 29 +- .../it-to-browser-readablestream/package.json | 132 ++++- .../it-to-browser-readablestream/src/index.ts | 31 +- .../test/index.spec.ts | 10 +- packages/it-to-buffer/LICENSE | 4 + packages/it-to-buffer/LICENSE-APACHE | 5 + packages/it-to-buffer/LICENSE-MIT | 19 + packages/it-to-buffer/README.md | 29 +- packages/it-to-buffer/package.json | 133 ++++- packages/it-to-buffer/src/index.ts | 9 +- packages/it-to-buffer/test/index.spec.ts | 38 +- 212 files changed, 6276 insertions(+), 1933 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/js-test-and-release.yml create mode 100644 LICENSE create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 packages/blob-to-it/LICENSE create mode 100644 packages/blob-to-it/LICENSE-APACHE create mode 100644 packages/blob-to-it/LICENSE-MIT create mode 100644 packages/browser-readablestream-to-it/LICENSE create mode 100644 packages/browser-readablestream-to-it/LICENSE-APACHE create mode 100644 packages/browser-readablestream-to-it/LICENSE-MIT create mode 100644 packages/it-all/LICENSE create mode 100644 packages/it-all/LICENSE-APACHE create mode 100644 packages/it-all/LICENSE-MIT create mode 100644 packages/it-batch/LICENSE create mode 100644 packages/it-batch/LICENSE-APACHE create mode 100644 packages/it-batch/LICENSE-MIT create mode 100644 packages/it-buffer-stream/LICENSE create mode 100644 packages/it-buffer-stream/LICENSE-APACHE create mode 100644 packages/it-buffer-stream/LICENSE-MIT create mode 100644 packages/it-drain/LICENSE create mode 100644 packages/it-drain/LICENSE-APACHE create mode 100644 packages/it-drain/LICENSE-MIT create mode 100644 packages/it-filter/LICENSE create mode 100644 packages/it-filter/LICENSE-APACHE create mode 100644 packages/it-filter/LICENSE-MIT create mode 100644 packages/it-first/LICENSE create mode 100644 packages/it-first/LICENSE-APACHE create mode 100644 packages/it-first/LICENSE-MIT create mode 100644 packages/it-flat-batch/LICENSE create mode 100644 packages/it-flat-batch/LICENSE-APACHE create mode 100644 packages/it-flat-batch/LICENSE-MIT rename packages/it-flat-batch/src/{ index.ts => index.ts} (61%) create mode 100644 packages/it-foreach/LICENSE create mode 100644 packages/it-foreach/LICENSE-APACHE create mode 100644 packages/it-foreach/LICENSE-MIT create mode 100644 packages/it-glob/LICENSE create mode 100644 packages/it-glob/LICENSE-APACHE create mode 100644 packages/it-glob/LICENSE-MIT create mode 100644 packages/it-last/LICENSE create mode 100644 packages/it-last/LICENSE-APACHE create mode 100644 packages/it-last/LICENSE-MIT create mode 100644 packages/it-length/LICENSE create mode 100644 packages/it-length/LICENSE-APACHE create mode 100644 packages/it-length/LICENSE-MIT create mode 100644 packages/it-map/LICENSE create mode 100644 packages/it-map/LICENSE-APACHE create mode 100644 packages/it-map/LICENSE-MIT create mode 100644 packages/it-merge/LICENSE create mode 100644 packages/it-merge/LICENSE-APACHE create mode 100644 packages/it-merge/LICENSE-MIT create mode 100644 packages/it-multipart/LICENSE create mode 100644 packages/it-multipart/LICENSE-APACHE create mode 100644 packages/it-multipart/LICENSE-MIT create mode 100644 packages/it-ndjson/LICENSE create mode 100644 packages/it-ndjson/LICENSE-APACHE create mode 100644 packages/it-ndjson/LICENSE-MIT create mode 100644 packages/it-parallel-batch/LICENSE create mode 100644 packages/it-parallel-batch/LICENSE-APACHE create mode 100644 packages/it-parallel-batch/LICENSE-MIT create mode 100644 packages/it-parallel/LICENSE create mode 100644 packages/it-parallel/LICENSE-APACHE create mode 100644 packages/it-parallel/LICENSE-MIT create mode 100644 packages/it-peekable/LICENSE create mode 100644 packages/it-peekable/LICENSE-APACHE create mode 100644 packages/it-peekable/LICENSE-MIT create mode 100644 packages/it-reduce/LICENSE create mode 100644 packages/it-reduce/LICENSE-APACHE create mode 100644 packages/it-reduce/LICENSE-MIT create mode 100644 packages/it-skip/LICENSE create mode 100644 packages/it-skip/LICENSE-APACHE create mode 100644 packages/it-skip/LICENSE-MIT create mode 100644 packages/it-sort/LICENSE create mode 100644 packages/it-sort/LICENSE-APACHE create mode 100644 packages/it-sort/LICENSE-MIT create mode 100644 packages/it-split/LICENSE create mode 100644 packages/it-split/LICENSE-APACHE create mode 100644 packages/it-split/LICENSE-MIT create mode 100644 packages/it-take/LICENSE create mode 100644 packages/it-take/LICENSE-APACHE create mode 100644 packages/it-take/LICENSE-MIT create mode 100644 packages/it-to-browser-readablestream/LICENSE create mode 100644 packages/it-to-browser-readablestream/LICENSE-APACHE create mode 100644 packages/it-to-browser-readablestream/LICENSE-MIT create mode 100644 packages/it-to-buffer/LICENSE create mode 100644 packages/it-to-buffer/LICENSE-APACHE create mode 100644 packages/it-to-buffer/LICENSE-MIT diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..0bc3b42d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..d57c2a02 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,8 @@ +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 00000000..d155996c --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,145 @@ +name: test & maybe release +on: + push: + branches: + - master # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - master # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-renderer + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-renderer + + release: + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_TOKEN }} + docker-username: ${{ secrets.DOCKER_USERNAME }} + - run: npm run --if-present release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 213d3a80..c791b991 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,83 @@ -# it - -Utility modules to make dealing with async iterators easier, some trivial, some not. - -* [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable -* [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable -* [it-all](./packages/it-all) Collect the contents of an iterable into an array -* [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays -* [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers -* [it-drain](./packages/it-drain) Consume an iterable and ignore any output -* [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function -* [it-first](./packages/it-first) Return the first item in an iterable -* [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length -* [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable -* [it-glob](./packages/it-glob) Glob matcher for file systems -* [it-last](./packages/it-last) Return the last item in an iterable -* [it-length](./packages/it-length) Consume an iterable and return its length -* [it-map](./packages/it-map) Map the output of an iterable -* [it-merge](./packages/it-merge) Treat multiple iterables as one -* [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable -* [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable -* [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit -* [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches -* [it-peekable](./packages/it-peekable) Peek/push an iterable -* [it-reduce](./packages/it-reduce) Reduce the output of an iterable -* [it-skip](./packages/it-skip) Skip items at the start of an iterable -* [it-sort](./packages/it-sort) Sort an iterable using a passed sort function -* [it-split](./packages/it-split) Split an iterable of buffers by linebreaks -* [it-take](./packages/it-take) Limit the number of items you want from an iterable -* [it-to-browser-readablestream](./packages/it-to-browser-readablestream) Turns an iterable into a WhatWG [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) -* [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them +# it + +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) + +> A collection of utilities for making working with iterables more bearable + +## Table of contents + +- [Structure](#structure) +- [License](#license) +- [Contribute](#contribute) + +## Structure + +- [`/packages/blob-to-it`](./packages/blob-to-it) Turns a blob into an async iterator +- [`/packages/browser-readablestream-to-it`](./packages/browser-readablestream-to-it) Turns a browser readble stream into an async iterator +- [`/packages/it-all`](./packages/it-all) Collects all values from an (async) iterable and returns them as an array +- [`/packages/it-batch`](./packages/it-batch) Takes an async iterator that emits things and emits them as fixed size batches +- [`/packages/it-buffer-stream`](./packages/it-buffer-stream) An async iterator that emits buffers containing bytes up to a certain length +- [`/packages/it-drain`](./packages/it-drain) Empties an async iterator +- [`/packages/it-filter`](./packages/it-filter) Filters the passed iterable by using the filter function +- [`/packages/it-first`](./packages/it-first) Returns the first result from an async iterator +- [`/packages/it-flat-batch`](./packages/it-flat-batch) Takes an async iterator that emits variable length arrays and emits them as fixed size batches +- [`/packages/it-foreach`](./packages/it-foreach) Invokes the passed function for each item in an iterable +- [`/packages/it-glob`](./packages/it-glob) Async iterable filename pattern matcher +- [`/packages/it-last`](./packages/it-last) Returns the last result from an async iterator +- [`/packages/it-length`](./packages/it-length) Counts the number of items in an async iterable +- [`/packages/it-map`](./packages/it-map) Maps the values yielded by an async iterator +- [`/packages/it-merge`](./packages/it-merge) Treat one or more iterables as a single iterable +- [`/packages/it-multipart`](./packages/it-multipart) Async iterable http multipart message parser +- [`/packages/it-ndjson`](./packages/it-ndjson) Parse iterators as ndjson and transform iterators to ndjson +- [`/packages/it-parallel`](./packages/it-parallel) Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input +- [`/packages/it-parallel-batch`](./packages/it-parallel-batch) Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input +- [`/packages/it-peekable`](./packages/it-peekable) Allows peeking/pushing an iterable +- [`/packages/it-reduce`](./packages/it-reduce) Reduces the values yielded from an async iterator +- [`/packages/it-skip`](./packages/it-skip) Skip items from an iterable +- [`/packages/it-sort`](./packages/it-sort) Collects all values from an async iterator, sorts them using the passed function and yields them +- [`/packages/it-split`](./packages/it-split) Splits Uint8Arrays emitted by an (async) iterable by a delimiter +- [`/packages/it-take`](./packages/it-take) Stop iteration after n items have been received +- [`/packages/it-to-browser-readablestream`](./packages/it-to-browser-readablestream) Takes an async iterator and turns it into a browser readable stream +- [`/packages/it-to-buffer`](./packages/it-to-buffer) Takes an async iterator that yields buffers and concatenates them all together + + + +- [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable +- [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable +- [it-all](./packages/it-all) Collect the contents of an iterable into an array +- [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays +- [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers +- [it-drain](./packages/it-drain) Consume an iterable and ignore any output +- [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function +- [it-first](./packages/it-first) Return the first item in an iterable +- [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length +- [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable +- [it-glob](./packages/it-glob) Glob matcher for file systems +- [it-last](./packages/it-last) Return the last item in an iterable +- [it-length](./packages/it-length) Consume an iterable and return its length +- [it-map](./packages/it-map) Map the output of an iterable +- [it-merge](./packages/it-merge) Treat multiple iterables as one +- [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable +- [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable +- [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit +- [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches +- [it-peekable](./packages/it-peekable) Peek/push an iterable +- [it-reduce](./packages/it-reduce) Reduce the output of an iterable +- [it-skip](./packages/it-skip) Skip items at the start of an iterable +- [it-sort](./packages/it-sort) Sort an iterable using a passed sort function +- [it-split](./packages/it-split) Split an iterable of buffers by linebreaks +- [it-take](./packages/it-take) Limit the number of items you want from an iterable +- [it-to-browser-readablestream](./packages/it-to-browser-readablestream) Turns an iterable into a WhatWG [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) +- [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/lerna.json b/lerna.json index 11274111..fe9f1a3a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,15 +1,13 @@ { - "lerna": "2.9.0", - "packages": [ - "packages/*" - ], + "lerna": "5.4.0", + "useWorkspaces": true, "version": "independent", "command": { - "bootstrap": { - "hoist": true - }, "run": { "stream": true } - } + }, + "packages": [ + "packages/*" + ] } diff --git a/package.json b/package.json index 33e119ec..592dc469 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,26 @@ "name": "it", "version": "1.0.0", "description": "A collection of utilities for making working with iterables more bearable", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/achingbrain/it#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "private": true, "scripts": { "postinstall": "lerna bootstrap", - "reset": "lerna run clean && rm -rf packages/*/node_modules packages/*/package-lock.json node_modules", + "reset": "rm -rf packages/*/dist packages/*/node_modules packages/*/package-lock.json node_modules package-lock.json", "test": "lerna run test", "coverage": "lerna run coverage", - "build": "lerna run build", + "build": "lerna exec -- tsc && lerna run build", "deploy": "lerna run deploy", "start": "NODE_ENV=development lerna run start", "clean": "lerna run clean", @@ -16,8 +29,10 @@ "check": "lerna run check", "publish": "lerna publish" }, - "devDependencies": { - "coveralls-lerna": "^0.0.5", + "dependencies": { "lerna": "^6.0.0" - } + }, + "workspaces": [ + "packages/*" + ] } diff --git a/packages/blob-to-it/LICENSE b/packages/blob-to-it/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/blob-to-it/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/blob-to-it/LICENSE-APACHE b/packages/blob-to-it/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/blob-to-it/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/blob-to-it/LICENSE-MIT b/packages/blob-to-it/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/blob-to-it/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/blob-to-it/README.md b/packages/blob-to-it/README.md index 701b0401..4106d040 100644 --- a/packages/blob-to-it/README.md +++ b/packages/blob-to-it/README.md @@ -1,13 +1,21 @@ -# blob-to-it +# blob-to-it -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-all)](https://david-dm.org/achingbrain/it?path=packages/it-all) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Turns a Blob into an async iterator +> Turns a blob into an async iterator + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save blob-to-it +```console +$ npm i blob-to-it ``` ## Usage @@ -22,3 +30,14 @@ const arr = await all(toIt(blob)) console.info(arr) // [ [ 0, 1, 2, 3, 4 ] ] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/blob-to-it/package.json b/packages/blob-to-it/package.json index 64f685d0..85762f86 100644 --- a/packages/blob-to-it/package.json +++ b/packages/blob-to-it/package.json @@ -2,36 +2,142 @@ "name": "blob-to-it", "version": "1.0.4", "description": "Turns a blob into an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/blob-to-it#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", "dep-check": "aegir dep-check", "clean": "aegir clean", - "test": "aegir test", - "test:node": "aegir test -t node --cov", + "test": "aegir test -t browser", "test:chrome": "aegir test -t browser --cov", "test:chrome-webworker": "aegir test -t webworker", "test:firefox": "aegir test -t browser -- --browser firefox", "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { - "browser-readablestream-to-it": "^1.0.3" + "browser-readablestream-to-it": "^1.0.0" }, "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/blob-to-it/tsconfig.json b/packages/blob-to-it/tsconfig.json index 13a35996..36fff505 100644 --- a/packages/blob-to-it/tsconfig.json +++ b/packages/blob-to-it/tsconfig.json @@ -6,5 +6,13 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../browser-readablestream-to-it" + }, + { + "path": "../it-all" + } ] } diff --git a/packages/browser-readablestream-to-it/LICENSE b/packages/browser-readablestream-to-it/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/browser-readablestream-to-it/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/browser-readablestream-to-it/LICENSE-APACHE b/packages/browser-readablestream-to-it/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/browser-readablestream-to-it/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/browser-readablestream-to-it/LICENSE-MIT b/packages/browser-readablestream-to-it/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/browser-readablestream-to-it/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/browser-readablestream-to-it/README.md b/packages/browser-readablestream-to-it/README.md index ce04003d..66aed4f9 100644 --- a/packages/browser-readablestream-to-it/README.md +++ b/packages/browser-readablestream-to-it/README.md @@ -1,13 +1,22 @@ -# browser-readablestream-to-it +# browser-readablestream-to-it -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-all)](https://david-dm.org/achingbrain/it?path=packages/it-all) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Turns a browser readable stream into an async iterator +> Turns a browser readble stream into an async iterator + +## Table of contents + +- [Install](#install) +- [Usage](#usage) + - [preventCancel](#preventcancel) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save browser-readablestream-to-it +```console +$ npm i browser-readablestream-to-it ``` ## Usage @@ -45,3 +54,14 @@ const arr = await all(toIt(stream, { preventCancel: true })) console.info(arr) // 0, 1, 2, 3, 4 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/browser-readablestream-to-it/package.json b/packages/browser-readablestream-to-it/package.json index dec0ae4b..ea47bd62 100644 --- a/packages/browser-readablestream-to-it/package.json +++ b/packages/browser-readablestream-to-it/package.json @@ -2,33 +2,139 @@ "name": "browser-readablestream-to-it", "version": "1.0.3", "description": "Turns a browser readble stream into an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/browser-readablestream-to-it#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", "dep-check": "aegir dep-check", "clean": "aegir clean", - "test": "aegir test", - "test:node": "aegir test -t node --cov", + "test": "aegir test -t browser", "test:chrome": "aegir test -t browser --cov", "test:chrome-webworker": "aegir test -t webworker", "test:firefox": "aegir test -t browser -- --browser firefox", "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/browser-readablestream-to-it/src/index.ts b/packages/browser-readablestream-to-it/src/index.ts index c9fb0bc6..01d1c600 100644 --- a/packages/browser-readablestream-to-it/src/index.ts +++ b/packages/browser-readablestream-to-it/src/index.ts @@ -10,7 +10,7 @@ export interface BrowserReadableStreamToItOptions { * prevent stream cancelling optional `{ preventCancel: true }` could be passed * as a second argument. */ -export default async function * browserReadableStreamToIt (stream: ReadableStream, options: BrowserReadableStreamToItOptions = {}): AsyncGenerator { +export default async function * browserReadableStreamToIt (stream: ReadableStream, options: BrowserReadableStreamToItOptions = {}): AsyncGenerator { const reader = stream.getReader() try { diff --git a/packages/browser-readablestream-to-it/test/index.spec.ts b/packages/browser-readablestream-to-it/test/index.spec.ts index 770879a5..dd02041c 100644 --- a/packages/browser-readablestream-to-it/test/index.spec.ts +++ b/packages/browser-readablestream-to-it/test/index.spec.ts @@ -55,7 +55,7 @@ describe('browser-readablestream-to-it', () => { it('should cancel stream', async () => { const source = [1, 2, 3, 4, 5] - const cancel = [] + const cancel: any = [] const stream = new ReadableStream({ pull (controller) { controller.enqueue(source.shift()) @@ -83,7 +83,7 @@ describe('browser-readablestream-to-it', () => { it('should not cancel stream if preventCancel is set', async () => { const source = [1, 2, 3, 4, 5] - const cancel = [] + const cancel: any = [] const stream = new ReadableStream({ pull (controller) { controller.enqueue(source.shift()) @@ -111,7 +111,7 @@ describe('browser-readablestream-to-it', () => { it('error cancels the stream', async () => { const source = [1, 2, 3, 4, 5] - const cancel = [] + const cancel: any = [] const stream = new ReadableStream({ pull (controller) { controller.enqueue(source.shift()) @@ -141,7 +141,7 @@ describe('browser-readablestream-to-it', () => { it('error does not cancels the stream if preventCancel is set', async () => { const source = [1, 2, 3, 4, 5] - const cancel = [] + const cancel: any = [] const stream = new ReadableStream({ pull (controller) { controller.enqueue(source.shift()) diff --git a/packages/browser-readablestream-to-it/tsconfig.json b/packages/browser-readablestream-to-it/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/browser-readablestream-to-it/tsconfig.json +++ b/packages/browser-readablestream-to-it/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-all/LICENSE b/packages/it-all/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-all/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-all/LICENSE-APACHE b/packages/it-all/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-all/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-all/LICENSE-MIT b/packages/it-all/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-all/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-all/README.md b/packages/it-all/README.md index 786524ef..d9f96421 100644 --- a/packages/it-all/README.md +++ b/packages/it-all/README.md @@ -1,17 +1,25 @@ -# it-all +# it-all -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-all)](https://david-dm.org/achingbrain/it?path=packages/it-all) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Collects all values from an (async) iterable into an array and returns it. +> Collects all values from an (async) iterable and returns them as an array -For when you need a one-liner to collect iterable values. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-all +```console +$ npm i it-all ``` +For when you need a one-liner to collect iterable values. + ## Usage ```javascript @@ -24,3 +32,14 @@ const arr = await all(values) console.info(arr) // 0, 1, 2, 3, 4 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-all/package.json b/packages/it-all/package.json index be415e2b..e2f24b29 100644 --- a/packages/it-all/package.json +++ b/packages/it-all/package.json @@ -2,10 +2,125 @@ "name": "it-all", "version": "1.0.6", "description": "Collects all values from an (async) iterable and returns them as an array", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-all#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-batch/LICENSE b/packages/it-batch/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-batch/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-batch/LICENSE-APACHE b/packages/it-batch/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-batch/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-batch/LICENSE-MIT b/packages/it-batch/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-batch/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-batch/README.md b/packages/it-batch/README.md index aa23a2fd..9218f12f 100644 --- a/packages/it-batch/README.md +++ b/packages/it-batch/README.md @@ -1,17 +1,25 @@ -# it-batch +# it-batch -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-batch)](https://david-dm.org/achingbrain/it?path=packages/it-batch) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Takes an (async) iterable that emits things and returns an async iterable that emits those things in fixed-sized batches. +> Takes an async iterator that emits things and emits them as fixed size batches -The final batch may be smaller than the max. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-batch +```console +$ npm i it-batch ``` +The final batch may be smaller than the max. + ## Usage ```javascript @@ -26,3 +34,14 @@ const result = await all(batch(values, batchSize)) console.info(result) // [0, 1], [2, 3], [4] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-batch/package.json b/packages/it-batch/package.json index aad7b562..577aaf55 100644 --- a/packages/it-batch/package.json +++ b/packages/it-batch/package.json @@ -2,10 +2,125 @@ "name": "it-batch", "version": "1.0.9", "description": "Takes an async iterator that emits things and emits them as fixed size batches", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-batch#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-batch/src/index.ts b/packages/it-batch/src/index.ts index a9829c7b..1faa8df3 100644 --- a/packages/it-batch/src/index.ts +++ b/packages/it-batch/src/index.ts @@ -1,17 +1,9 @@ -'use strict' - /** * Takes an (async) iterable that emits things and returns an async iterable that - * emits those things in fixed-sized batches. - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {number} [size=1] - * @returns {AsyncIterable} + * emits those things in fixed-sized batches */ -async function * batch (source, size = 1) { - /** @type {T[]} */ - let things = [] +export default async function * batch (source: AsyncIterable | Iterable, size: number = 1): AsyncGenerator { + let things: T[] = [] if (size < 1) { size = 1 @@ -33,5 +25,3 @@ async function * batch (source, size = 1) { things = things.slice(size) } } - -module.exports = batch diff --git a/packages/it-batch/test/index.spec.ts b/packages/it-batch/test/index.spec.ts index 3e46b4e1..a9bbd23d 100644 --- a/packages/it-batch/test/index.spec.ts +++ b/packages/it-batch/test/index.spec.ts @@ -1,50 +1,55 @@ -const batch = require('../dist') -const test = require('ava') +/* eslint-env mocha */ + +import batch from '../src/index.js' +import { expect } from 'aegir/chai' import all from 'it-all' -test('Should batch up entries', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = 2 - const res = await all(batch(values, batchSize)) +describe('it-batch', () => { + it('should batch up entries', async () => { + const values = [0, 1, 2, 3, 4] + const batchSize = 2 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) -}) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) -test('Should batch up entries without batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const res = await all(batch(values)) + it('should batch up entries without batch size', async () => { + const values = [0, 1, 2, 3, 4] + const res = await all(batch(values)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with negative batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = -1 - const res = await all(batch(values, batchSize)) + it('should batch up entries with negative batch size', async () => { + const values = [0, 1, 2, 3, 4] + const batchSize = -1 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with zero batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = 0 - const res = await all(batch(values, batchSize)) + it('should batch up entries with zero batch size', async () => { + const values = [0, 1, 2, 3, 4] + const batchSize = 0 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with string batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = '2' - const res = await all(batch(values, batchSize)) + it('should batch up entries with string batch size', async () => { + const values = [0, 1, 2, 3, 4] + const batchSize = '2' + // @ts-expect-error batchSize type is incorrect + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) -}) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) -test('Should batch up entries with non-integer batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = 2.5 - const res = await all(batch(values, batchSize)) + it('should batch up entries with non-integer batch size', async () => { + const values = [0, 1, 2, 3, 4] + const batchSize = 2.5 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) }) diff --git a/packages/it-batch/tsconfig.json b/packages/it-batch/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-batch/tsconfig.json +++ b/packages/it-batch/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-buffer-stream/LICENSE b/packages/it-buffer-stream/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-buffer-stream/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-buffer-stream/LICENSE-APACHE b/packages/it-buffer-stream/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-buffer-stream/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-buffer-stream/LICENSE-MIT b/packages/it-buffer-stream/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-buffer-stream/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-buffer-stream/README.md b/packages/it-buffer-stream/README.md index a5453837..fd4d4066 100644 --- a/packages/it-buffer-stream/README.md +++ b/packages/it-buffer-stream/README.md @@ -1,13 +1,21 @@ -# it-buffer-stream +# it-buffer-stream -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-buffer-stream)](https://david-dm.org/achingbrain/it?path=packages/it-buffer-stream) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> An async iterable that emits buffers containing bytes up to a certain length +> An async iterator that emits buffers containing bytes up to a certain length + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-buffer-stream +```console +$ npm i it-buffer-stream ``` ## Usage @@ -37,3 +45,14 @@ for await (buf of bufferStream(totalLength, options)) { // `buffers` is an array of Buffers the combined length of which === totalLength ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-buffer-stream/package.json b/packages/it-buffer-stream/package.json index 3651704f..2e04c78d 100644 --- a/packages/it-buffer-stream/package.json +++ b/packages/it-buffer-stream/package.json @@ -2,10 +2,125 @@ "name": "it-buffer-stream", "version": "2.0.2", "description": "An async iterator that emits buffers containing bytes up to a certain length", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-buffer-stream#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,19 +134,11 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", - "devDependencies": { - "aegir": "^37.5.0", - "uint8arrays": "^4.0.2" - }, "dependencies": { "iso-random-stream": "^1.1.1" }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "devDependencies": { + "aegir": "^37.5.0", + "uint8arrays": "^4.0.2" } } diff --git a/packages/it-buffer-stream/src/index.ts b/packages/it-buffer-stream/src/index.ts index 524d953b..833f3dd8 100644 --- a/packages/it-buffer-stream/src/index.ts +++ b/packages/it-buffer-stream/src/index.ts @@ -1,38 +1,23 @@ -'use strict' +// @ts-expect-error - untyped dependency +import randomBytes from 'iso-random-stream/src/random.js' -// @ts-ignore - untyped dependency -const randomBytes = require('iso-random-stream/src/random') - -/** - * @typedef {Object} Options - * @property {number} [chunkSize] - * @property {function(Uint8Array):void} [collector] - * @property {function(number):Promise|Uint8Array} [generator] - */ - -/** - * @typedef {Object} ActualOptions - * @property {number} chunkSize - * @property {function(Uint8Array):void} collector - * @property {function(number):Promise|Uint8Array} generator - */ +export interface BufferStreamOptions { + chunkSize?: number + collector?: (arr: Uint8Array) => void + generator?: (lenght: number) => Uint8Array | Promise +} -/** @type {ActualOptions} */ -const defaultOptions = { +const defaultOptions: Required = { chunkSize: 4096, collector: () => {}, generator: (size) => Promise.resolve(randomBytes(size)) } /** - * An async iterable that emits buffers containing bytes up to a certain length. - * - * @param {number} limit - * @param {Options} [options] + * An async iterable that emits buffers containing bytes up to a certain length */ -async function * bufferStream (limit, options = {}) { - /** @type {ActualOptions} */ - const opts = Object.assign({}, defaultOptions, options) +export default async function * bufferStream (limit: number, options: BufferStreamOptions = {}) { + const opts: Required = Object.assign({}, defaultOptions, options) let emitted = 0 const arr = [] @@ -56,5 +41,3 @@ async function * bufferStream (limit, options = {}) { yield bytes } } - -module.exports = bufferStream diff --git a/packages/it-buffer-stream/test/index.spec.ts b/packages/it-buffer-stream/test/index.spec.ts index f97b4635..c43725c5 100644 --- a/packages/it-buffer-stream/test/index.spec.ts +++ b/packages/it-buffer-stream/test/index.spec.ts @@ -1,87 +1,89 @@ -const bufferStream = require('./') -const test = require('ava') -const { concat: uint8ArrayConcat } = require('uint8arrays/concat') +import { expect } from 'aegir/chai' +import { concat as uint8ArrayConcat } from 'uint8arrays/concat' +import bufferStream from '../src/index.js' -test('Should emit bytes', async (t) => { - const expected = 100 - const buffers = [] +describe('it-buffer-stream', () => { + it('should emit bytes', async () => { + const expected = 100 + const buffers = [] - for await (const buf of bufferStream(expected)) { - buffers.push(buf) - } + for await (const buf of bufferStream(expected)) { + buffers.push(buf) + } - t.is(buffers.length, 1) - t.is(buffers[0].length, expected) -}) + expect(buffers).to.have.lengthOf(1) + expect(buffers[0]).to.have.lengthOf(expected) + }) -test('Should emit a number of buffers', async (t) => { - const expected = 100 - const chunkSize = 10 - const buffers = [] + it('should emit a number of buffers', async () => { + const expected = 100 + const chunkSize = 10 + const buffers = [] - for await (const buf of bufferStream(expected, { - chunkSize - })) { - buffers.push(buf) - } + for await (const buf of bufferStream(expected, { + chunkSize + })) { + buffers.push(buf) + } - t.is(buffers.length, 10) - t.is(buffers[0].length, expected / chunkSize) + expect(buffers).to.have.lengthOf(10) + expect(buffers[0]).to.have.lengthOf(expected / chunkSize) - const total = buffers.reduce((acc, cur) => acc + cur.length, 0) + const total = buffers.reduce((acc, cur) => acc + cur.length, 0) - t.is(expected, total) -}) + expect(expected).to.equal(total) + }) -test('Should allow collection of buffers', async (t) => { - const expected = 100 - let emitted = new Uint8Array(0) - const buffers = [] + it('should allow collection of buffers', async () => { + const expected = 100 + let emitted = new Uint8Array(0) + const buffers = [] - for await (const buf of bufferStream(expected, { - collector: (buffer) => { - emitted = uint8ArrayConcat([emitted, buffer]) + for await (const buf of bufferStream(expected, { + collector: (buffer) => { + emitted = uint8ArrayConcat([emitted, buffer]) + } + })) { + buffers.push(buf) } - })) { - buffers.push(buf) - } - t.deepEqual(Uint8Array.from(emitted), Uint8Array.from(buffers[0])) -}) + expect(Uint8Array.from(emitted)).to.equalBytes(Uint8Array.from(buffers[0])) + }) -test('Should allow generation of buffers', async (t) => { - const expected = 100 - let emitted = new Uint8Array(0) - const buffers = [] + it('should allow generation of buffers', async () => { + const expected = 100 + let emitted = new Uint8Array(0) + const buffers = [] - for await (const buf of bufferStream(expected, { - generator: (size) => { - const output = new Uint8Array(size) - emitted = uint8ArrayConcat([emitted, output]) + for await (const buf of bufferStream(expected, { + generator: (size) => { + const output = new Uint8Array(size) + emitted = uint8ArrayConcat([emitted, output]) - return output + return output + } + })) { + buffers.push(buf) } - })) { - buffers.push(buf) - } - t.deepEqual(emitted, buffers[0]) -}) + expect(emitted).to.equalBytes(buffers[0]) + }) -test('Should propagate byte generation errors', async (t) => { - const generationError = new Error('Urk!') + it('should propagate byte generation errors', async () => { + const generationError = new Error('Urk!') + + try { + for await (const _ of bufferStream(5, { // eslint-disable-line no-unused-vars + generator: async () => { + throw generationError + } + })) { // eslint-disable-line no-empty - try { - for await (const _ of bufferStream(5, { // eslint-disable-line no-unused-vars - generator: async () => { - throw generationError } - })) { // eslint-disable-line no-empty + throw new Error('No error was thrown') + } catch (err) { + expect(err).to.equal(generationError) } - - throw new Error('No error was thrown') - } catch (err) { - t.is(err, generationError) - } + }) }) diff --git a/packages/it-drain/LICENSE b/packages/it-drain/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-drain/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-drain/LICENSE-APACHE b/packages/it-drain/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-drain/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-drain/LICENSE-MIT b/packages/it-drain/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-drain/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-drain/README.md b/packages/it-drain/README.md index e8e379b3..3430aa46 100644 --- a/packages/it-drain/README.md +++ b/packages/it-drain/README.md @@ -1,17 +1,25 @@ -# it-drain +# it-drain -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml/) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-drain)](https://david-dm.org/achingbrain/it?path=packages/it-drain) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Drains an (async) iterable discarding its content and does not return anything. +> Empties an async iterator -Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-drain +```console +$ npm i it-drain ``` +Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values. + ## Usage ```javascript @@ -22,3 +30,14 @@ const values = [0, 1, 2, 3, 4] await drain(values) ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-drain/package.json b/packages/it-drain/package.json index b452b731..2851a828 100644 --- a/packages/it-drain/package.json +++ b/packages/it-drain/package.json @@ -2,10 +2,125 @@ "name": "it-drain", "version": "1.0.5", "description": "Empties an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-drain#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-drain/src/index.ts b/packages/it-drain/src/index.ts index 86fb80fa..5ec17508 100644 --- a/packages/it-drain/src/index.ts +++ b/packages/it-drain/src/index.ts @@ -1,15 +1,7 @@ -'use strict' - /** * Drains an (async) iterable discarding its' content and does not return - * anything. - * - * @template T - * @param {AsyncIterable|Iterable} source - * @returns {Promise} + * anything */ -const drain = async (source) => { +export default async function drain (source: AsyncIterable|Iterable): Promise { for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty } - -module.exports = drain diff --git a/packages/it-drain/test/index.spec.ts b/packages/it-drain/test/index.spec.ts index 8f9abbdb..594dbd9f 100644 --- a/packages/it-drain/test/index.spec.ts +++ b/packages/it-drain/test/index.spec.ts @@ -1,16 +1,18 @@ -const drain = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import drain from '../src/index.js' -test('Should empty an async iterator', async (t) => { - let done = false - const iter = function * () { - yield 1 - yield 2 - yield 3 - done = true - } +describe('it-drain', () => { + it('should empty an async iterator', async () => { + let done = false + const iter = function * () { + yield 1 + yield 2 + yield 3 + done = true + } - await drain(iter()) + await drain(iter()) - t.truthy(done) + expect(done).to.be.true() + }) }) diff --git a/packages/it-filter/LICENSE b/packages/it-filter/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-filter/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-filter/LICENSE-APACHE b/packages/it-filter/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-filter/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-filter/LICENSE-MIT b/packages/it-filter/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-filter/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-filter/README.md b/packages/it-filter/README.md index 6e45d1f8..1d35e2ab 100644 --- a/packages/it-filter/README.md +++ b/packages/it-filter/README.md @@ -1,13 +1,21 @@ -# it-filter +# it-filter -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-all)](https://david-dm.org/achingbrain/it?path=packages/it-all) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Filters the passed (async) iterable by using the filter function +> Filters the passed iterable by using the filter function + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-filter +```console +$ npm i it-filter ``` ## Usage @@ -25,3 +33,14 @@ const arr = await all(filter(values, fn)) console.info(arr) // 3, 4 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-filter/package.json b/packages/it-filter/package.json index 5ef43fa3..6a7a44d5 100644 --- a/packages/it-filter/package.json +++ b/packages/it-filter/package.json @@ -2,10 +2,125 @@ "name": "it-filter", "version": "1.0.3", "description": "Filters the passed iterable by using the filter function", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-filter#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-filter/src/index.ts b/packages/it-filter/src/index.ts index bfbac0e6..9f833cbf 100644 --- a/packages/it-filter/src/index.ts +++ b/packages/it-filter/src/index.ts @@ -1,18 +1,11 @@ -'use strict' /** * Filters the passed (async) iterable by using the filter function - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {function(T):boolean|Promise} fn */ -const filter = async function * (source, fn) { +export default async function * filter (source: AsyncIterable|Iterable, fn: (val: T) => boolean|Promise): AsyncGenerator { for await (const entry of source) { if (await fn(entry)) { yield entry } } } - -module.exports = filter diff --git a/packages/it-filter/test/index.spec.ts b/packages/it-filter/test/index.spec.ts index 97f4387a..1efebf08 100644 --- a/packages/it-filter/test/index.spec.ts +++ b/packages/it-filter/test/index.spec.ts @@ -1,19 +1,21 @@ +import { expect } from 'aegir/chai' import all from 'it-all' -const filter = require('./') -const test = require('ava') +import filter from '../src/index.js' -test('Should filter all values greater than 2', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-filter', () => { + it('should filter all values greater than 2', async () => { + const values = [0, 1, 2, 3, 4] - const res = await all(filter(values, val => val > 2)) + const res = await all(filter(values, val => val > 2)) - t.deepEqual(res, [3, 4]) -}) + expect(res).to.deep.equal([3, 4]) + }) -test('Should filter all values greater than 2 with a promise', async (t) => { - const values = [0, 1, 2, 3, 4] + it('should filter all values greater than 2 with a promise', async () => { + const values = [0, 1, 2, 3, 4] - const res = await all(filter(values, async val => val > 2)) + const res = await all(filter(values, async val => val > 2)) - t.deepEqual(res, [3, 4]) + expect(res).to.deep.equal([3, 4]) + }) }) diff --git a/packages/it-filter/tsconfig.json b/packages/it-filter/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-filter/tsconfig.json +++ b/packages/it-filter/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-first/LICENSE b/packages/it-first/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-first/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-first/LICENSE-APACHE b/packages/it-first/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-first/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-first/LICENSE-MIT b/packages/it-first/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-first/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-first/README.md b/packages/it-first/README.md index 3e03abf9..dc59df57 100644 --- a/packages/it-first/README.md +++ b/packages/it-first/README.md @@ -1,17 +1,25 @@ -# it-first +# it-first -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-first)](https://david-dm.org/achingbrain/it?path=packages/it-first) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Returns the first result from an (async) iterable. +> Returns the first result from an async iterator -Mostly useful for tests. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-first +```console +$ npm i it-first ``` +Mostly useful for tests. + ## Usage ```javascript @@ -24,3 +32,14 @@ const res = await first(values) console.info(res) // 0 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-first/package.json b/packages/it-first/package.json index 5c1a18db..eada4313 100644 --- a/packages/it-first/package.json +++ b/packages/it-first/package.json @@ -2,10 +2,125 @@ "name": "it-first", "version": "1.0.7", "description": "Returns the first result from an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-first#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-first/src/index.ts b/packages/it-first/src/index.ts index 1fb5198a..631ce02b 100644 --- a/packages/it-first/src/index.ts +++ b/packages/it-first/src/index.ts @@ -1,18 +1,12 @@ -'use strict' /** * Returns the first result from an (async) iterable, unless empty, in which - * case returns `undefined`. - * - * @template T - * @param {AsyncIterable|Iterable} source + * case returns `undefined` */ -const first = async (source) => { +export default async function first (source: AsyncIterable|Iterable): Promise { for await (const entry of source) { // eslint-disable-line no-unreachable-loop return entry } return undefined } - -module.exports = first diff --git a/packages/it-first/test/index.spec.ts b/packages/it-first/test/index.spec.ts index dcdc6f0d..b86a91cb 100644 --- a/packages/it-first/test/index.spec.ts +++ b/packages/it-first/test/index.spec.ts @@ -1,10 +1,12 @@ -const first = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import first from '../src/index.js' -test('Should return only the first result from an async iterator', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-first', () => { + it('should return only the first result from an async iterator', async () => { + const values = [0, 1, 2, 3, 4] - const res = await first(values) + const res = await first(values) - t.is(res, 0) + expect(res).to.equal(0) + }) }) diff --git a/packages/it-flat-batch/LICENSE b/packages/it-flat-batch/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-flat-batch/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-flat-batch/LICENSE-APACHE b/packages/it-flat-batch/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-flat-batch/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-flat-batch/LICENSE-MIT b/packages/it-flat-batch/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-flat-batch/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-flat-batch/README.md b/packages/it-flat-batch/README.md index 8c8642ae..b0d01f89 100644 --- a/packages/it-flat-batch/README.md +++ b/packages/it-flat-batch/README.md @@ -1,17 +1,25 @@ -# it-flat-batch +# it-flat-batch -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-flat-batch)](https://david-dm.org/achingbrain/it?path=packages/it-flat-batch) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Takes an (async) iterable that emits variable length arrays of things and returns an async iterable that emits those thnigs in fixed-size batches. +> Takes an async iterator that emits variable length arrays and emits them as fixed size batches -The final batch may be smaller than requested batch size. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-flat-batch +```console +$ npm i it-flat-batch ``` +The final batch may be smaller than requested batch size. + ## Usage ```javascript @@ -26,3 +34,14 @@ const result = await all(batch(values, batchSize)) console.info(result) // [0, 1], [2, 3], [4] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-flat-batch/package.json b/packages/it-flat-batch/package.json index 5a91ab2b..0d497da0 100644 --- a/packages/it-flat-batch/package.json +++ b/packages/it-flat-batch/package.json @@ -2,10 +2,125 @@ "name": "it-flat-batch", "version": "1.0.7", "description": "Takes an async iterator that emits variable length arrays and emits them as fixed size batches", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-flat-batch#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-flat-batch/src/ index.ts b/packages/it-flat-batch/src/index.ts similarity index 61% rename from packages/it-flat-batch/src/ index.ts rename to packages/it-flat-batch/src/index.ts index 3fa6fee2..235ef578 100644 --- a/packages/it-flat-batch/src/ index.ts +++ b/packages/it-flat-batch/src/index.ts @@ -1,24 +1,17 @@ -'use strict' /** * Takes an (async) iterable that emits variable length arrays of things and - * returns an async iterable that emits those things in fixed-size batches. - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {number|string} [batchSize=1] - * @returns {AsyncIterable} + * returns an async iterable that emits those things in fixed-size batches */ -async function * batch (source, batchSize) { - // @ts-ignore - expects string not a number +export default async function * batch (source: AsyncIterable|Iterable, batchSize: number = 1): AsyncGenerator { + // @ts-expect-error - expects string not a number let size = parseInt(batchSize) if (isNaN(size) || size < 1) { size = 1 } - /** @type {T[]} */ - let things = [] + let things: T[] = [] for await (const set of source) { things = things.concat(set) @@ -36,5 +29,3 @@ async function * batch (source, batchSize) { things = things.slice(size) } } - -module.exports = batch diff --git a/packages/it-flat-batch/test/index.spec.ts b/packages/it-flat-batch/test/index.spec.ts index cc1b2893..cec0d70f 100644 --- a/packages/it-flat-batch/test/index.spec.ts +++ b/packages/it-flat-batch/test/index.spec.ts @@ -1,70 +1,73 @@ -const batch = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' import all from 'it-all' +import batch from '../src/index.js' -test('Should batch up emitted arrays', async (t) => { - const values = [[0, 1, 2], [3], [4]] - const res = await all(batch(values, 2)) +describe('it-batch', () => { + it('should batch up emitted arrays', async () => { + const values = [[0, 1, 2], [3], [4]] + const res = await all(batch(values, 2)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) -}) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) -test('Should batch up emitted arrays in singles', async (t) => { - const values = [[0, 1, 2], [3], [4]] - const res = await all(batch(values, 1)) + it('should batch up emitted arrays in singles', async () => { + const values = [[0, 1, 2], [3], [4]] + const res = await all(batch(values, 1)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up emitted arrays in one array', async (t) => { - const values = [[0, 1, 2], [3], [4]] - const res = await all(batch(values, 100)) + it('should batch up emitted arrays in one array', async () => { + const values = [[0, 1, 2], [3], [4]] + const res = await all(batch(values, 100)) - t.deepEqual(res, [[0, 1, 2, 3, 4]]) -}) + expect(res).to.deep.equal([[0, 1, 2, 3, 4]]) + }) -test('Should batch up emitted arrays in small arrays', async (t) => { - const values = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] - const res = await all(batch(values, 1)) + it('should batch up emitted arrays in small arrays', async () => { + const values = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] + const res = await all(batch(values, 1)) - t.deepEqual(res, [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) + }) -test('Should batch up emitted arrays when no batch size is passed', async (t) => { - const values = [[0, 1, 2], [3], [4]] - const res = await all(batch(values)) + it('should batch up emitted arrays when no batch size is passed', async () => { + const values = [[0, 1, 2], [3], [4]] + const res = await all(batch(values)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with negative batch size', async (t) => { - const values = [0, 1, 2, 3, 4] - const batchSize = -1 - const res = await all(batch(values, batchSize)) + it('should batch up entries with negative batch size', async () => { + const values = [[0, 1, 2], [3], [4]] + const batchSize = -1 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with zero batch size', async (t) => { - const values = [[0, 1, 2], [3, 4]] - const batchSize = 0 - const res = await all(batch(values, batchSize)) + it('should batch up entries with zero batch size', async () => { + const values = [[0, 1, 2], [3, 4]] + const batchSize = 0 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0], [1], [2], [3], [4]]) -}) + expect(res).to.deep.equal([[0], [1], [2], [3], [4]]) + }) -test('Should batch up entries with string batch size', async (t) => { - const values = [[0, 1, 2], [3, 4]] - const batchSize = '2' - const res = await all(batch(values, batchSize)) + it('should batch up entries with string batch size', async () => { + const values = [[0, 1, 2], [3, 4]] + const batchSize = '2' + // @ts-expect-error batchSize type is wrong + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) -}) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) -test('Should batch up entries with non-integer batch size', async (t) => { - const values = [[0, 1, 2], [3, 4]] - const batchSize = 2.5 - const res = await all(batch(values, batchSize)) + it('should batch up entries with non-integer batch size', async () => { + const values = [[0, 1, 2], [3, 4]] + const batchSize = 2.5 + const res = await all(batch(values, batchSize)) - t.deepEqual(res, [[0, 1], [2, 3], [4]]) + expect(res).to.deep.equal([[0, 1], [2, 3], [4]]) + }) }) diff --git a/packages/it-flat-batch/tsconfig.json b/packages/it-flat-batch/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-flat-batch/tsconfig.json +++ b/packages/it-flat-batch/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-foreach/LICENSE b/packages/it-foreach/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-foreach/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-foreach/LICENSE-APACHE b/packages/it-foreach/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-foreach/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-foreach/LICENSE-MIT b/packages/it-foreach/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-foreach/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-foreach/README.md b/packages/it-foreach/README.md index 71b7a5fd..8294d2ed 100644 --- a/packages/it-foreach/README.md +++ b/packages/it-foreach/README.md @@ -1,17 +1,25 @@ -# it-foreach +# it-foreach -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-foreach)](https://david-dm.org/achingbrain/it?path=packages/it-foreach) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Invokes the passed function for each item in an iterable -For when you need a one-liner to collect iterable values. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-foreach +```console +$ npm i it-foreach ``` +For when you need a one-liner to collect iterable values. + ## Usage ```javascript @@ -26,3 +34,14 @@ const arr = await drain( each(values, console.info) ) ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-foreach/package.json b/packages/it-foreach/package.json index 8321c270..9c89862c 100644 --- a/packages/it-foreach/package.json +++ b/packages/it-foreach/package.json @@ -2,10 +2,125 @@ "name": "it-foreach", "version": "0.1.1", "description": "Invokes the passed function for each item in an iterable", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-foreach#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-foreach/src/index.ts b/packages/it-foreach/src/index.ts index ce5f3daf..6c8d7979 100644 --- a/packages/it-foreach/src/index.ts +++ b/packages/it-foreach/src/index.ts @@ -1,17 +1,10 @@ -'use strict' /** * Invokes the passed function for each item in an iterable - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {(thing: T) => void | Promise} fn */ -const each = async function * (source, fn) { +export default async function * forEach (source: AsyncIterable|Iterable, fn: (thing: T) => void | Promise): AsyncGenerator { for await (const thing of source) { await fn(thing) yield thing } } - -module.exports = each diff --git a/packages/it-foreach/test/index.spec.ts b/packages/it-foreach/test/index.spec.ts index 458c426f..530511cd 100644 --- a/packages/it-foreach/test/index.spec.ts +++ b/packages/it-foreach/test/index.spec.ts @@ -1,36 +1,38 @@ -const each = require('./') import all from 'it-all' -const test = require('ava') +import { expect } from 'aegir/chai' +import forEach from '../src/index.js' -test('Should iterate over every value', async (t) => { - const values = [0, 1, 2, 3, 4] - let sum = 0 +describe('it-for-each', () => { + it('should iterate over every value', async () => { + const values = [0, 1, 2, 3, 4] + let sum = 0 - const res = await all(each(values, (val) => { - sum += val - })) + const res = await all(forEach(values, (val) => { + sum += val + })) - t.deepEqual(res, values) - t.is(10, sum) -}) + expect(res).to.deep.equal(values) + expect(10).to.equal(sum) + }) -test('Should abort source', async (t) => { - const values = [0, 1, 2, 3, 4] - let sum = 0 - const err = new Error('wat') + it('should abort source', async () => { + const values = [0, 1, 2, 3, 4] + let sum = 0 + const err = new Error('wat') - try { - await all(each(values, (val) => { - sum += val + try { + await all(forEach(values, (val) => { + sum += val - if (val === 3) { - throw err - } - })) + if (val === 3) { + throw err + } + })) - throw new Error('Did not abort') - } catch (e) { - t.is(e, err) - t.is(6, sum) - } + throw new Error('Did not abort') + } catch (e) { + expect(e).to.equal(err) + expect(6).to.equal(sum) + } + }) }) diff --git a/packages/it-foreach/tsconfig.json b/packages/it-foreach/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-foreach/tsconfig.json +++ b/packages/it-foreach/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-glob/LICENSE b/packages/it-glob/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-glob/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-glob/LICENSE-APACHE b/packages/it-glob/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-glob/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-glob/LICENSE-MIT b/packages/it-glob/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-glob/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-glob/README.md b/packages/it-glob/README.md index 0742e6f6..6f3a1af7 100644 --- a/packages/it-glob/README.md +++ b/packages/it-glob/README.md @@ -1,17 +1,25 @@ -# it-glob +# it-glob -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-glob)](https://david-dm.org/achingbrain/it?path=packages/it-glob) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Async iterable filename pattern matcher -Like [`glob`](https://npmjs.com/package/glob) but async iterable. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) -## Installation +## Install ```console -$ npm install --save it-glob +$ npm i it-glob ``` +Like [`glob`](https://npmjs.com/package/glob) but async iterable. + ## Usage ```javascript @@ -31,3 +39,14 @@ for await (const path of glob('/path/to/file', '**/*', options)) { ``` See the [minimatch docs](https://www.npmjs.com/package/minimatch#options) for the full list of options. + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-glob/package.json b/packages/it-glob/package.json index 2cdd231d..55262374 100644 --- a/packages/it-glob/package.json +++ b/packages/it-glob/package.json @@ -2,41 +2,144 @@ "name": "it-glob", "version": "1.0.2", "description": "Async iterable filename pattern matcher", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-glob#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", "dep-check": "aegir dep-check", "clean": "aegir clean", - "test": "aegir test", + "test": "aegir test -t node", "test:node": "aegir test -t node --cov", - "test:chrome": "aegir test -t browser --cov", - "test:chrome-webworker": "aegir test -t webworker", - "test:firefox": "aegir test -t browser -- --browser firefox", - "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { "@types/minimatch": "^3.0.4", "minimatch": "^3.0.4" }, "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" + "it-all": "^1.0.0" }, "browser": { - "fs": false, + "fs/promises": false, "path": false - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-glob/src/index.ts b/packages/it-glob/src/index.ts index a8b43ff9..b65b99a5 100644 --- a/packages/it-glob/src/index.ts +++ b/packages/it-glob/src/index.ts @@ -1,28 +1,29 @@ -'use strict' +import fs from 'fs/promises' +import path from 'path' +import minimatch from 'minimatch' +import type { IOptions } from 'minimatch' -const fs = require('fs').promises -const path = require('path') -const minimatch = require('minimatch') +export interface GlobOptions extends IOptions { + /** + * The current working directory + */ + cwd?: string -/** - * @typedef {string} Glob - * @typedef {object} OptionsExt - * @property {string} [cwd=process.cwd()] - * @property {boolean} [absolute=false] - If true produces absolute paths - * @property {boolean} [nodir] - If true yields file paths and skip directories - * - * @typedef {OptionsExt & minimatch.IOptions} Options - */ + /** + * If true produces absolute paths (default: false) + */ + absolute?: boolean + + /** + * If true yields file paths and skip directories (default: false) + */ + nodir?: boolean +} /** * Async iterable filename pattern matcher - * - * @param {string} dir - * @param {string} pattern - * @param {Options} [options] - * @returns {AsyncIterable} */ -async function * glob (dir, pattern, options = {}) { +export default async function * glob (dir: string, pattern: string, options: GlobOptions = {}): AsyncGenerator { const absoluteDir = path.resolve(dir) const relativeDir = path.relative(options.cwd || process.cwd(), dir) @@ -41,14 +42,7 @@ async function * glob (dir, pattern, options = {}) { } } -/** - * @param {string} base - * @param {string} dir - * @param {Glob} pattern - * @param {Options} options - * @returns {AsyncIterable} - */ -async function * _glob (base, dir, pattern, options) { +async function * _glob (base: string, dir: string, pattern: string, options: GlobOptions): AsyncGenerator { for await (const entry of await fs.opendir(path.join(base, dir))) { const relativeEntryPath = path.join(dir, entry.name) const absoluteEntryPath = path.join(base, dir, entry.name) @@ -70,5 +64,3 @@ async function * _glob (base, dir, pattern, options) { } } } - -module.exports = glob diff --git a/packages/it-glob/test/index.spec.ts b/packages/it-glob/test/index.spec.ts index f655d61a..3d22b687 100644 --- a/packages/it-glob/test/index.spec.ts +++ b/packages/it-glob/test/index.spec.ts @@ -1,76 +1,82 @@ -const test = require('ava') +import { expect } from 'aegir/chai' import all from 'it-all' -const glob = require('.') -const path = require('path') +import glob from '../src/index.js' +import path from 'path' +import { dirname } from 'path' +import { fileURLToPath } from 'url' -test('it should match file', async t => { - const files = await all(glob('.', '**/*')) +const __dirname = dirname(fileURLToPath(import.meta.url)) - t.truthy(files.includes('README.md')) -}) +describe('it-glob', () => { + it('should match file', async () => { + const files = await all(glob('.', '**/*')) -test('it should match file in subdirectory', async t => { - const files = await all(glob('.', '**/*')) + expect(files.includes('README.md')).to.be.true() + }) - t.truthy(files.includes(path.join('node_modules', 'it-all'))) -}) + it('should match file in subdirectory', async () => { + const files = await all(glob('.', '**/*')) -test('it should match one', async t => { - const files = await all(glob('.', 'README.md')) + expect(files.includes(path.join('dist', 'src', 'index.d.ts'))).to.be.true() + }) - t.deepEqual(files, ['README.md']) -}) + it('should match one', async () => { + const files = await all(glob('.', 'README.md')) -test('it should match files', async t => { - const files = await all(glob('README.md', 'README.md')) + expect(files).to.deep.equal(['README.md']) + }) - t.deepEqual(files, ['README.md']) -}) + it('should match files', async () => { + const files = await all(glob('README.md', 'README.md')) -test('it should ignore files', async t => { - const files = await all(glob('.', '**/*!(*/index.js|**/node_modules/**)')) + expect(files).to.deep.equal(['README.md']) + }) - t.falsy(files.includes('test/index.js')) -}) + it('should ignore files', async () => { + const files = await all(glob('.', '**/*!(*/index.js|**/dist/**)')) -test('it should ignore files from absolute directory', async t => { - const files = await all(glob(__dirname, '**/*!(test/index.js|)**/node_modules/**')) + expect(files.includes('test/index.js')).to.be.false() + }) - t.falsy(files.includes(path.resolve(__dirname, 'index.js'))) -}) + it('should ignore files from absolute directory', async () => { + const files = await all(glob(__dirname, '**/*!(test/index.js|)**/dist/**')) -test('it returns absolute paths', async t => { - const files = await all(glob(__dirname, '**/*', { - absolute: true - })) + expect(files.includes(path.resolve(__dirname, 'index.js'))).to.be.false() + }) - files.forEach(file => { - t.truthy(path.isAbsolute(file)) + it('should return absolute paths', async () => { + const files = await all(glob(__dirname, '**/*', { + absolute: true + })) + + files.forEach(file => { + expect(path.isAbsolute(file)).to.be.true() + }) }) -}) -test('it returns relative paths', async t => { - const files = await all(glob(__dirname, '**/*', { - absolute: false - })) + it('should return relative paths', async () => { + const files = await all(glob(__dirname, '**/*', { + absolute: false + })) - files.forEach(file => { - t.falsy(path.isAbsolute(file)) + files.forEach(file => { + expect(path.isAbsolute(file)).to.be.false() + }) }) -}) -test('it matches directories', async t => { - const files = await all(glob(__dirname, 'node_modules/*')) + it('should match directories', async () => { + const files = await all(glob(path.resolve(__dirname, '..', '..'), 'dist/*')) - t.truthy(files.includes(path.join('node_modules', 'it-all'))) -}) + expect(files.includes(path.join('dist', 'src'))).to.be.true() + }) -test('it skips directories', async t => { - const files = await all(glob(__dirname, 'node_modules/**/*', { - nodir: true, - dot: true - })) + it('should skip directories', async () => { + const files = await all(glob(path.resolve(__dirname, '..', '..'), 'dist/**/*', { + nodir: true, + dot: true + })) - t.falsy(files.includes(path.join('node_modules', '.bin'))) - t.truthy(files.includes(path.join('node_modules', '.bin', 'ava'))) + expect(files.includes(path.join('dist', 'src'))).to.be.false() + expect(files.includes(path.join('dist', 'src', 'index.js'))).to.be.true() + }) }) diff --git a/packages/it-glob/tsconfig.json b/packages/it-glob/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-glob/tsconfig.json +++ b/packages/it-glob/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-last/LICENSE b/packages/it-last/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-last/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-last/LICENSE-APACHE b/packages/it-last/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-last/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-last/LICENSE-MIT b/packages/it-last/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-last/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-last/README.md b/packages/it-last/README.md index 80f493c7..0cb2ddd0 100644 --- a/packages/it-last/README.md +++ b/packages/it-last/README.md @@ -1,17 +1,25 @@ -# it-last +# it-last -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-last)](https://david-dm.org/achingbrain/it?path=packages/it-last) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Returns the last item of an (async) iterable +> Returns the last result from an async iterator -Mostly useful for tests. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-last +```console +$ npm i it-last ``` +Mostly useful for tests. + ## Usage ```javascript @@ -24,3 +32,14 @@ const res = await last(values) console.info(res) // 4 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-last/package.json b/packages/it-last/package.json index 8438f7e0..cc9f0090 100644 --- a/packages/it-last/package.json +++ b/packages/it-last/package.json @@ -2,10 +2,125 @@ "name": "it-last", "version": "1.0.6", "description": "Returns the last result from an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-last#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-last/src/index.ts b/packages/it-last/src/index.ts index 20dbe680..1505b219 100644 --- a/packages/it-last/src/index.ts +++ b/packages/it-last/src/index.ts @@ -1,13 +1,8 @@ -'use strict' - /** * Returns the last item of an (async) iterable, unless empty, in which case - * return `undefined`. - * - * @template T - * @param {AsyncIterable|Iterable} source + * return `undefined` */ -const last = async (source) => { +export default async function last (source: AsyncIterable|Iterable): Promise { let res for await (const entry of source) { @@ -16,5 +11,3 @@ const last = async (source) => { return res } - -module.exports = last diff --git a/packages/it-last/test/index.spec.ts b/packages/it-last/test/index.spec.ts index fcdc7e8d..dfd1f013 100644 --- a/packages/it-last/test/index.spec.ts +++ b/packages/it-last/test/index.spec.ts @@ -1,10 +1,20 @@ -const last = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import last from '../src/index.js' -test('Should return only the last result from an async iterator', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-last', () => { + it('should return only the last result from an async iterator', async () => { + const values = [0, 1, 2, 3, 4] - const res = await last(values) + const res = await last(values) - t.is(res, 4) + expect(res).to.equal(4) + }) + + it('should return undefined if the async iterator was empty', async () => { + const values: any[] = [] + + const res = await last(values) + + expect(res).to.be.undefined() + }) }) diff --git a/packages/it-length/LICENSE b/packages/it-length/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-length/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-length/LICENSE-APACHE b/packages/it-length/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-length/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-length/LICENSE-MIT b/packages/it-length/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-length/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-length/README.md b/packages/it-length/README.md index 3a8cc1cb..b1499574 100644 --- a/packages/it-length/README.md +++ b/packages/it-length/README.md @@ -1,17 +1,25 @@ -# it-length +# it-length -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-last)](https://david-dm.org/achingbrain/it?path=packages/it-last) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Counts the items in an async iterable +> Counts the number of items in an async iterable -N.b. will consume the iterable +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-length +```console +$ npm i it-length ``` +N.b. will consume the iterable + ## Usage ```javascript @@ -24,3 +32,14 @@ const res = await length(values) console.info(res) // 5 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-length/package.json b/packages/it-length/package.json index 92576e0e..0ca4f485 100644 --- a/packages/it-length/package.json +++ b/packages/it-length/package.json @@ -2,10 +2,125 @@ "name": "it-length", "version": "1.0.4", "description": "Counts the number of items in an async iterable", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-length#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-length/src/index.ts b/packages/it-length/src/index.ts index b99e4e21..3ef31549 100644 --- a/packages/it-length/src/index.ts +++ b/packages/it-length/src/index.ts @@ -1,12 +1,7 @@ -'use strict' - /** - * Consumes the passed iterator and returns the number of items it contained. - * - * @param {AsyncIterable | Iterable} iterator - * @returns {Promise} + * Consumes the passed iterator and returns the number of items it contained */ -const length = async (iterator) => { +export default async function length (iterator: AsyncIterable | Iterable): Promise { let count = 0 for await (const _ of iterator) { // eslint-disable-line no-unused-vars @@ -15,5 +10,3 @@ const length = async (iterator) => { return count } - -module.exports = length diff --git a/packages/it-length/test/index.spec.ts b/packages/it-length/test/index.spec.ts index 80da64bd..cf3cdac6 100644 --- a/packages/it-length/test/index.spec.ts +++ b/packages/it-length/test/index.spec.ts @@ -1,10 +1,12 @@ -const length = require('../dist') -const test = require('ava') +import { expect } from 'aegir/chai' +import length from '../src/index.js' -test('Should count the items in an async iterator', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-length', () => { + it('should count the items in an async iterator', async () => { + const values = [0, 1, 2, 3, 4] - const res = await length(values) + const res = await length(values) - t.is(res, 5) + expect(res).to.equal(5) + }) }) diff --git a/packages/it-map/LICENSE b/packages/it-map/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-map/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-map/LICENSE-APACHE b/packages/it-map/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-map/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-map/LICENSE-MIT b/packages/it-map/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-map/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-map/README.md b/packages/it-map/README.md index 46b4ee98..b90c42e1 100644 --- a/packages/it-map/README.md +++ b/packages/it-map/README.md @@ -1,14 +1,21 @@ +# it-map -# it-map +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-map)](https://david-dm.org/achingbrain/it?path=packages/it-map) +> Maps the values yielded by an async iterator -> Maps the values yielded by an (async) iterator +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-map +```console +$ npm i it-map ``` ## Usage @@ -23,3 +30,14 @@ const result = await map(values, (val) => val++) console.info(result) // 15 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-map/package.json b/packages/it-map/package.json index b9515e98..8befa874 100644 --- a/packages/it-map/package.json +++ b/packages/it-map/package.json @@ -2,10 +2,125 @@ "name": "it-map", "version": "1.0.6", "description": "Maps the values yielded by an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-map#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-map/src/index.ts b/packages/it-map/src/index.ts index fb6552f6..373521f0 100644 --- a/packages/it-map/src/index.ts +++ b/packages/it-map/src/index.ts @@ -1,18 +1,9 @@ -'use strict' - /** * Takes an (async) iterable and returns one with each item mapped by the passed - * function. - * - * @template I,O - * @param {AsyncIterable|Iterable} source - * @param {function(I):O|Promise} func - * @returns {AsyncIterable} + * function */ -const map = async function * (source, func) { +export default async function * map (source: AsyncIterable|Iterable, func: (val: I) => O | Promise): AsyncGenerator { for await (const val of source) { yield func(val) } } - -module.exports = map diff --git a/packages/it-map/test/index.spec.ts b/packages/it-map/test/index.spec.ts index 38dc4521..5005dce2 100644 --- a/packages/it-map/test/index.spec.ts +++ b/packages/it-map/test/index.spec.ts @@ -1,22 +1,24 @@ -const map = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import map from '../src/index.js' -test('Should map an async iterator', async (t) => { - const iter = function * () { - yield 1 - } +describe('it-map', () => { + it('should map an async iterator', async () => { + const iter = function * () { + yield 1 + } - for await (const result of map(iter(), (val) => val + 1)) { - t.is(result, 2) - } -}) + for await (const result of map(iter(), (val) => val + 1)) { + expect(result).to.equal(2) + } + }) -test('Should map an async iterator to a promise', async (t) => { - const iter = function * () { - yield 1 - } + it('should map an async iterator to a promise', async () => { + const iter = function * () { + yield 1 + } - for await (const result of map(iter(), async (val) => val + 1)) { - t.is(result, 2) - } + for await (const result of map(iter(), async (val) => val + 1)) { + expect(result).to.equal(2) + } + }) }) diff --git a/packages/it-merge/LICENSE b/packages/it-merge/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-merge/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-merge/LICENSE-APACHE b/packages/it-merge/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-merge/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-merge/LICENSE-MIT b/packages/it-merge/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-merge/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-merge/README.md b/packages/it-merge/README.md index 9b4f922a..f2bedaa9 100644 --- a/packages/it-merge/README.md +++ b/packages/it-merge/README.md @@ -1,17 +1,25 @@ -# it-merge +# it-merge -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-merge)](https://david-dm.org/achingbrain/it?path=packages/it-merge) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Treat a number of (async) iterables as if they were one +> Treat one or more iterables as a single iterable -Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-merge +```console +$ npm i it-merge ``` +Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed. + ## Usage ```javascript @@ -25,3 +33,14 @@ const arr = await all(merge(values1, values2)) console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-merge/package.json b/packages/it-merge/package.json index 6623ca44..a60c3956 100644 --- a/packages/it-merge/package.json +++ b/packages/it-merge/package.json @@ -2,10 +2,125 @@ "name": "it-merge", "version": "1.0.4", "description": "Treat one or more iterables as a single iterable", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-merge#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,19 +134,11 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { - "it-pushable": "^1.4.0" + "it-pushable": "^1.4.2" }, "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-merge/src/index.ts b/packages/it-merge/src/index.ts index 40652836..abb83c6c 100644 --- a/packages/it-merge/src/index.ts +++ b/packages/it-merge/src/index.ts @@ -1,19 +1,13 @@ -'use strict' - -const pushable = require('it-pushable') +import pushable from 'it-pushable' /** * Treat one or more iterables as a single iterable. * * Nb. sources are iterated over in parallel so the * order of emitted items is not guaranteed. - * - * @template T - * @param {...AsyncIterable|Iterable} sources - * @returns {AsyncIterable} */ -const merge = async function * (...sources) { - const output = pushable() +export default async function * merge (...sources: Array|Iterable>): AsyncGenerator { + const output = pushable() setTimeout(async () => { try { @@ -26,12 +20,10 @@ const merge = async function * (...sources) { ) output.end() - } catch (/** @type {any} */ err) { + } catch (err: any) { output.end(err) } }, 0) yield * output } - -module.exports = merge diff --git a/packages/it-merge/test/index.spec.ts b/packages/it-merge/test/index.spec.ts index 20807f83..b6372778 100644 --- a/packages/it-merge/test/index.spec.ts +++ b/packages/it-merge/test/index.spec.ts @@ -1,12 +1,14 @@ -const merge = require('./') +import { expect } from 'aegir/chai' import all from 'it-all' -const test = require('ava') +import merge from '../src/index.js' -test('Should merge multiple arrays', async (t) => { - const values1 = [0, 1, 2, 3, 4] - const values2 = [5, 6, 7, 8, 9] +describe('it-merge', () => { + it('should merge multiple arrays', async () => { + const values1 = [0, 1, 2, 3, 4] + const values2 = [5, 6, 7, 8, 9] - const res = await all(merge(values1, values2)) + const res = await all(merge(values1, values2)) - t.deepEqual(res.sort(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + expect(res.sort()).to.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + }) }) diff --git a/packages/it-merge/tsconfig.json b/packages/it-merge/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-merge/tsconfig.json +++ b/packages/it-merge/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-multipart/LICENSE b/packages/it-multipart/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-multipart/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-multipart/LICENSE-APACHE b/packages/it-multipart/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-multipart/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-multipart/LICENSE-MIT b/packages/it-multipart/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-multipart/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-multipart/README.md b/packages/it-multipart/README.md index 589b6bf2..c4d3e6b2 100644 --- a/packages/it-multipart/README.md +++ b/packages/it-multipart/README.md @@ -1,8 +1,22 @@ -# it-multipart +# it-multipart -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-multipart)](https://david-dm.org/achingbrain/it?path=packages/it-multipart) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Streaming multipart HTTP message parser +> Async iterable http multipart message parser + +## Table of contents + +- [Install](#install) +- [Example](#example) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i it-multipart +``` ## Example @@ -32,3 +46,14 @@ http.createServer(async (req, res) => { console.log('server listening on port 5001') }) ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index 259d5420..d1088210 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -2,25 +2,134 @@ "name": "it-multipart", "version": "2.0.2", "description": "Async iterable http multipart message parser", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-multipart#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", "dep-check": "aegir dep-check", "clean": "aegir clean", - "test": "aegir test", + "test": "aegir test -t node", "test:node": "aegir test -t node --cov", - "test:chrome": "aegir test -t browser --cov", - "test:chrome-webworker": "aegir test -t webworker", - "test:firefox": "aegir test -t browser -- --browser firefox", - "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { "formidable": "^1.2.2", "it-pushable": "^1.4.2" @@ -29,12 +138,11 @@ "@types/formidable": "^1.2.1", "aegir": "^37.5.0", "form-data": "^3.0.0", - "undici": "^5.11.0" + "it-drain": "^1.0.5", + "node-fetch": "^3.2.10" }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "browser": { + "http": false, + "formidable": false } } diff --git a/packages/it-multipart/src/index.ts b/packages/it-multipart/src/index.ts index 41432c81..dc001b57 100644 --- a/packages/it-multipart/src/index.ts +++ b/packages/it-multipart/src/index.ts @@ -1,24 +1,17 @@ -'use strict' +import formidable from 'formidable' +import pushable from 'it-pushable' +import type { IncomingMessage, IncomingHttpHeaders } from 'http' -const formidable = require('formidable') -const pushable = require('it-pushable') - -/** - * @typedef {import('http').IncomingMessage} IncomingMessage - * @typedef {import('http').IncomingHttpHeaders} IncomingHttpHeaders - * @typedef {Object} Part - * @property {IncomingHttpHeaders} headers - * @property {AsyncIterable} body - */ +export interface Part { + headers: IncomingHttpHeaders + body: AsyncIterable +} /** * Streaming multipart HTTP message parser - * - * @param {IncomingMessage} request - * @returns {AsyncIterable} */ -async function * multipart (request) { - const output = pushable() +export default async function * multipart (request: IncomingMessage): AsyncGenerator { + const output = pushable() if (!request) { output.end(new Error('request missing')) @@ -35,7 +28,7 @@ async function * multipart (request) { }) form.onPart = (part) => { - const body = pushable() + const body = pushable() part.on('data', buf => { body.push(buf) @@ -55,5 +48,3 @@ async function * multipart (request) { yield * output } - -module.exports = multipart diff --git a/packages/it-multipart/test/index.spec.ts b/packages/it-multipart/test/index.spec.ts index 69ab46a8..b0d0e887 100644 --- a/packages/it-multipart/test/index.spec.ts +++ b/packages/it-multipart/test/index.spec.ts @@ -1,127 +1,131 @@ -const test = require('ava') -const http = require('http') -const handler = require('.') -// @ts-ignore -const fetch = require('node-fetch') -const FormData = require('form-data') - -/** @type {string} */ -let port -/** @type {import('http').Server} */ -let server - -test.before.cb((t) => { - /** - * @param {import('http').IncomingMessage} req - */ - async function echo (req) { - /** @type {Record} */ - const files = {} - - for await (const part of handler(req)) { - // @ts-ignore - header may not be present - const name = part.headers['content-disposition'].match(/name="(.*)"/)[1] - - files[name] = '' - - for await (const str of part.body) { - files[name] += str +import { expect } from 'aegir/chai' +import http from 'http' +import handler from '../src/index.js' +import fetch from 'node-fetch' +import FormData from 'form-data' +import drain from 'it-drain' +import type { Server, IncomingMessage } from 'http' + +describe('it-multipart', () => { + let port: string + let server: Server + + before(async () => { + async function echo (req: IncomingMessage) { + const files: Record = {} + + for await (const part of handler(req)) { + // @ts-ignore - header may not be present + const name = part.headers['content-disposition'].match(/name="(.*)"/)[1] + + files[name] = '' + + for await (const str of part.body) { + files[name] += str + } } - } - return JSON.stringify(files) - } + return JSON.stringify(files) + } - server = http.createServer((req, res) => { - echo(req) - .then((files) => { - res.writeHead(200, { - 'content-length': files.length, - 'content-type': 'application/json' - }) - res.end(files) + port = await new Promise((resolve, reject) => { + server = http.createServer((req, res) => { + echo(req) + .then((files) => { + res.writeHead(200, { + 'content-length': files.length, + 'content-type': 'application/json' + }) + res.end(files) + }) + .catch(err => { + if (err.message.includes('bad content-type header')) { + res.writeHead(400) + } else { + res.writeHead(500) + } + + res.end(err.stack) + }) }) - .catch(err => { - if (err.message.includes('bad content-type header')) { - res.writeHead(400) - } else { - res.writeHead(500) - } - - res.end(err.stack) + server.on('error', (err) => { + console.info('start failed', err) + reject(err) }) - }).listen(() => { - // @ts-ignore - address() returns `null|string|object` and TS can't infer - // it's last one even though it's inside listen callback. - port = server.address().port - t.end() + server.listen(() => { + // @ts-expect-error - address() returns `null|string|object` and TS can't infer + // it's last one even though it's inside listen callback. + resolve(server.address().port) + }) + }) }) -}) -test.after.cb((t) => { - server.close(() => t.end()) -}) + after((cb) => { + if (port != null && server != null) { + server.close(() => { + cb() + }) + } + }) -test('it parses files from a multipart request', async (t) => { - const formData = new FormData() - formData.append('file-1.txt', Buffer.from('file 1 contents')) - formData.append('file-2.txt', Buffer.from('file 2 contents')) + it('should parse files from a multipart request', async () => { + const formData = new FormData() + formData.append('file-1.txt', Buffer.from('file 1 contents')) + formData.append('file-2.txt', Buffer.from('file 2 contents')) - const result = await fetch(`http://localhost:${port}`, { - method: 'POST', - headers: formData.getHeaders(), - body: formData - }) + const result = await fetch(`http://127.0.0.1:${port}`, { + method: 'POST', + headers: formData.getHeaders(), + body: formData + }) - t.is(result.status, 200) + expect(result.status).to.equal(200) - const response = await result.json() + const response = await result.json() - t.deepEqual(response, { - 'file-1.txt': 'file 1 contents', - 'file-2.txt': 'file 2 contents' + expect(response).to.deep.equal({ + 'file-1.txt': 'file 1 contents', + 'file-2.txt': 'file 2 contents' + }) }) -}) -test('it parses loads of files from multipart requests', async (t) => { - await Promise.all( - [1, 2, 3, 4, 5].map(async (index) => { - const formData = new FormData() + it('should parse loads of files from multipart requests', async () => { + await Promise.all( + [1, 2, 3, 4, 5].map(async (index) => { + const formData = new FormData() - for (let i = 0; i < (100 * index); i++) { - formData.append(`file-${i}.txt`, Buffer.from(`file ${i} contents`)) - } + for (let i = 0; i < (100 * index); i++) { + formData.append(`file-${i}.txt`, Buffer.from(`file ${i} contents`)) + } - const result = await fetch(`http://localhost:${port}`, { - method: 'POST', - headers: formData.getHeaders(), - body: formData - }) + const result = await fetch(`http://localhost:${port}`, { + method: 'POST', + headers: formData.getHeaders(), + body: formData + }) - t.is(result.status, 200) + expect(result.status).to.equal(200) - const response = await result.json() + const response: any = await result.json() - for (let i = 0; i < (10 * index); i++) { - t.is(response[`file-${i}.txt`], `file ${i} contents`) - } - }) - ) -}) + for (let i = 0; i < (10 * index); i++) { + expect(response[`file-${i}.txt`]).to.equal(`file ${i} contents`) + } + }) + ) + }) -test('it throws when request is not passed', async (t) => { - await t.throwsAsync(async () => { - for await (const _ of handler()) { // eslint-disable-line no-unused-vars + it('should throw when request is not passed', async () => { + // @ts-expect-error missing argument + await expect(drain(handler())).to.eventually.be.rejected().with.property('message', 'request missing') + }) - } - }, { message: 'request missing' }) -}) + it('should throw when request is not multipart', async () => { + const result = await fetch(`http://localhost:${port}`, { + method: 'POST', + body: 'not multipart' + }) -test('it throws when request is not multipart', async (t) => { - const result = await fetch(`http://localhost:${port}`, { - method: 'POST', - body: 'not multipart' + expect(result.status).to.equal(400) }) - - t.is(result.status, 400) }) diff --git a/packages/it-ndjson/LICENSE b/packages/it-ndjson/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-ndjson/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-ndjson/LICENSE-APACHE b/packages/it-ndjson/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-ndjson/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-ndjson/LICENSE-MIT b/packages/it-ndjson/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-ndjson/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-ndjson/README.md b/packages/it-ndjson/README.md index 304920ea..510bf379 100644 --- a/packages/it-ndjson/README.md +++ b/packages/it-ndjson/README.md @@ -1,13 +1,21 @@ -# it-ndjson +# it-ndjson -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-ndjson)](https://david-dm.org/achingbrain/it?path=packages/it-ndjson) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Parse iterators as ndjson and transform iterators to ndjson +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) + ## Install -```sh -$ npm install --save it-ndjson +```console +$ npm i it-ndjson ``` ## Usage @@ -27,3 +35,14 @@ const res = await all(ndjson.parse(arr)) console.info(res) // [0, 1, 2, 3, 4] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-ndjson/package.json b/packages/it-ndjson/package.json index b3cb8cb8..33a875e9 100644 --- a/packages/it-ndjson/package.json +++ b/packages/it-ndjson/package.json @@ -2,10 +2,125 @@ "name": "it-ndjson", "version": "0.1.1", "description": "Parse iterators as ndjson and transform iterators to ndjson", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-ndjson#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,17 +134,9 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", "buffer": "^6.0.3", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-ndjson/src/index.ts b/packages/it-ndjson/src/index.ts index a66cd743..87ae384d 100644 --- a/packages/it-ndjson/src/index.ts +++ b/packages/it-ndjson/src/index.ts @@ -1,7 +1,3 @@ -const parse = require('./parse') -const stringify = require('./stringify') -module.exports = { - parse, - stringify -} +export { default as parse } from './parse.js' +export { default as stringify } from './stringify.js' diff --git a/packages/it-ndjson/src/parse.ts b/packages/it-ndjson/src/parse.ts index 2ea9b21e..efa5698a 100644 --- a/packages/it-ndjson/src/parse.ts +++ b/packages/it-ndjson/src/parse.ts @@ -1,7 +1,5 @@ -/** - * @param {AsyncIterable | Iterable} source - */ -async function * parse (source) { + +export default async function * parse (source: AsyncIterable | Iterable): AsyncGenerator { const matcher = /\r?\n/ const decoder = new TextDecoder('utf8') let buffer = '' @@ -26,5 +24,3 @@ async function * parse (source) { yield JSON.parse(buffer) } } - -module.exports = parse diff --git a/packages/it-ndjson/src/stringify.ts b/packages/it-ndjson/src/stringify.ts index bf98e9bb..3fee4139 100644 --- a/packages/it-ndjson/src/stringify.ts +++ b/packages/it-ndjson/src/stringify.ts @@ -1,11 +1,6 @@ -/** - * @param {AsyncIterable | Iterable} source - */ -async function * stringify (source) { +export default async function * stringify (source: AsyncIterable | Iterable): AsyncGenerator { for await (const obj of source) { yield JSON.stringify(obj) + '\n' } } - -module.exports = stringify diff --git a/packages/it-ndjson/test/index.spec.ts b/packages/it-ndjson/test/index.spec.ts index b31099dd..fc26c42f 100644 --- a/packages/it-ndjson/test/index.spec.ts +++ b/packages/it-ndjson/test/index.spec.ts @@ -1,23 +1,16 @@ -const test = require('ava') -const ndjson = require('.') -const { Buffer } = require('buffer') +import { expect } from 'aegir/chai' +import * as ndjson from '../src/index.js' +import { Buffer } from 'buffer' import all from 'it-all' -/** - * @template T - * @param {T[]} array - * @returns {AsyncIterable} - */ -async function * toAsyncIterator (array) { +async function * toAsyncIterator (array: T[]): AsyncIterable { for (let i = 0; i < array.length; i++) { - yield new Promise(resolve => setTimeout(() => resolve(array[i]))) + await new Promise(resolve => setTimeout(() => resolve())) + yield array[i] } } -/** - * @param {string} str - */ -function toUint8Array (str) { +function toUint8Array (str: string): Uint8Array { const arr = new Uint8Array(str.length) for (let i = 0; i < str.length; i++) { arr[i] = str.charCodeAt(i) @@ -25,66 +18,68 @@ function toUint8Array (str) { return arr } -test('should split 1 item from 1 chunk', async t => { - const source = toAsyncIterator(['{ "id": 1 }\n']) - const results = await all(ndjson.parse(source)) +describe('it-ndjson', () => { + it('should split 1 item from 1 chunk', async () => { + const source = toAsyncIterator(['{ "id": 1 }\n']) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }]) -}) + expect(results).to.deep.equal([{ id: 1 }]) + }) -test('should split 1 item from 2 chunks', async t => { - const source = toAsyncIterator(['{ "id', '": 1 }\n']) - const results = await all(ndjson.parse(source)) + it('should split 1 item from 2 chunks', async () => { + const source = toAsyncIterator(['{ "id', '": 1 }\n']) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }]) -}) + expect(results).to.deep.equal([{ id: 1 }]) + }) -test('should split 2 items from 2 chunks', async t => { - const source = toAsyncIterator(['{ "id": 1 }\n', '{ "id": 2 }']) - const results = await all(ndjson.parse(source)) + it('should split 2 items from 2 chunks', async () => { + const source = toAsyncIterator(['{ "id": 1 }\n', '{ "id": 2 }']) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }, { id: 2 }]) -}) + expect(results).to.deep.equal([{ id: 1 }, { id: 2 }]) + }) -test('should split 2 items from 1 chunk', async t => { - const source = toAsyncIterator(['{ "id": 1 }\n{ "id": 2 }']) - const results = await all(ndjson.parse(source)) + it('should split 2 items from 1 chunk', async () => { + const source = toAsyncIterator(['{ "id": 1 }\n{ "id": 2 }']) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }, { id: 2 }]) -}) + expect(results).to.deep.equal([{ id: 1 }, { id: 2 }]) + }) -test('should split 3 items from 2 chunks', async t => { - const source = toAsyncIterator(['{ "id": 1 }\n{ "i', 'd": 2 }', '\n{"id":3}']) - const results = await all(ndjson.parse(source)) + it('should split 3 items from 2 chunks', async () => { + const source = toAsyncIterator(['{ "id": 1 }\n{ "i', 'd": 2 }', '\n{"id":3}']) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }, { id: 2 }, { id: 3 }]) -}) + expect(results).to.deep.equal([{ id: 1 }, { id: 2 }, { id: 3 }]) + }) -test('should split from Buffers', async t => { - const source = toAsyncIterator([Buffer.from('{ "id": 1 }\n{ "i'), Buffer.from('d": 2 }'), Buffer.from('\n{"id":3}')]) - const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }, { id: 2 }, { id: 3 }]) -}) + it('should split from Buffers', async () => { + const source = toAsyncIterator([Buffer.from('{ "id": 1 }\n{ "i'), Buffer.from('d": 2 }'), Buffer.from('\n{"id":3}')]) + const results = await all(ndjson.parse(source)) + expect(results).to.deep.equal([{ id: 1 }, { id: 2 }, { id: 3 }]) + }) -test('should split from Uint8Arrays', async t => { - const source = toAsyncIterator([toUint8Array('{ "id": 1 }\n{ "i'), toUint8Array('d": 2 }'), toUint8Array('\n{"id":3}')]) - const results = await all(ndjson.parse(source)) + it('should split from Uint8Arrays', async () => { + const source = toAsyncIterator([toUint8Array('{ "id": 1 }\n{ "i'), toUint8Array('d": 2 }'), toUint8Array('\n{"id":3}')]) + const results = await all(ndjson.parse(source)) - t.deepEqual(results, [{ id: 1 }, { id: 2 }, { id: 3 }]) -}) + expect(results).to.deep.equal([{ id: 1 }, { id: 2 }, { id: 3 }]) + }) -test('should round trip', async t => { - const input = '{"id":1}\n{"id":2}\n{"id":3}\n' - const source = toAsyncIterator([input]) - const results = await all(ndjson.stringify(ndjson.parse(source))) + it('should round trip', async () => { + const input = '{"id":1}\n{"id":2}\n{"id":3}\n' + const source = toAsyncIterator([input]) + const results = await all(ndjson.stringify(ndjson.parse(source))) - t.is(results.join(''), input) -}) + expect(results.join('')).to.equal(input) + }) -test('should stringify trip', async t => { - const input = [{ id: 1 }, { id: 2 }, { id: 3 }] - const source = toAsyncIterator(input) - const results = await all(ndjson.stringify(source)) + it('should stringify trip', async () => { + const input = [{ id: 1 }, { id: 2 }, { id: 3 }] + const source = toAsyncIterator(input) + const results = await all(ndjson.stringify(source)) - t.is(results.join(''), '{"id":1}\n{"id":2}\n{"id":3}\n') + expect(results.join('')).to.equal('{"id":1}\n{"id":2}\n{"id":3}\n') + }) }) diff --git a/packages/it-ndjson/tsconfig.json b/packages/it-ndjson/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-ndjson/tsconfig.json +++ b/packages/it-ndjson/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-parallel-batch/LICENSE b/packages/it-parallel-batch/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-parallel-batch/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-parallel-batch/LICENSE-APACHE b/packages/it-parallel-batch/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-parallel-batch/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-parallel-batch/LICENSE-MIT b/packages/it-parallel-batch/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-parallel-batch/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-parallel-batch/README.md b/packages/it-parallel-batch/README.md index 3eeb6da8..21aae28c 100644 --- a/packages/it-parallel-batch/README.md +++ b/packages/it-parallel-batch/README.md @@ -1,23 +1,31 @@ -# it-parallel-batch +# it-parallel-batch -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-parallel-batch)](https://david-dm.org/achingbrain/it?path=packages/it-parallel-batch) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Takes an (async) iterable that emits promise-returning functions, invokes them in parallel and emits the results as they become available but in the same order as the input +> Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input -The final batch may be smaller than the batch size. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-parallel-batch +```console +$ npm i it-parallel-batch ``` +The final batch may be smaller than the batch size. + ## Usage ```javascript const parallelBatch = require('it-parallel-batch') import all from 'it-all' -const delay = require('delay') +import delay from 'delay' // This can also be an iterator, async iterator, generator, etc const input = [ @@ -44,3 +52,14 @@ const result = await all(parallelBatch(input, batchSize)) console.info(result) // [1, 2, 3] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-parallel-batch/package.json b/packages/it-parallel-batch/package.json index 3f3498f4..770d8398 100644 --- a/packages/it-parallel-batch/package.json +++ b/packages/it-parallel-batch/package.json @@ -2,10 +2,125 @@ "name": "it-parallel-batch", "version": "1.0.11", "description": "Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel-batch#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,27 +134,12 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", + "dependencies": { + "it-batch": "^1.0.0" + }, "devDependencies": { "aegir": "^37.5.0", "delay": "^4.3.0", - "it-all": "^1.0.6" - }, - "dependencies": { - "it-batch": "^1.0.9" - }, - "typesVersions": { - "*": { - "*": [ - ".", - "dist/*" - ] - } - }, - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-parallel-batch/src/index.ts b/packages/it-parallel-batch/src/index.ts index dade63cf..5c381f9a 100644 --- a/packages/it-parallel-batch/src/index.ts +++ b/packages/it-parallel-batch/src/index.ts @@ -1,34 +1,24 @@ -'use strict' +import batch from 'it-batch' -const batch = require('it-batch') - -/** - * @template T - * @typedef {{ok:true, value:T}} Success - */ +interface Success { + ok: true + value: T +} -/** - * @typedef {{ok:false, err:Error}} Failure - */ +interface Failure { + ok: false + err: Error +} /** * Takes an (async) iterator that emits promise-returning functions, * invokes them in parallel and emits the results as they become available but * in the same order as the input - * - * @template T - * @param {AsyncIterable<() => Promise>|Iterable<() => Promise>} source - * @param {number} [size=1] - * @returns {AsyncIterable} */ -async function * parallelBatch (source, size = 1) { +export default async function * parallelBatch (source: AsyncIterable<() => Promise>|Iterable<() => Promise>, size: number = 1): AsyncGenerator { for await (const tasks of batch(source, size)) { - /** @type {Promise|Failure>[]} */ - const things = tasks.map( - /** - * @param {() => Promise} p - */ - p => { + const things: Promise|Failure>[] = tasks.map( + (p: () => Promise) => { return p().then(value => ({ ok: true, value }), err => ({ ok: false, err })) }) @@ -43,5 +33,3 @@ async function * parallelBatch (source, size = 1) { } } } - -module.exports = parallelBatch diff --git a/packages/it-parallel-batch/test/index.spec.ts b/packages/it-parallel-batch/test/index.spec.ts index a7158388..a5dbde1b 100644 --- a/packages/it-parallel-batch/test/index.spec.ts +++ b/packages/it-parallel-batch/test/index.spec.ts @@ -1,229 +1,233 @@ -'use strict' - -const parallelBatch = require('../dist') -const test = require('ava') +import { expect } from 'aegir/chai' import all from 'it-all' -const delay = require('delay') - -test('Should batch up emitted arrays', async (t) => { - const input = [ - async () => { - await delay(200) - - return 1 - }, - async () => { - await delay(100) - - return 2 - } - ] - - const res = await all(parallelBatch(input, 2)) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up emitted arrays in the right order', async (t) => { - const input = [ - async () => { - await delay(100) - - return 1 - }, - async () => { - await delay(200) - - return 2 - }, - async () => { - await delay(50) - - return 3 - } - ] - - const res = await all(parallelBatch(input, 2)) - - t.deepEqual(res, [1, 2, 3]) -}) - -test('Should propagate errors', async (t) => { - const error = new Error('wat') - - const input = [ - async () => { - await delay(100) - - return 1 - }, - async () => { - await delay(200) - - throw error - }, - async () => { - await delay(50) - - return 3 - } - ] - - try { - await all(parallelBatch(input, 2)) - } catch (err) { - t.is(err, error) - } -}) - -test('Execute batch in parallel', async (t) => { - const error = new Error('wat') - const started = [false, false, false] - - const input = [ - async () => { - started[0] = true - - await delay(200) - - return 1 - }, - async () => { - started[1] = true - - await delay(100) - - throw error - }, - async () => { - // in second batch, should not execute - started[2] = true - - await delay(100) - - return 3 - } - ] - - try { - await all(parallelBatch(input, 2)) - } catch (err) { - t.is(err, error) - } - - t.deepEqual(started, [true, true, false]) -}) - -test('Should work without size parameter', async (t) => { - const input = [ - async () => { - await delay(200) - - return 1 - }, - async () => { - await delay(100) - - return 2 - } - ] - - const res = await all(parallelBatch(input)) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with negative batch size', async (t) => { - const input = [ - async () => { - await delay(200) - - return 1 - }, - async () => { - await delay(100) - - return 2 +import delay from 'delay' +import parallelBatch from '../src/index.js' + +describe('it-parallel-batch', () => { + it('should batch up emitted arrays', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + + const res = await all(parallelBatch(input, 2)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up emitted arrays in the right order', async () => { + const input = [ + async () => { + await delay(100) + + return 1 + }, + async () => { + await delay(200) + + return 2 + }, + async () => { + await delay(50) + + return 3 + } + ] + + const res = await all(parallelBatch(input, 2)) + + expect(res).to.deep.equal([1, 2, 3]) + }) + + it('should propagate errors', async () => { + const error = new Error('wat') + + const input = [ + async () => { + await delay(100) + + return 1 + }, + async () => { + await delay(200) + + throw error + }, + async () => { + await delay(50) + + return 3 + } + ] + + try { + await all(parallelBatch(input, 2)) + } catch (err) { + expect(err).to.equal(error) } - ] - const batchSize = -1 - const res = await all(parallelBatch(input, batchSize)) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with zero batch size', async (t) => { - const input = [ - async () => { - await delay(200) + }) - return 1 - }, - async () => { - await delay(100) + it('should execute batch in parallel', async () => { + const error = new Error('wat') + const started = [false, false, false] - return 2 - } - ] - const batchSize = 0 - const res = await all(parallelBatch(input, batchSize)) - - t.deepEqual(res, [1, 2]) -}) + const input = [ + async () => { + started[0] = true -test('Should batch up entries with string batch size', async (t) => { - const input = [ - async () => { - await delay(200) + await delay(200) - return 1 - }, - async () => { - await delay(100) + return 1 + }, + async () => { + started[1] = true - return 2 - } - ] - const batchSize = '2' - const res = await all(parallelBatch(input, batchSize)) + await delay(100) - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with non-integer batch size', async (t) => { - const input = [ - async () => { - await delay(200) - - return 1 - }, - async () => { - await delay(100) - - return 2 - } - ] - const batchSize = 2.5 - const res = await all(parallelBatch(input, batchSize)) - - t.deepEqual(res, [1, 2]) -}) + throw error + }, + async () => { + // in second batch, should not execute + started[2] = true -test('Should allow returning errors', async (t) => { - const input = [ - async () => { - await delay(200) + await delay(100) - return new Error('herp') - }, - async () => { - await delay(100) + return 3 + } + ] - return new Error('derp') + try { + await all(parallelBatch(input, 2)) + } catch (err) { + expect(err).to.equal(error) } - ] - const batchSize = 2 - const res = await all(parallelBatch(input, batchSize)) - t.deepEqual(res, [new Error('herp'), new Error('derp')]) + expect(started).to.deep.equal([true, true, false]) + }) + + it('should work without size parameter', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + + const res = await all(parallelBatch(input)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with negative batch size', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + const batchSize = -1 + const res = await all(parallelBatch(input, batchSize)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with zero batch size', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + const batchSize = 0 + const res = await all(parallelBatch(input, batchSize)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with string batch size', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + const batchSize = '2' + // @ts-expect-error batchSize type is wrong + const res = await all(parallelBatch(input, batchSize)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with non-integer batch size', async () => { + const input = [ + async () => { + await delay(200) + + return 1 + }, + async () => { + await delay(100) + + return 2 + } + ] + const batchSize = 2.5 + const res = await all(parallelBatch(input, batchSize)) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should allow returning errors', async () => { + const herp = new Error('herp') + const derp = new Error('derp') + + const input = [ + async () => { + await delay(200) + + return herp + }, + async () => { + await delay(100) + + return derp + } + ] + const batchSize = 2 + const res = await all(parallelBatch(input, batchSize)) + + expect(res).to.deep.equal([herp, derp]) + }) }) diff --git a/packages/it-parallel-batch/tsconfig.json b/packages/it-parallel-batch/tsconfig.json index 13a35996..2bd5d99b 100644 --- a/packages/it-parallel-batch/tsconfig.json +++ b/packages/it-parallel-batch/tsconfig.json @@ -6,5 +6,13 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + }, + { + "path": "../it-batch" + } ] } diff --git a/packages/it-parallel/LICENSE b/packages/it-parallel/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-parallel/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-parallel/LICENSE-APACHE b/packages/it-parallel/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-parallel/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-parallel/LICENSE-MIT b/packages/it-parallel/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-parallel/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-parallel/README.md b/packages/it-parallel/README.md index b2855037..3c781c40 100644 --- a/packages/it-parallel/README.md +++ b/packages/it-parallel/README.md @@ -1,13 +1,21 @@ -# it-parallel +# it-parallel -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-parallel)](https://david-dm.org/achingbrain/it?path=packages/it-parallel) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) + ## Install -```sh -$ npm install --save it-parallel +```console +$ npm i it-parallel ``` ## Usage @@ -15,7 +23,7 @@ $ npm install --save it-parallel ```javascript const parallel = require('it-parallel') import all from 'it-all' -const delay = require('delay') +import delay from 'delay' // This can also be an iterator, async iterator, generator, etc const input = [ @@ -75,3 +83,14 @@ const result = await all(parallel(input, { console.info(result) // [1, 2, 3] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-parallel/package.json b/packages/it-parallel/package.json index 95872803..c7ab4dd2 100644 --- a/packages/it-parallel/package.json +++ b/packages/it-parallel/package.json @@ -2,10 +2,125 @@ "name": "it-parallel", "version": "2.0.2", "description": "Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-parallel#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,27 +134,12 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", - "devDependencies": { - "aegir": "^37.5.0", - "delay": "^4.3.0", - "it-all": "^1.0.6" - }, "dependencies": { "p-defer": "^3.0.0" }, - "typesVersions": { - "*": { - "*": [ - ".", - "dist/*" - ] - } - }, - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "devDependencies": { + "aegir": "^37.5.0", + "delay": "^4.3.0", + "it-all": "^1.0.0" } } diff --git a/packages/it-parallel/src/index.ts b/packages/it-parallel/src/index.ts index c3b32d77..21bea5f3 100644 --- a/packages/it-parallel/src/index.ts +++ b/packages/it-parallel/src/index.ts @@ -1,32 +1,30 @@ /* global EventTarget Event */ -'use strict' -const defer = require('p-defer') +import defer from 'p-defer' -/** - * @template T - * @typedef {object} Operation - * @property {boolean} done - * @property {boolean} ok - * @property {Error} err - * @property {T} value - */ +interface Operation { + done: boolean + ok: boolean + err: Error + value: T +} const CustomEvent = globalThis.CustomEvent || Event +export interface ParallelOptions { + /** + * How many jobs to execute in parallel (default: ) + */ + concurrency?: number + ordered?: boolean +} + /** * Takes an (async) iterator that emits promise-returning functions, * invokes them in parallel and emits the results as they become available but * in the same order as the input - * - * @template T - * @param {Iterable<() => Promise> | AsyncIterable<() => Promise>} source - * @param {object} [options] - * @param {number} [options.concurrency=Infinity] - * @param {boolean} [options.ordered=false] - * @returns {AsyncIterable} */ -async function * parallel (source, options = {}) { +export default async function * parallel (source: Iterable<() => Promise> | AsyncIterable<() => Promise>, options: ParallelOptions = {}): AsyncGenerator { let concurrency = options.concurrency || Infinity if (concurrency < 1) { @@ -36,8 +34,7 @@ async function * parallel (source, options = {}) { const ordered = options.ordered == null ? false : options.ordered const emitter = new EventTarget() - /** @type {Operation[]}} */ - const ops = [] + const ops: Operation[] = [] let slotAvailable = defer() let resultAvailable = defer() let sourceFinished = false @@ -60,10 +57,7 @@ async function * parallel (source, options = {}) { break } - /** - * @type {any} - */ - const op = { + const op: any = { done: false } ops.push(op) @@ -164,5 +158,3 @@ async function * parallel (source, options = {}) { } } } - -module.exports = parallel diff --git a/packages/it-parallel/test/index.spec.ts b/packages/it-parallel/test/index.spec.ts index 68bbb582..3e064a2c 100644 --- a/packages/it-parallel/test/index.spec.ts +++ b/packages/it-parallel/test/index.spec.ts @@ -1,11 +1,9 @@ -'use strict' - -const parallel = require('../dist') -const test = require('ava') +import { expect } from 'aegir/chai' import all from 'it-all' -const delay = require('delay') +import delay from 'delay' +import parallel from '../src/index.js' -const createFn = (ms, result) => { +const createFn = (ms: number, result: number) => { return async () => { await delay(ms) @@ -13,244 +11,250 @@ const createFn = (ms, result) => { } } -test('Should execute and return ordered results', async (t) => { - const input = [ - createFn(1000, 1), - createFn(2000, 2), - createFn(100, 3), - createFn(500, 4) - ] - - const res = await all(parallel(input, { - concurrency: 3, - ordered: true - })) - - t.deepEqual(res, [1, 2, 3, 4]) -}) - -test('Should execute and return unordered results', async (t) => { - const input = [ - createFn(1000, 1), - createFn(2000, 2), - createFn(100, 3), - createFn(500, 4) - ] - - const res = await all(parallel(input, { - concurrency: 3, - ordered: false - })) - - t.deepEqual(res, [3, 4, 1, 2]) -}) - -test('Should not exceed concurrency limit', async (t) => { - let running = 0 - let runningMax = 0 - const concurrency = 3 - - const createFn = (ms, result) => { - return async () => { - running++ - - if (running > runningMax) { - runningMax = running +describe('it-parallel', () => { + it('should execute and return ordered results', async () => { + const input = [ + createFn(1000, 1), + createFn(2000, 2), + createFn(100, 3), + createFn(500, 4) + ] + + const res = await all(parallel(input, { + concurrency: 3, + ordered: true + })) + + expect(res).to.deep.equal([1, 2, 3, 4]) + }) + + it('should execute and return unordered results', async () => { + const input = [ + createFn(1000, 1), + createFn(2000, 2), + createFn(100, 3), + createFn(500, 4) + ] + + const res = await all(parallel(input, { + concurrency: 3, + ordered: false + })) + + expect(res).to.deep.equal([3, 4, 1, 2]) + }) + + it('should not exceed concurrency limit', async () => { + let running = 0 + let runningMax = 0 + const concurrency = 3 + + const createFn = (ms: number, result: number) => { + return async () => { + running++ + + if (running > runningMax) { + runningMax = running + } + + await delay(ms) + + running-- + + return result } - - await delay(ms) - - running-- - - return result } - } - const input = [ - createFn(1000, 1), - createFn(100, 2), - createFn(100, 3), - createFn(10, 4), - createFn(10, 5) - ] + const input = [ + createFn(1000, 1), + createFn(100, 2), + createFn(100, 3), + createFn(10, 4), + createFn(10, 5) + ] - const res = await all(parallel(input, { concurrency, ordered: true })) + const res = await all(parallel(input, { concurrency, ordered: true })) - t.deepEqual(res, [1, 2, 3, 4, 5]) + expect(res).to.deep.equal([1, 2, 3, 4, 5]) - t.is(runningMax, concurrency) -}) + expect(runningMax).to.equal(concurrency) + }) -test('Should propagate task errors', async (t) => { - const error = new Error('wat') + it('should propagate task errors', async () => { + const error = new Error('wat') - const input = [ - createFn(100, 1), - async () => { - await delay(200) + const input = [ + createFn(100, 1), + async () => { + await delay(200) - throw error - }, - createFn(50, 3) - ] - - try { - await all(parallel(input, { concurrency: 2 })) - } catch (err) { - t.is(err, error) - } -}) + throw error + }, + createFn(50, 3) + ] -test('Should propagate source errors', async (t) => { - const error = new Error('Urk!') + try { + await all(parallel(input, { concurrency: 2 })) + } catch (err) { + expect(err).to.equal(error) + } + }) - async function * source () { - yield async () => 'foo' + it('should propagate source errors', async () => { + const error = new Error('Urk!') - throw error - } + async function * source () { + yield async () => 'foo' - try { - await all(parallel(source(), { concurrency: 2 })) - } catch (err) { - t.is(err, error) - } -}) + throw error + } -test('Should allow source to finish if task errors', async (t) => { - let sourceFinished = false - let index = 0 - const values = [ - async () => { - await delay(500) - throw new Error('Urk!') - }, - async () => { - await delay(100) - return 'hello' - }, - async () => { - await delay(200) - return 'hello' - }, - async () => { - await delay(300) - return 'hello' - }, - async () => { - await delay(400) - return 'hello' - }, - async () => { - await delay(500) - return 'world' - }, - async () => { - await delay(600) - return 'world' + try { + await all(parallel(source(), { concurrency: 2 })) + } catch (err) { + expect(err).to.equal(error) } - ] - - const source = { - [Symbol.asyncIterator]: () => source, - async next () { - const value = values[index] - index++ - - return Promise.resolve({ - done: index === values.length, - value - }) - }, - return () { - sourceFinished = true + }) + + it('should allow source to finish if task errors', async () => { + let sourceFinished = false + let index = 0 + const values = [ + async () => { + await delay(500) + throw new Error('Urk!') + }, + async () => { + await delay(100) + return 'hello' + }, + async () => { + await delay(200) + return 'hello' + }, + async () => { + await delay(300) + return 'hello' + }, + async () => { + await delay(400) + return 'hello' + }, + async () => { + await delay(500) + return 'world' + }, + async () => { + await delay(600) + return 'world' + } + ] + + const source: any = { + [Symbol.asyncIterator]: () => source, + async next () { + const value = values[index] + index++ + + return Promise.resolve({ + done: index === values.length, + value + }) + }, + return () { + sourceFinished = true + } } - } - - try { - await all(parallel(source, { concurrency: 2, ordered: true })) - } catch { - t.truthy(sourceFinished) - } -}) - -test('Should work without concurrency parameter', async (t) => { - const input = [ - createFn(200, 1), - createFn(100, 2) - ] - - const res = await all(parallel(input, { ordered: true })) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with negative batch size', async (t) => { - const input = [ - createFn(200, 1), - createFn(100, 2) - ] - const concurrency = -1 - const res = await all(parallel(input, { concurrency, ordered: true })) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with zero batch size', async (t) => { - const input = [ - createFn(200, 1), - createFn(100, 2) - ] - const concurrency = 0 - const res = await all(parallel(input, { concurrency, ordered: true })) - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with string batch size', async (t) => { - const input = [ - createFn(200, 1), - createFn(100, 2) - ] - const concurrency = '2' - const res = await all(parallel(input, { concurrency, ordered: true })) - - t.deepEqual(res, [1, 2]) -}) - -test('Should batch up entries with non-integer batch size', async (t) => { - const input = [ - createFn(200, 1), - createFn(100, 2) - ] - const concurrency = 2.5 - const res = await all(parallel(input, { concurrency, ordered: true })) - - t.deepEqual(res, [1, 2]) -}) - -test('Should allow returning errors', async (t) => { - const input = [ - async () => { - await delay(200) - - return new Error('herp') - }, - async () => { - await delay(100) - - return new Error('derp') + try { + await all(parallel(source, { concurrency: 2, ordered: true })) + } catch { + expect(sourceFinished).to.be.true() } - ] - const concurrency = 2 - const res = await all(parallel(input, { concurrency, ordered: true })) + }) + + it('should work without concurrency parameter', async () => { + const input = [ + createFn(200, 1), + createFn(100, 2) + ] + + const res = await all(parallel(input, { ordered: true })) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with negative batch size', async () => { + const input = [ + createFn(200, 1), + createFn(100, 2) + ] + const concurrency = -1 + const res = await all(parallel(input, { concurrency, ordered: true })) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with zero batch size', async () => { + const input = [ + createFn(200, 1), + createFn(100, 2) + ] + const concurrency = 0 + const res = await all(parallel(input, { concurrency, ordered: true })) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with string batch size', async () => { + const input = [ + createFn(200, 1), + createFn(100, 2) + ] + const concurrency = '2' + // @ts-expect-error concurrency is wrong type + const res = await all(parallel(input, { concurrency, ordered: true })) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should batch up entries with non-integer batch size', async () => { + const input = [ + createFn(200, 1), + createFn(100, 2) + ] + const concurrency = 2.5 + const res = await all(parallel(input, { concurrency, ordered: true })) + + expect(res).to.deep.equal([1, 2]) + }) + + it('should allow returning errors', async () => { + const herp = new Error('herp') + const derp = new Error('derp') + + const input = [ + async () => { + await delay(200) + + return herp + }, + async () => { + await delay(100) + + return derp + } + ] + const concurrency = 2 + const res = await all(parallel(input, { concurrency, ordered: true })) - t.deepEqual(res, [new Error('herp'), new Error('derp')]) -}) + expect(res).to.deep.equal([herp, derp]) + }) -test('Should work with empty source', async (t) => { - const input = [] - const res = await all(parallel(input)) + it('should work with empty source', async () => { + const input: any[] = [] + const res = await all(parallel(input)) - t.deepEqual(res, []) + expect(res).to.deep.equal([]) + }) }) diff --git a/packages/it-parallel/tsconfig.json b/packages/it-parallel/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-parallel/tsconfig.json +++ b/packages/it-parallel/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-peekable/LICENSE b/packages/it-peekable/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-peekable/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-peekable/LICENSE-APACHE b/packages/it-peekable/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-peekable/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-peekable/LICENSE-MIT b/packages/it-peekable/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-peekable/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-peekable/README.md b/packages/it-peekable/README.md index 976d8c3c..852879f9 100644 --- a/packages/it-peekable/README.md +++ b/packages/it-peekable/README.md @@ -1,17 +1,25 @@ -# it-peekable +# it-peekable -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-reduce)](https://david-dm.org/achingbrain/it?path=packages/it-reduce) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> A peekable async iterator +> Allows peeking/pushing an iterable -Lets you look at the contents of an async iterator and decide what to do +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-peekable +```console +$ npm i it-peekable ``` +Lets you look at the contents of an async iterator and decide what to do + ## Usage ```javascript @@ -31,3 +39,14 @@ it.push(first) console.info([...it]) // [ 0, 1, 2, 3, 4 ] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-peekable/package.json b/packages/it-peekable/package.json index 655a65f3..97bb6ecb 100644 --- a/packages/it-peekable/package.json +++ b/packages/it-peekable/package.json @@ -2,10 +2,125 @@ "name": "it-peekable", "version": "1.0.3", "description": "Allows peeking/pushing an iterable", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-peekable#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-peekable/src/index.ts b/packages/it-peekable/src/index.ts index 978412fa..2b965205 100644 --- a/packages/it-peekable/src/index.ts +++ b/packages/it-peekable/src/index.ts @@ -1,44 +1,26 @@ -'use strict' -/** - * @template T - * @typedef {Object} Peek - * @property {() => IteratorResult} peek - */ -/** - * @template T - * @typedef {Object} AsyncPeek - * @property {() => Promise>} peek - */ +interface Peek { + peek: () => IteratorResult +} -/** - * @template T - * @typedef {Object} Push - * @property {(value:T) => void} push - */ +interface AsyncPeek { + peek: () => Promise> +} -/** - * @template T - * @typedef {Iterable & Peek & Push & Iterator} Peekable - */ +interface Push { + push: (value:T) => void +} -/** - * @template T - * @typedef {AsyncIterable & AsyncPeek & Push & AsyncIterator} AsyncPeekable - */ +type Peekable = Iterable & Peek & Push & Iterator -/** - * @template {Iterable | AsyncIterable} I - * @param {I} iterable - * @returns {I extends Iterable - * ? Peekable - * : I extends AsyncIterable - * ? AsyncPeekable - * : never - * } - */ -function peekableIterator (iterable) { +type AsyncPeekable = AsyncIterable & AsyncPeek & Push & AsyncIterator + +export default function peekableIterator | AsyncIterable> (iterable: I): I extends Iterable + ? Peekable + : I extends AsyncIterable + ? AsyncPeekable + : never { // @ts-ignore const [iterator, symbol] = iterable[Symbol.asyncIterator] // @ts-ignore @@ -46,15 +28,14 @@ function peekableIterator (iterable) { // @ts-ignore : [iterable[Symbol.iterator](), Symbol.iterator] - /** @type {any[]} */ - const queue = [] + const queue: any[] = [] // @ts-ignore return { peek: () => { return iterator.next() }, - push: (value) => { + push: (value: any) => { queue.push(value) }, next: () => { @@ -72,5 +53,3 @@ function peekableIterator (iterable) { } } } - -module.exports = peekableIterator diff --git a/packages/it-peekable/test/index.spec.ts b/packages/it-peekable/test/index.spec.ts index 5dd3b8fb..77558028 100644 --- a/packages/it-peekable/test/index.spec.ts +++ b/packages/it-peekable/test/index.spec.ts @@ -1,53 +1,59 @@ -const peekableIt = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' import all from 'it-all' - -test('Should peek at an iterable', async (t) => { - const iterable = [0, 1, 2, 3] - const peekable = peekableIt(iterable) - const { value, done } = peekable.peek() - - t.is(value, 0) - t.is(done, false) -}) - -test('Should peek at an async iterable', async (t) => { - const content = [0, 1, 2, 3] - const iterable = async function * () { - for (let i = 0; i < content.length; i++) { - yield content[i] +import peekableIt from '../src/index.js' + +describe('it-peekable', () => { + it('should peek at an iterable', async () => { + const iterable = [0, 1, 2, 3] + const peekable = peekableIt(iterable) + const { value, done } = peekable.peek() + + expect(value).to.equal(0) + expect(done).to.be.false() + }) + + it('should peek at an async iterable', async () => { + const content = [0, 1, 2, 3] + const iterable = async function * () { + for (let i = 0; i < content.length; i++) { + yield content[i] + } } - } - const peekable = peekableIt(iterable()) - const { value, done } = await peekable.peek() + const peekable = peekableIt(iterable()) + const { value, done } = await peekable.peek() - t.is(value, 0) - t.is(done, false) -}) + expect(value).to.equal(0) + expect(done).to.be.false() + }) -test('Should push an iterable', async (t) => { - const iterable = [0, 1, 2, 3] - const peekable = peekableIt(iterable) - const { value } = peekable.peek() + it('should push an iterable', async () => { + const iterable = [0, 1, 2, 3] + const peekable = peekableIt(iterable) + const { value } = peekable.peek() - peekable.push(value) + if (value != null) { + peekable.push(value) + } - t.deepEqual([...peekable], iterable) -}) + expect([...peekable]).to.deep.equal(iterable) + }) -test('Should push an async iterable', async (t) => { - const content = [0, 1, 2, 3] - const iterable = async function * () { - for (let i = 0; i < content.length; i++) { - yield content[i] + it('should push an async iterable', async () => { + const content = [0, 1, 2, 3] + const iterable = async function * () { + for (let i = 0; i < content.length; i++) { + yield content[i] + } } - } - const peekable = peekableIt(iterable()) - const { value } = await peekable.peek() + const peekable = peekableIt(iterable()) + const { value } = await peekable.peek() - peekable.push(value) + if (value != null) { + peekable.push(value) + } - t.deepEqual(await all(peekable), content) + expect(await all(peekable)).to.deep.equal(content) + }) }) diff --git a/packages/it-peekable/tsconfig.json b/packages/it-peekable/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-peekable/tsconfig.json +++ b/packages/it-peekable/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-reduce/LICENSE b/packages/it-reduce/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-reduce/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-reduce/LICENSE-APACHE b/packages/it-reduce/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-reduce/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-reduce/LICENSE-MIT b/packages/it-reduce/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-reduce/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-reduce/README.md b/packages/it-reduce/README.md index 9ce9f983..50d1e7e9 100644 --- a/packages/it-reduce/README.md +++ b/packages/it-reduce/README.md @@ -1,17 +1,25 @@ -# it-reduce +# it-reduce -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-reduce)](https://david-dm.org/achingbrain/it?path=packages/it-reduce) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Reduces the values yielded by an (async) iterable +> Reduces the values yielded from an async iterator -Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-reduce +```console +$ npm i it-reduce ``` +Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values. + ## Usage ```javascript @@ -24,3 +32,14 @@ const result = await reduce(values, (acc, curr) => acc + curr, 0) console.info(result) // 10 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-reduce/package.json b/packages/it-reduce/package.json index 3874e523..ee8394fe 100644 --- a/packages/it-reduce/package.json +++ b/packages/it-reduce/package.json @@ -2,10 +2,125 @@ "name": "it-reduce", "version": "1.0.6", "description": "Reduces the values yielded from an async iterator", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-reduce#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,15 +134,7 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-reduce/src/index.ts b/packages/it-reduce/src/index.ts index 69c66367..f1329d1a 100644 --- a/packages/it-reduce/src/index.ts +++ b/packages/it-reduce/src/index.ts @@ -1,19 +1,11 @@ -'use strict' /** * Reduces the values yielded by an (async) iterable - * - * @template T, V - * @param {AsyncIterable|Iterable} source - * @param {function(V, T):V} func - * @param {V} init */ -const reduce = async (source, func, init) => { +export default async function reduce (source: AsyncIterable | Iterable, func: (acc: V, curr: T) => V, init: V): Promise { for await (const val of source) { init = func(init, val) } return init } - -module.exports = reduce diff --git a/packages/it-reduce/test/index.spec.ts b/packages/it-reduce/test/index.spec.ts index 07e0192c..6e1f150d 100644 --- a/packages/it-reduce/test/index.spec.ts +++ b/packages/it-reduce/test/index.spec.ts @@ -1,14 +1,16 @@ -const reduce = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import reduce from '../src/index.js' -test('Should reduce the values yielded from an async iterator', async (t) => { - const iter = function * () { - yield 1 - yield 2 - yield 3 - } +describe('it-reduce', () => { + it('should reduce the values yielded from an async iterator', async () => { + const iter = function * () { + yield 1 + yield 2 + yield 3 + } - const result = await reduce(iter(), (acc, curr) => acc + curr, 0) + const result = await reduce(iter(), (acc, curr) => acc + curr, 0) - t.is(result, 6) + expect(result).to.equal(6) + }) }) diff --git a/packages/it-skip/LICENSE b/packages/it-skip/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-skip/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-skip/LICENSE-APACHE b/packages/it-skip/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-skip/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-skip/LICENSE-MIT b/packages/it-skip/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-skip/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-skip/README.md b/packages/it-skip/README.md index 766ede0b..54cd9e94 100644 --- a/packages/it-skip/README.md +++ b/packages/it-skip/README.md @@ -1,17 +1,25 @@ -# it-skip +# it-skip -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-skip)](https://david-dm.org/achingbrain/it?path=packages/it-skip) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Skip items from an iterable. +> Skip items from an iterable -For when you are only interested in later values from an iterable. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-skip +```console +$ npm i it-skip ``` +For when you are only interested in later values from an iterable. + ## Usage ```javascript @@ -25,3 +33,14 @@ const arr = await all(skip(values, 2)) console.info(arr) // 2, 3, 4 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-skip/package.json b/packages/it-skip/package.json index 6f286041..6e688c62 100644 --- a/packages/it-skip/package.json +++ b/packages/it-skip/package.json @@ -2,10 +2,125 @@ "name": "it-skip", "version": "1.0.2", "description": "Skip items from an iterable", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-skip#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-skip/src/index.ts b/packages/it-skip/src/index.ts index 1a929102..53dce816 100644 --- a/packages/it-skip/src/index.ts +++ b/packages/it-skip/src/index.ts @@ -1,14 +1,8 @@ -'use strict' /** - * Skip items from an iterable. - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {number} offset - * @returns {AsyncIterable} + * Skip items from an iterable */ -const skip = async function * (source, offset) { +export default async function * skip (source: AsyncIterable|Iterable, offset: number): AsyncGenerator { for await (const entry of source) { if (offset === 0) { yield entry @@ -19,5 +13,3 @@ const skip = async function * (source, offset) { offset-- } } - -module.exports = skip diff --git a/packages/it-skip/test/index.spec.ts b/packages/it-skip/test/index.spec.ts index c902abc5..14f642cb 100644 --- a/packages/it-skip/test/index.spec.ts +++ b/packages/it-skip/test/index.spec.ts @@ -1,11 +1,13 @@ -const skip = require('./') +import { expect } from 'aegir/chai' import all from 'it-all' -const test = require('ava') +import skip from '../src/index.js' -test('Should skip values from an iterable', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-skip', () => { + it('should skip values from an iterable', async () => { + const values = [0, 1, 2, 3, 4] - const res = await all(skip(values, 2)) + const res = await all(skip(values, 2)) - t.deepEqual(res, [2, 3, 4]) + expect(res).to.deep.equal([2, 3, 4]) + }) }) diff --git a/packages/it-skip/tsconfig.json b/packages/it-skip/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-skip/tsconfig.json +++ b/packages/it-skip/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-sort/LICENSE b/packages/it-sort/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-sort/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-sort/LICENSE-APACHE b/packages/it-sort/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-sort/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-sort/LICENSE-MIT b/packages/it-sort/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-sort/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-sort/README.md b/packages/it-sort/README.md index 83da85a5..8535cd7b 100644 --- a/packages/it-sort/README.md +++ b/packages/it-sort/README.md @@ -1,13 +1,21 @@ -# it-sort +# it-sort -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-sort)](https://david-dm.org/achingbrain/it?path=packages/it-sort) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Collects all values from an async iterator, sorts them using the passed function and yields them +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) + ## Install -```sh -$ npm install --save it-sort +```console +$ npm i it-sort ``` ## Usage @@ -27,3 +35,14 @@ const arr = await all(sort(values, sorter)) console.info(arr) // 'bar', 'foo' ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-sort/package.json b/packages/it-sort/package.json index ae2edd62..ff056ee0 100644 --- a/packages/it-sort/package.json +++ b/packages/it-sort/package.json @@ -2,10 +2,125 @@ "name": "it-sort", "version": "1.0.1", "description": "Collects all values from an async iterator, sorts them using the passed function and yields them", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-sort#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,18 +134,10 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { - "it-all": "^1.0.6" + "it-all": "^1.0.0" }, "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-sort/src/index.ts b/packages/it-sort/src/index.ts index 51cb2213..886c1287 100644 --- a/packages/it-sort/src/index.ts +++ b/packages/it-sort/src/index.ts @@ -1,19 +1,15 @@ -'use strict' - import all from 'it-all' +export interface CompareFunction { + (a: T, b: T): number +} + /** * Collects all values from an async iterator, sorts them * using the passed function and yields them - * - * @template T - * @param {AsyncIterable | Iterable} source - * @param {(a: T, b: T) => -1 | 0 | 1} sorter */ -const sort = async function * (source, sorter) { +export default async function * sort (source: AsyncIterable | Iterable, sorter: CompareFunction): AsyncGenerator { const arr = await all(source) yield * arr.sort(sorter) } - -module.exports = sort diff --git a/packages/it-sort/test/index.spec.ts b/packages/it-sort/test/index.spec.ts index 042ce5e6..4321a978 100644 --- a/packages/it-sort/test/index.spec.ts +++ b/packages/it-sort/test/index.spec.ts @@ -1,14 +1,16 @@ -const sort = require('./') +import { expect } from 'aegir/chai' import all from 'it-all' -const test = require('ava') +import sort, { CompareFunction } from '../src/index.js' -test('Should sort all entries of an array', async (t) => { - const values = ['foo', 'bar'] - const sorter = (a, b) => { - return a.localeCompare(b) - } +describe('it-sort', () => { + it('should sort all entries of an array', async () => { + const values = ['foo', 'bar'] + const sorter: CompareFunction = (a, b) => { + return a.localeCompare(b) + } - const res = await all(sort(values, sorter)) + const res = await all(sort(values, sorter)) - t.deepEqual(res, ['bar', 'foo']) + expect(res).to.deep.equal(['bar', 'foo']) + }) }) diff --git a/packages/it-sort/tsconfig.json b/packages/it-sort/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-sort/tsconfig.json +++ b/packages/it-sort/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-split/LICENSE b/packages/it-split/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-split/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-split/LICENSE-APACHE b/packages/it-split/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-split/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-split/LICENSE-MIT b/packages/it-split/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-split/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-split/README.md b/packages/it-split/README.md index ed052133..a0f00b7f 100644 --- a/packages/it-split/README.md +++ b/packages/it-split/README.md @@ -1,13 +1,21 @@ -# it-split +# it-split -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-split)](https://david-dm.org/achingbrain/it?path=packages/it-split) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) > Splits Uint8Arrays emitted by an (async) iterable by a delimiter +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) + ## Install -```sh -$ npm install --save it-split +```console +$ npm i it-split ``` ## Usage @@ -43,3 +51,14 @@ const arr = await all(split(values, { console.info(arr) // [ Buffer.from([0]), Buffer.from([3, 0]), Buffer.from([3, 1]) ] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-split/package.json b/packages/it-split/package.json index a6d5a92b..37d9ee6f 100644 --- a/packages/it-split/package.json +++ b/packages/it-split/package.json @@ -2,10 +2,125 @@ "name": "it-split", "version": "1.0.2", "description": "Splits Uint8Arrays emitted by an (async) iterable by a delimiter", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-split#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,21 +134,14 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "dependencies": { "bl": "^5.0.0" }, "devDependencies": { "@types/bl": "^5.0.1", "aegir": "^37.5.0", - "it-all": "^1.0.6", + "buffer": "^6.0.3", + "it-all": "^1.0.0", "uint8arrays": "^4.0.2" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-split/src/index.ts b/packages/it-split/src/index.ts index edc0a638..e9a58d19 100644 --- a/packages/it-split/src/index.ts +++ b/packages/it-split/src/index.ts @@ -1,15 +1,13 @@ -'use strict' +import BufferList from 'bl/BufferList.js' -const BufferList = require('bl/BufferList') +export interface SplitOptions { + delimiter?: Uint8Array +} /** * Splits Uint8Arrays emitted by an (async) iterable by a delimiter - * - * @param {AsyncIterable|Iterable} source - * @param {object} [options] - * @param {Uint8Array} [options.delimiter] */ -const split = async function * (source, options = {}) { +export default async function * split (source: AsyncIterable|Iterable, options: SplitOptions = {}): AsyncGenerator { const bl = new BufferList() const delimiter = options.delimiter || new TextEncoder().encode('\n') @@ -27,12 +25,7 @@ const split = async function * (source, options = {}) { } } -/** - * - * @param {BufferList} bl - * @param {Uint8Array} delimiter - */ -async function * yieldUntilEnd (bl, delimiter) { +async function * yieldUntilEnd (bl: BufferList, delimiter: Uint8Array): AsyncGenerator { let index = bl.indexOf(delimiter) while (index !== -1) { @@ -43,5 +36,3 @@ async function * yieldUntilEnd (bl, delimiter) { index = bl.indexOf(delimiter) } } - -module.exports = split diff --git a/packages/it-split/test/index.spec.ts b/packages/it-split/test/index.spec.ts index 48040a48..a718305a 100644 --- a/packages/it-split/test/index.spec.ts +++ b/packages/it-split/test/index.spec.ts @@ -1,38 +1,41 @@ -const split = require('./') +import { expect } from 'aegir/chai' import all from 'it-all' -const test = require('ava') -const { toString } = require('uint8arrays/to-string') +import { toString } from 'uint8arrays/to-string' +import split from '../src/index.js' +import { Buffer } from 'buffer' -test('Should split Uint8Arrays by newlines', async (t) => { - const encoder = new TextEncoder() - const values = [ - encoder.encode('hello\nwor'), - encoder.encode('ld') - ] +describe('it-split', () => { + it('should split Uint8Arrays by newlines', async () => { + const encoder = new TextEncoder() + const values = [ + encoder.encode('hello\nwor'), + encoder.encode('ld') + ] - const res = await all(split(values)) + const res = await all(split(values)) - t.deepEqual(res.map(buf => toString(buf)), [ - 'hello', - 'world' - ]) -}) + expect(res.map(buf => toString(buf))).to.deep.equal([ + 'hello', + 'world' + ]) + }) -test('Should split Uint8Arrays by arbitrary delimiters', async (t) => { - const values = [ - Uint8Array.from([0, 1, 2, 3]), - Uint8Array.from([0, 1, 2, 3]), - Uint8Array.from([1, 1, 2]) - ] - const delimiter = Uint8Array.from([1, 2]) + it('should split Uint8Arrays by arbitrary delimiters', async () => { + const values = [ + Uint8Array.from([0, 1, 2, 3]), + Uint8Array.from([0, 1, 2, 3]), + Uint8Array.from([1, 1, 2]) + ] + const delimiter = Uint8Array.from([1, 2]) - const res = await all(split(values, { - delimiter - })) + const res = await all(split(values, { + delimiter + })) - t.deepEqual(res, [ - Buffer.from([0]), - Buffer.from([3, 0]), - Buffer.from([3, 1]) - ]) + expect(res).to.deep.equal([ + Buffer.from([0]), + Buffer.from([3, 0]), + Buffer.from([3, 1]) + ]) + }) }) diff --git a/packages/it-split/tsconfig.json b/packages/it-split/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-split/tsconfig.json +++ b/packages/it-split/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-take/LICENSE b/packages/it-take/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-take/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-take/LICENSE-APACHE b/packages/it-take/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-take/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-take/LICENSE-MIT b/packages/it-take/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-take/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-take/README.md b/packages/it-take/README.md index 10d8ba84..844d119f 100644 --- a/packages/it-take/README.md +++ b/packages/it-take/README.md @@ -1,17 +1,25 @@ -# it-take +# it-take -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-take)](https://david-dm.org/achingbrain/it?path=packages/it-take) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Stop iteration after n items have been received. +> Stop iteration after n items have been received -For when you only want a few values out of an iterable. +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-take +```console +$ npm i it-take ``` +For when you only want a few values out of an iterable. + ## Usage ```javascript @@ -25,3 +33,14 @@ const arr = await all(take(values, 2)) console.info(arr) // 0, 1 ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-take/package.json b/packages/it-take/package.json index e544bd55..cb87f3d7 100644 --- a/packages/it-take/package.json +++ b/packages/it-take/package.json @@ -2,10 +2,125 @@ "name": "it-take", "version": "1.0.2", "description": "Stop iteration after n items have been received", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-take#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,16 +134,8 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0", - "it-all": "^1.0.6" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "it-all": "^1.0.0" } } diff --git a/packages/it-take/src/index.ts b/packages/it-take/src/index.ts index 68a5bd34..322badc5 100644 --- a/packages/it-take/src/index.ts +++ b/packages/it-take/src/index.ts @@ -1,14 +1,8 @@ -'use strict' /** - * Stop iteration after n items have been received. - * - * @template T - * @param {AsyncIterable|Iterable} source - * @param {number} limit - * @returns {AsyncIterable} + * Stop iteration after n items have been received */ -const take = async function * (source, limit) { +export default async function * take (source: AsyncIterable|Iterable, limit: number): AsyncGenerator { let items = 0 if (limit < 1) { @@ -25,5 +19,3 @@ const take = async function * (source, limit) { } } } - -module.exports = take diff --git a/packages/it-take/test/index.spec.ts b/packages/it-take/test/index.spec.ts index f2147073..3abc178e 100644 --- a/packages/it-take/test/index.spec.ts +++ b/packages/it-take/test/index.spec.ts @@ -1,11 +1,13 @@ -const take = require('./') +import { expect } from 'aegir/chai' import all from 'it-all' -const test = require('ava') +import take from '../src/index.js' -test('Should limit the number of values returned from an iterable', async (t) => { - const values = [0, 1, 2, 3, 4] +describe('it-take', () => { + it('should limit the number of values returned from an iterable', async () => { + const values = [0, 1, 2, 3, 4] - const res = await all(take(values, 2)) + const res = await all(take(values, 2)) - t.deepEqual(res, [0, 1]) + expect(res).to.deep.equal([0, 1]) + }) }) diff --git a/packages/it-take/tsconfig.json b/packages/it-take/tsconfig.json index 13a35996..f9f4589e 100644 --- a/packages/it-take/tsconfig.json +++ b/packages/it-take/tsconfig.json @@ -6,5 +6,10 @@ "include": [ "src", "test" + ], + "references": [ + { + "path": "../it-all" + } ] } diff --git a/packages/it-to-browser-readablestream/LICENSE b/packages/it-to-browser-readablestream/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-to-browser-readablestream/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-to-browser-readablestream/LICENSE-APACHE b/packages/it-to-browser-readablestream/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-to-browser-readablestream/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-to-browser-readablestream/LICENSE-MIT b/packages/it-to-browser-readablestream/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-to-browser-readablestream/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-to-browser-readablestream/README.md b/packages/it-to-browser-readablestream/README.md index ae0bd8be..5c1970c7 100644 --- a/packages/it-to-browser-readablestream/README.md +++ b/packages/it-to-browser-readablestream/README.md @@ -1,13 +1,21 @@ -# it-to-browser-readablestream +# it-to-browser-readablestream -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-to-browser-readablestream)](https://david-dm.org/achingbrain/it?path=packages/it-to-browser-readablestream) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Takes an iterable and turns it into a WhatWG browser readablestream +> Takes an async iterator and turns it into a browser readable stream + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-to-browser-readablestream +```console +$ npm i it-to-browser-readablestream ``` ## Usage @@ -24,3 +32,14 @@ for await (const buf of stream) { console.info(buf) // Buffer[0, 1] } ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-to-browser-readablestream/package.json b/packages/it-to-browser-readablestream/package.json index 993fa3e2..f340121d 100644 --- a/packages/it-to-browser-readablestream/package.json +++ b/packages/it-to-browser-readablestream/package.json @@ -2,32 +2,138 @@ "name": "it-to-browser-readablestream", "version": "1.0.4", "description": "Takes an async iterator and turns it into a browser readable stream", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-browser-readablestream#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", "dep-check": "aegir dep-check", "clean": "aegir clean", - "test": "aegir test", - "test:node": "aegir test -t node --cov", + "test": "aegir test -t browser", "test:chrome": "aegir test -t browser --cov", "test:chrome-webworker": "aegir test -t webworker", "test:firefox": "aegir test -t browser -- --browser firefox", "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", "devDependencies": { "aegir": "^37.5.0" - }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } } } diff --git a/packages/it-to-browser-readablestream/src/index.ts b/packages/it-to-browser-readablestream/src/index.ts index 5989b097..547f4260 100644 --- a/packages/it-to-browser-readablestream/src/index.ts +++ b/packages/it-to-browser-readablestream/src/index.ts @@ -1,22 +1,17 @@ -'use strict' -/** - * @typedef {Object} SourceExt - * @property {boolean} [_cancelled] - */ -/** - * @template T - * @typedef {SourceExt & UnderlyingSource} Source - */ +interface SourceExt { + _cancelled: boolean +} + +type Source = SourceExt & UnderlyingSource /** - * @template T - * @param {AsyncIterator|Iterator} source - * @param {QueuingStrategy} [queuingStrategy] - * @returns {ReadableStream} + * Converts an (async) iterator into a WHATWG ReadableStream */ -function itToBrowserReadableStream (source, queuingStrategy = {}) { - return new globalThis.ReadableStream(/** @type {Source} */({ +export default function itToBrowserReadableStream (source: AsyncIterator|Iterator, queuingStrategy: QueuingStrategy = {}): ReadableStream { + const s: Source = { + _cancelled: false, + async start () { this._cancelled = false }, @@ -41,7 +36,7 @@ function itToBrowserReadableStream (source, queuingStrategy = {}) { cancel () { this._cancelled = true } - }), queuingStrategy) -} + } -module.exports = itToBrowserReadableStream + return new globalThis.ReadableStream(s, queuingStrategy) +} diff --git a/packages/it-to-browser-readablestream/test/index.spec.ts b/packages/it-to-browser-readablestream/test/index.spec.ts index 674adf71..49ce04f0 100644 --- a/packages/it-to-browser-readablestream/test/index.spec.ts +++ b/packages/it-to-browser-readablestream/test/index.spec.ts @@ -1,6 +1,8 @@ -const toBrowserReadbleStream = require('./') -const test = require('ava') +import { expect } from 'aegir/chai' +import toBrowserReadbleStream from '../src/index.js' -test('Should export something', async (t) => { - t.true(typeof toBrowserReadbleStream === 'function') +describe('it-to-browser-readable-stream', () => { + it('should export something', async () => { + expect(typeof toBrowserReadbleStream).to.equal('function') + }) }) diff --git a/packages/it-to-buffer/LICENSE b/packages/it-to-buffer/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/packages/it-to-buffer/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/it-to-buffer/LICENSE-APACHE b/packages/it-to-buffer/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/packages/it-to-buffer/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/it-to-buffer/LICENSE-MIT b/packages/it-to-buffer/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/packages/it-to-buffer/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/it-to-buffer/README.md b/packages/it-to-buffer/README.md index ac3d488e..97b7cab8 100644 --- a/packages/it-to-buffer/README.md +++ b/packages/it-to-buffer/README.md @@ -1,13 +1,21 @@ -# it-to-buffer +# it-to-buffer -[![Build status](https://github.com/achingbrain/it/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/achingbrain/it/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/achingbrain/it/badge.svg?branch=master)](https://coveralls.io/github/achingbrain/it?branch=master) [![Dependencies Status](https://david-dm.org/achingbrain/it/status.svg?path=packages/it-to-buffer)](https://david-dm.org/achingbrain/it?path=packages/it-to-buffer) +[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it) +[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml) -> Takes an iterable that yields buffer-like-objects and concats them into one buffer +> Takes an async iterator that yields buffers and concatenates them all together + +## Table of contents + +- [Install](#install) +- [Usage](#usage) +- [License](#license) +- [Contribute](#contribute) ## Install -```sh -$ npm install --save it-to-buffer +```console +$ npm i it-to-buffer ``` ## Usage @@ -22,3 +30,14 @@ const result = await toBuffer(values) console.info(result) // Buffer[0, 1, 2, 3] ``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/packages/it-to-buffer/package.json b/packages/it-to-buffer/package.json index 3a643cda..aa1998b1 100644 --- a/packages/it-to-buffer/package.json +++ b/packages/it-to-buffer/package.json @@ -2,10 +2,125 @@ "name": "it-to-buffer", "version": "2.0.2", "description": "Takes an async iterator that yields buffers and concatenates them all together", - "type": "module", - "repository": "github:achingbrain/it", + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/achingbrain/it/tree/master/packages/it-to-buffer#readme", - "bugs": "https://github.com/achingbrain/it/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/it.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/it/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "build": "aegir build", "lint": "aegir lint", @@ -19,18 +134,10 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, - "author": "Alex Potsides ", - "license": "ISC", - "devDependencies": { - "aegir": "^37.5.0" - }, "dependencies": { "uint8arrays": "^4.0.2" }, - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/src/index.js" - } + "devDependencies": { + "aegir": "^37.5.0" } } diff --git a/packages/it-to-buffer/src/index.ts b/packages/it-to-buffer/src/index.ts index b2b83c1b..3055ff57 100644 --- a/packages/it-to-buffer/src/index.ts +++ b/packages/it-to-buffer/src/index.ts @@ -1,13 +1,10 @@ -'use strict' - -const { concat: uint8ArrayConcat } = require('uint8arrays/concat') +import { concat as uint8ArrayConcat } from 'uint8arrays/concat' /** * Takes an (async) iterable that yields buffer-like-objects and concats them * into one buffer - * @param {AsyncIterable|Iterable} stream */ -async function toBuffer (stream) { +export default async function toBuffer (stream: AsyncIterable|Iterable): Promise { let buffer = new Uint8Array(0) for await (const buf of stream) { @@ -16,5 +13,3 @@ async function toBuffer (stream) { return buffer } - -module.exports = toBuffer diff --git a/packages/it-to-buffer/test/index.spec.ts b/packages/it-to-buffer/test/index.spec.ts index ce1746d4..f2ad41f3 100644 --- a/packages/it-to-buffer/test/index.spec.ts +++ b/packages/it-to-buffer/test/index.spec.ts @@ -1,24 +1,26 @@ -const toBuffer = require('../dist') -const test = require('ava') +import { expect } from 'aegir/chai' +import toBuffer from '../src/index.js' -test('Should turn a generator that yields buffers into a buffer', async (t) => { - const iter = function * () { - yield Uint8Array.from([0]) - yield Uint8Array.from([1]) - yield Uint8Array.from([2]) - } +describe('it-to-buffer', () => { + it('should turn a generator that yields buffers into a buffer', async () => { + const iter = function * () { + yield Uint8Array.from([0]) + yield Uint8Array.from([1]) + yield Uint8Array.from([2]) + } - const result = await toBuffer(iter()) + const result = await toBuffer(iter()) - t.deepEqual(result, Uint8Array.from([0, 1, 2])) -}) + expect(result).to.equalBytes(Uint8Array.from([0, 1, 2])) + }) -test('Should turn an array buffers into a buffer', async (t) => { - const result = await toBuffer([ - Uint8Array.from([0]), - Uint8Array.from([1]), - Uint8Array.from([2]) - ]) + it('should turn an array buffers into a buffer', async () => { + const result = await toBuffer([ + Uint8Array.from([0]), + Uint8Array.from([1]), + Uint8Array.from([2]) + ]) - t.deepEqual(result, Uint8Array.from([0, 1, 2])) + expect(result).to.equalBytes(Uint8Array.from([0, 1, 2])) + }) }) From 89ba32e86e846a0a31a79aa3e99fdf43b63875cb Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 12:48:51 +0100 Subject: [PATCH 4/8] chore: linting --- packages/blob-to-it/src/index.ts | 3 +-- .../browser-readablestream-to-it/src/index.ts | 2 +- packages/it-batch/src/index.ts | 2 +- packages/it-buffer-stream/src/index.ts | 2 +- packages/it-buffer-stream/test/index.spec.ts | 2 +- packages/it-drain/src/index.ts | 2 +- packages/it-flat-batch/src/index.ts | 2 +- packages/it-glob/src/index.ts | 8 +++---- packages/it-glob/test/index.spec.ts | 17 +++++++------- packages/it-length/src/index.ts | 2 +- packages/it-merge/src/index.ts | 4 ++-- packages/it-merge/test/index.spec.ts | 12 +++++++++- packages/it-multipart/package.json | 3 ++- packages/it-multipart/src/index.ts | 2 +- packages/it-multipart/test/index.spec.ts | 8 +++---- packages/it-ndjson/src/parse.ts | 4 ++-- packages/it-parallel-batch/src/index.ts | 6 ++--- packages/it-parallel/src/index.ts | 18 +++++++-------- packages/it-parallel/test/index.spec.ts | 2 +- packages/it-peekable/src/index.ts | 23 +++++++++---------- packages/it-split/src/index.ts | 6 ++--- .../it-to-browser-readablestream/src/index.ts | 2 +- 22 files changed, 70 insertions(+), 62 deletions(-) diff --git a/packages/blob-to-it/src/index.ts b/packages/blob-to-it/src/index.ts index d0042190..2035e548 100644 --- a/packages/blob-to-it/src/index.ts +++ b/packages/blob-to-it/src/index.ts @@ -4,11 +4,10 @@ import browserReadableStreamToIt from 'browser-readablestream-to-it' export default function blobToIt (blob: Blob): AsyncIterable { if (typeof blob.stream === 'function') { - // @ts-ignore missing some properties return browserReadableStreamToIt(blob.stream()) } // firefox < 69 does not support blob.stream() - // @ts-ignore - response.body is optional, but in practice it's a stream. + // @ts-expect-error - response.body is optional, but in practice it's a stream. return browserReadableStreamToIt(new Response(blob).body) } diff --git a/packages/browser-readablestream-to-it/src/index.ts b/packages/browser-readablestream-to-it/src/index.ts index 01d1c600..d2f000c6 100644 --- a/packages/browser-readablestream-to-it/src/index.ts +++ b/packages/browser-readablestream-to-it/src/index.ts @@ -25,7 +25,7 @@ export default async function * browserReadableStreamToIt (stream: ReadableS } } finally { if (options.preventCancel !== true) { - reader.cancel() + await reader.cancel() } reader.releaseLock() diff --git a/packages/it-batch/src/index.ts b/packages/it-batch/src/index.ts index 1faa8df3..fbbc5171 100644 --- a/packages/it-batch/src/index.ts +++ b/packages/it-batch/src/index.ts @@ -19,7 +19,7 @@ export default async function * batch (source: AsyncIterable | Iterable 0) { yield things.slice(0, size) things = things.slice(size) diff --git a/packages/it-buffer-stream/src/index.ts b/packages/it-buffer-stream/src/index.ts index 833f3dd8..da3936a7 100644 --- a/packages/it-buffer-stream/src/index.ts +++ b/packages/it-buffer-stream/src/index.ts @@ -10,7 +10,7 @@ export interface BufferStreamOptions { const defaultOptions: Required = { chunkSize: 4096, collector: () => {}, - generator: (size) => Promise.resolve(randomBytes(size)) + generator: async (size) => await Promise.resolve(randomBytes(size)) } /** diff --git a/packages/it-buffer-stream/test/index.spec.ts b/packages/it-buffer-stream/test/index.spec.ts index c43725c5..987d9c66 100644 --- a/packages/it-buffer-stream/test/index.spec.ts +++ b/packages/it-buffer-stream/test/index.spec.ts @@ -73,7 +73,7 @@ describe('it-buffer-stream', () => { const generationError = new Error('Urk!') try { - for await (const _ of bufferStream(5, { // eslint-disable-line no-unused-vars + for await (const _ of bufferStream(5, { // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars generator: async () => { throw generationError } diff --git a/packages/it-drain/src/index.ts b/packages/it-drain/src/index.ts index 5ec17508..3f007a50 100644 --- a/packages/it-drain/src/index.ts +++ b/packages/it-drain/src/index.ts @@ -3,5 +3,5 @@ * anything */ export default async function drain (source: AsyncIterable|Iterable): Promise { - for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty + for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars } diff --git a/packages/it-flat-batch/src/index.ts b/packages/it-flat-batch/src/index.ts index 235ef578..7597eb46 100644 --- a/packages/it-flat-batch/src/index.ts +++ b/packages/it-flat-batch/src/index.ts @@ -23,7 +23,7 @@ export default async function * batch (source: AsyncIterable|Iterable 0) { yield things.slice(0, size) things = things.slice(size) diff --git a/packages/it-glob/src/index.ts b/packages/it-glob/src/index.ts index b65b99a5..e286896d 100644 --- a/packages/it-glob/src/index.ts +++ b/packages/it-glob/src/index.ts @@ -25,7 +25,7 @@ export interface GlobOptions extends IOptions { */ export default async function * glob (dir: string, pattern: string, options: GlobOptions = {}): AsyncGenerator { const absoluteDir = path.resolve(dir) - const relativeDir = path.relative(options.cwd || process.cwd(), dir) + const relativeDir = path.relative(options.cwd ?? process.cwd(), dir) const stats = await fs.stat(absoluteDir) @@ -38,7 +38,7 @@ export default async function * glob (dir: string, pattern: string, options: Glo } if (minimatch(relativeDir, pattern, options)) { - yield options.absolute ? absoluteDir : relativeDir + yield options.absolute === true ? absoluteDir : relativeDir } } @@ -51,12 +51,12 @@ async function * _glob (base: string, dir: string, pattern: string, options: Glo const isDirectory = entry.isDirectory() - if (isDirectory && options.nodir) { + if (isDirectory && options.nodir === true) { match = false } if (match) { - yield options.absolute ? absoluteEntryPath : relativeEntryPath + yield options.absolute === true ? absoluteEntryPath : relativeEntryPath } if (isDirectory) { diff --git a/packages/it-glob/test/index.spec.ts b/packages/it-glob/test/index.spec.ts index 3d22b687..9e4566d2 100644 --- a/packages/it-glob/test/index.spec.ts +++ b/packages/it-glob/test/index.spec.ts @@ -1,11 +1,10 @@ import { expect } from 'aegir/chai' import all from 'it-all' import glob from '../src/index.js' -import path from 'path' -import { dirname } from 'path' +import path, { dirname } from 'path' import { fileURLToPath } from 'url' -const __dirname = dirname(fileURLToPath(import.meta.url)) +const dir = dirname(fileURLToPath(import.meta.url)) describe('it-glob', () => { it('should match file', async () => { @@ -39,13 +38,13 @@ describe('it-glob', () => { }) it('should ignore files from absolute directory', async () => { - const files = await all(glob(__dirname, '**/*!(test/index.js|)**/dist/**')) + const files = await all(glob(dir, '**/*!(test/index.js|)**/dist/**')) - expect(files.includes(path.resolve(__dirname, 'index.js'))).to.be.false() + expect(files.includes(path.resolve(dir, 'index.js'))).to.be.false() }) it('should return absolute paths', async () => { - const files = await all(glob(__dirname, '**/*', { + const files = await all(glob(dir, '**/*', { absolute: true })) @@ -55,7 +54,7 @@ describe('it-glob', () => { }) it('should return relative paths', async () => { - const files = await all(glob(__dirname, '**/*', { + const files = await all(glob(dir, '**/*', { absolute: false })) @@ -65,13 +64,13 @@ describe('it-glob', () => { }) it('should match directories', async () => { - const files = await all(glob(path.resolve(__dirname, '..', '..'), 'dist/*')) + const files = await all(glob(path.resolve(dir, '..', '..'), 'dist/*')) expect(files.includes(path.join('dist', 'src'))).to.be.true() }) it('should skip directories', async () => { - const files = await all(glob(path.resolve(__dirname, '..', '..'), 'dist/**/*', { + const files = await all(glob(path.resolve(dir, '..', '..'), 'dist/**/*', { nodir: true, dot: true })) diff --git a/packages/it-length/src/index.ts b/packages/it-length/src/index.ts index 3ef31549..7eb21b2f 100644 --- a/packages/it-length/src/index.ts +++ b/packages/it-length/src/index.ts @@ -4,7 +4,7 @@ export default async function length (iterator: AsyncIterable | Iterable): Promise { let count = 0 - for await (const _ of iterator) { // eslint-disable-line no-unused-vars + for await (const _ of iterator) { // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars count++ } diff --git a/packages/it-merge/src/index.ts b/packages/it-merge/src/index.ts index abb83c6c..7c27cc4b 100644 --- a/packages/it-merge/src/index.ts +++ b/packages/it-merge/src/index.ts @@ -9,7 +9,7 @@ import pushable from 'it-pushable' export default async function * merge (...sources: Array|Iterable>): AsyncGenerator { const output = pushable() - setTimeout(async () => { + void Promise.resolve().then(async () => { try { await Promise.all( sources.map(async (source) => { @@ -23,7 +23,7 @@ export default async function * merge (...sources: Array|It } catch (err: any) { output.end(err) } - }, 0) + }) yield * output } diff --git a/packages/it-merge/test/index.spec.ts b/packages/it-merge/test/index.spec.ts index b6372778..38f39880 100644 --- a/packages/it-merge/test/index.spec.ts +++ b/packages/it-merge/test/index.spec.ts @@ -9,6 +9,16 @@ describe('it-merge', () => { const res = await all(merge(values1, values2)) - expect(res.sort()).to.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + expect(res.sort((a, b) => { + if (a < b) { + return -1 + } + + if (a > b) { + return 1 + } + + return 0 + })).to.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) }) }) diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index d1088210..33501ca7 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -139,7 +139,8 @@ "aegir": "^37.5.0", "form-data": "^3.0.0", "it-drain": "^1.0.5", - "node-fetch": "^3.2.10" + "node-fetch": "^3.2.10", + "uint8arrays": "^4.0.2" }, "browser": { "http": false, diff --git a/packages/it-multipart/src/index.ts b/packages/it-multipart/src/index.ts index dc001b57..f6f2a6dc 100644 --- a/packages/it-multipart/src/index.ts +++ b/packages/it-multipart/src/index.ts @@ -13,7 +13,7 @@ export interface Part { export default async function * multipart (request: IncomingMessage): AsyncGenerator { const output = pushable() - if (!request) { + if (request == null) { output.end(new Error('request missing')) yield * output diff --git a/packages/it-multipart/test/index.spec.ts b/packages/it-multipart/test/index.spec.ts index b0d0e887..cb0920b2 100644 --- a/packages/it-multipart/test/index.spec.ts +++ b/packages/it-multipart/test/index.spec.ts @@ -4,6 +4,7 @@ import handler from '../src/index.js' import fetch from 'node-fetch' import FormData from 'form-data' import drain from 'it-drain' +import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import type { Server, IncomingMessage } from 'http' describe('it-multipart', () => { @@ -15,13 +16,13 @@ describe('it-multipart', () => { const files: Record = {} for await (const part of handler(req)) { - // @ts-ignore - header may not be present + // @ts-expect-error - header may not be present const name = part.headers['content-disposition'].match(/name="(.*)"/)[1] files[name] = '' for await (const str of part.body) { - files[name] += str + files[name] += uint8ArrayToString(str) } } @@ -39,7 +40,7 @@ describe('it-multipart', () => { res.end(files) }) .catch(err => { - if (err.message.includes('bad content-type header')) { + if (err.message.includes('bad content-type header') === true) { res.writeHead(400) } else { res.writeHead(500) @@ -49,7 +50,6 @@ describe('it-multipart', () => { }) }) server.on('error', (err) => { - console.info('start failed', err) reject(err) }) server.listen(() => { diff --git a/packages/it-ndjson/src/parse.ts b/packages/it-ndjson/src/parse.ts index efa5698a..98d30c6e 100644 --- a/packages/it-ndjson/src/parse.ts +++ b/packages/it-ndjson/src/parse.ts @@ -11,7 +11,7 @@ export default async function * parse (source: AsyncIterable (source: AsyncIterable (source: AsyncIterable<() => Promise>|Iterable<() => Promise>, size: number = 1): AsyncGenerator { for await (const tasks of batch(source, size)) { - const things: Promise|Failure>[] = tasks.map( - (p: () => Promise) => { - return p().then(value => ({ ok: true, value }), err => ({ ok: false, err })) + const things: Array|Failure>> = tasks.map( + async (p: () => Promise) => { + return await p().then(value => ({ ok: true, value }), err => ({ ok: false, err })) }) for (let i = 0; i < things.length; i++) { diff --git a/packages/it-parallel/src/index.ts b/packages/it-parallel/src/index.ts index 21bea5f3..96713d97 100644 --- a/packages/it-parallel/src/index.ts +++ b/packages/it-parallel/src/index.ts @@ -9,7 +9,7 @@ interface Operation { value: T } -const CustomEvent = globalThis.CustomEvent || Event +const CustomEvent = globalThis.CustomEvent ?? Event export interface ParallelOptions { /** @@ -25,7 +25,7 @@ export interface ParallelOptions { * in the same order as the input */ export default async function * parallel (source: Iterable<() => Promise> | AsyncIterable<() => Promise>, options: ParallelOptions = {}): AsyncGenerator { - let concurrency = options.concurrency || Infinity + let concurrency = options.concurrency ?? Infinity if (concurrency < 1) { concurrency = Infinity @@ -34,18 +34,18 @@ export default async function * parallel (source: Iterable<() => Promise> const ordered = options.ordered == null ? false : options.ordered const emitter = new EventTarget() - const ops: Operation[] = [] + const ops: Array> = [] let slotAvailable = defer() let resultAvailable = defer() let sourceFinished = false - let sourceErr + let sourceErr: Error | undefined let opErred = false emitter.addEventListener('task-complete', () => { resultAvailable.resolve() }) - Promise.resolve().then(async () => { + void Promise.resolve().then(async () => { try { for await (const task of source) { if (ops.length === concurrency) { @@ -77,7 +77,7 @@ export default async function * parallel (source: Iterable<() => Promise> sourceFinished = true emitter.dispatchEvent(new CustomEvent('task-complete')) - } catch (err) { + } catch (err: any) { sourceErr = err emitter.dispatchEvent(new CustomEvent('task-complete')) } @@ -85,14 +85,14 @@ export default async function * parallel (source: Iterable<() => Promise> function valuesAvailable () { if (ordered) { - return Boolean(ops[0] && ops[0].done) + return ops[0]?.done } return Boolean(ops.find(op => op.done)) } function * yieldOrderedValues () { - while (ops.length && ops[0].done) { + while ((ops.length > 0) && ops[0].done) { const op = ops[0] ops.shift() @@ -141,7 +141,7 @@ export default async function * parallel (source: Iterable<() => Promise> await resultAvailable.promise } - if (sourceErr) { + if (sourceErr != null) { // the source threw an error, propagate it throw sourceErr } diff --git a/packages/it-parallel/test/index.spec.ts b/packages/it-parallel/test/index.spec.ts index 3e064a2c..b72e9e51 100644 --- a/packages/it-parallel/test/index.spec.ts +++ b/packages/it-parallel/test/index.spec.ts @@ -156,7 +156,7 @@ describe('it-parallel', () => { const value = values[index] index++ - return Promise.resolve({ + return await Promise.resolve({ done: index === values.length, value }) diff --git a/packages/it-peekable/src/index.ts b/packages/it-peekable/src/index.ts index 2b965205..9fc15f88 100644 --- a/packages/it-peekable/src/index.ts +++ b/packages/it-peekable/src/index.ts @@ -1,5 +1,4 @@ - interface Peek { peek: () => IteratorResult } @@ -9,7 +8,7 @@ interface AsyncPeek { } interface Push { - push: (value:T) => void + push: (value: T) => void } type Peekable = Iterable & Peek & Push & Iterator @@ -17,20 +16,20 @@ type Peekable = Iterable & Peek & Push & Iterator type AsyncPeekable = AsyncIterable & AsyncPeek & Push & AsyncIterator export default function peekableIterator | AsyncIterable> (iterable: I): I extends Iterable - ? Peekable - : I extends AsyncIterable - ? AsyncPeekable - : never { - // @ts-ignore - const [iterator, symbol] = iterable[Symbol.asyncIterator] - // @ts-ignore + ? Peekable + : I extends AsyncIterable + ? AsyncPeekable + : never { + // @ts-expect-error + const [iterator, symbol] = iterable[Symbol.asyncIterator] != null + // @ts-expect-error ? [iterable[Symbol.asyncIterator](), Symbol.asyncIterator] - // @ts-ignore + // @ts-expect-error : [iterable[Symbol.iterator](), Symbol.iterator] const queue: any[] = [] - // @ts-ignore + // @ts-expect-error return { peek: () => { return iterator.next() @@ -39,7 +38,7 @@ export default function peekableIterator | AsyncIterable queue.push(value) }, next: () => { - if (queue.length) { + if (queue.length > 0) { return { done: false, value: queue.shift() diff --git a/packages/it-split/src/index.ts b/packages/it-split/src/index.ts index e9a58d19..b2ee07e4 100644 --- a/packages/it-split/src/index.ts +++ b/packages/it-split/src/index.ts @@ -9,10 +9,10 @@ export interface SplitOptions { */ export default async function * split (source: AsyncIterable|Iterable, options: SplitOptions = {}): AsyncGenerator { const bl = new BufferList() - const delimiter = options.delimiter || new TextEncoder().encode('\n') + const delimiter = options.delimiter ?? new TextEncoder().encode('\n') for await (const buf of source) { - // @ts-ignore Uint8Array type is missing from add signature + // @ts-expect-error Uint8Array type is missing from add signature bl.append(buf) yield * yieldUntilEnd(bl, delimiter) @@ -20,7 +20,7 @@ export default async function * split (source: AsyncIterable|Iterabl yield * yieldUntilEnd(bl, delimiter) - if (bl.length) { + if (bl.length > 0) { yield bl.slice() } } diff --git a/packages/it-to-browser-readablestream/src/index.ts b/packages/it-to-browser-readablestream/src/index.ts index 547f4260..817ea605 100644 --- a/packages/it-to-browser-readablestream/src/index.ts +++ b/packages/it-to-browser-readablestream/src/index.ts @@ -23,7 +23,7 @@ export default function itToBrowserReadableStream (source: AsyncIterator| return } - if (done) { + if (done === true) { controller.close() return } From 08bfc17edead28d272c932f473d609296060a669 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 12:49:34 +0100 Subject: [PATCH 5/8] chore: add dep-check --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 592dc469..ca5626d9 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "start": "NODE_ENV=development lerna run start", "clean": "lerna run clean", "lint": "lerna run lint", + "dep-check": "lerna run dep-check", "check": "lerna run check", "publish": "lerna publish" }, From 00036c82eca83a44f32e985f0194f7ce8d971017 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 14 Oct 2022 13:10:27 +0100 Subject: [PATCH 6/8] chore: update readme examples --- packages/blob-to-it/README.md | 2 +- packages/browser-readablestream-to-it/README.md | 2 +- packages/it-batch/README.md | 2 +- packages/it-buffer-stream/README.md | 2 ++ packages/it-drain/README.md | 2 +- packages/it-filter/README.md | 2 +- packages/it-first/README.md | 2 +- packages/it-flat-batch/README.md | 2 +- packages/it-foreach/README.md | 4 ++-- packages/it-glob/README.md | 2 +- packages/it-last/README.md | 2 +- packages/it-length/README.md | 2 +- packages/it-map/README.md | 2 +- packages/it-merge/README.md | 3 ++- packages/it-multipart/README.md | 4 ++-- packages/it-ndjson/README.md | 2 +- packages/it-parallel-batch/README.md | 2 +- packages/it-parallel/README.md | 2 +- packages/it-peekable/README.md | 2 +- packages/it-reduce/README.md | 2 +- packages/it-skip/README.md | 2 +- packages/it-sort/README.md | 2 +- packages/it-split/README.md | 3 ++- packages/it-take/README.md | 2 +- packages/it-to-browser-readablestream/README.md | 2 +- packages/it-to-buffer/README.md | 2 +- 26 files changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/blob-to-it/README.md b/packages/blob-to-it/README.md index 4106d040..29051c82 100644 --- a/packages/blob-to-it/README.md +++ b/packages/blob-to-it/README.md @@ -21,7 +21,7 @@ $ npm i blob-to-it ## Usage ```javascript -const toIt = require('blob-to-it') +import toIt from 'blob-to-it' import all from 'it-all' const content = [ Uint8Array.from([0, 1, 2, 3, 4]) ] diff --git a/packages/browser-readablestream-to-it/README.md b/packages/browser-readablestream-to-it/README.md index 66aed4f9..cd99078e 100644 --- a/packages/browser-readablestream-to-it/README.md +++ b/packages/browser-readablestream-to-it/README.md @@ -22,7 +22,7 @@ $ npm i browser-readablestream-to-it ## Usage ```javascript -const toIt = require('browser-readablestream-to-it') +import toIt from 'browser-readablestream-to-it' import all from 'it-all' const content = [0, 1, 2, 3, 4] diff --git a/packages/it-batch/README.md b/packages/it-batch/README.md index 9218f12f..2493ec55 100644 --- a/packages/it-batch/README.md +++ b/packages/it-batch/README.md @@ -23,7 +23,7 @@ The final batch may be smaller than the max. ## Usage ```javascript -const batch = require('it-batch') +import batch from 'it-batch' import all from 'it-all' // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-buffer-stream/README.md b/packages/it-buffer-stream/README.md index fd4d4066..6a46afbb 100644 --- a/packages/it-buffer-stream/README.md +++ b/packages/it-buffer-stream/README.md @@ -21,6 +21,8 @@ $ npm i it-buffer-stream ## Usage ```javascript +import bufferStream from 'it-buffer-stream' + const totalLength = //... a big number // all options are optional, defaults are shown diff --git a/packages/it-drain/README.md b/packages/it-drain/README.md index 3430aa46..2d3d933b 100644 --- a/packages/it-drain/README.md +++ b/packages/it-drain/README.md @@ -23,7 +23,7 @@ Mostly useful for tests or when you want to be explicit about consuming an itera ## Usage ```javascript -const drain = require('it-drain') +import drain from 'it-drain' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-filter/README.md b/packages/it-filter/README.md index 1d35e2ab..dc3701b4 100644 --- a/packages/it-filter/README.md +++ b/packages/it-filter/README.md @@ -22,7 +22,7 @@ $ npm i it-filter ```javascript import all from 'it-all' -const filter = require('it-filter') +import filter from 'it-filter' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-first/README.md b/packages/it-first/README.md index dc59df57..e8fc4d54 100644 --- a/packages/it-first/README.md +++ b/packages/it-first/README.md @@ -23,7 +23,7 @@ Mostly useful for tests. ## Usage ```javascript -const first = require('it-first') +import first from 'it-first' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-flat-batch/README.md b/packages/it-flat-batch/README.md index b0d01f89..e8aeaeae 100644 --- a/packages/it-flat-batch/README.md +++ b/packages/it-flat-batch/README.md @@ -23,7 +23,7 @@ The final batch may be smaller than requested batch size. ## Usage ```javascript -const batch = require('it-flat-batch') +import batch from 'it-flat-batch' import all from 'it-all' // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-foreach/README.md b/packages/it-foreach/README.md index 8294d2ed..71c5160f 100644 --- a/packages/it-foreach/README.md +++ b/packages/it-foreach/README.md @@ -23,8 +23,8 @@ For when you need a one-liner to collect iterable values. ## Usage ```javascript -const each = require('it-foreach') -const drain = require('it-drain') +import each from 'it-foreach' +import drain from 'it-drain' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-glob/README.md b/packages/it-glob/README.md index 6f3a1af7..df22b57d 100644 --- a/packages/it-glob/README.md +++ b/packages/it-glob/README.md @@ -23,7 +23,7 @@ Like [`glob`](https://npmjs.com/package/glob) but async iterable. ## Usage ```javascript -const glob = require('it-glob') +import glob from 'it-glob' const options = { cwd // defaults to process.cwd diff --git a/packages/it-last/README.md b/packages/it-last/README.md index 0cb2ddd0..d87900d0 100644 --- a/packages/it-last/README.md +++ b/packages/it-last/README.md @@ -23,7 +23,7 @@ Mostly useful for tests. ## Usage ```javascript -const last = require('it-last') +import last from 'it-last' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-length/README.md b/packages/it-length/README.md index b1499574..5bbadcc1 100644 --- a/packages/it-length/README.md +++ b/packages/it-length/README.md @@ -23,7 +23,7 @@ N.b. will consume the iterable ## Usage ```javascript -const length = require('it-length') +import length from 'it-length' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-map/README.md b/packages/it-map/README.md index b90c42e1..c7c5a2a0 100644 --- a/packages/it-map/README.md +++ b/packages/it-map/README.md @@ -21,7 +21,7 @@ $ npm i it-map ## Usage ```javascript -const map = require('it-map') +import map from 'it-map' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-merge/README.md b/packages/it-merge/README.md index f2bedaa9..7b753812 100644 --- a/packages/it-merge/README.md +++ b/packages/it-merge/README.md @@ -23,7 +23,8 @@ Nb. sources are iterated over in parallel so the order of emitted items is not g ## Usage ```javascript -const all = require('it-merge') +import merge from 'it-merge' +import all from 'it-all' // This can also be an iterator, async iterator, generator, etc const values1 = [0, 1, 2, 3, 4] diff --git a/packages/it-multipart/README.md b/packages/it-multipart/README.md index c4d3e6b2..903bac43 100644 --- a/packages/it-multipart/README.md +++ b/packages/it-multipart/README.md @@ -21,8 +21,8 @@ $ npm i it-multipart ## Example ```javascript -const http = require('http') -const multipart = require('it-multipart') +import http from 'http' +import multipart from 'it-multipart' http.createServer(async (req, res) => { if (req.method === 'POST' && req.headers['content-type']) { diff --git a/packages/it-ndjson/README.md b/packages/it-ndjson/README.md index 510bf379..4bf603e8 100644 --- a/packages/it-ndjson/README.md +++ b/packages/it-ndjson/README.md @@ -21,7 +21,7 @@ $ npm i it-ndjson ## Usage ```javascript -const ndjson = require('it-ndjson') +import ndjson from 'it-ndjson' import all from 'it-all' // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-parallel-batch/README.md b/packages/it-parallel-batch/README.md index 21aae28c..2d92bcaa 100644 --- a/packages/it-parallel-batch/README.md +++ b/packages/it-parallel-batch/README.md @@ -23,7 +23,7 @@ The final batch may be smaller than the batch size. ## Usage ```javascript -const parallelBatch = require('it-parallel-batch') +import parallelBatch from 'it-parallel-batch' import all from 'it-all' import delay from 'delay' diff --git a/packages/it-parallel/README.md b/packages/it-parallel/README.md index 3c781c40..b003277e 100644 --- a/packages/it-parallel/README.md +++ b/packages/it-parallel/README.md @@ -21,7 +21,7 @@ $ npm i it-parallel ## Usage ```javascript -const parallel = require('it-parallel') +import parallel from 'it-parallel' import all from 'it-all' import delay from 'delay' diff --git a/packages/it-peekable/README.md b/packages/it-peekable/README.md index 852879f9..34e5c7f6 100644 --- a/packages/it-peekable/README.md +++ b/packages/it-peekable/README.md @@ -23,7 +23,7 @@ Lets you look at the contents of an async iterator and decide what to do ## Usage ```javascript -const peekable = require('it-peekable') +import peekable from 'it-peekable' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-reduce/README.md b/packages/it-reduce/README.md index 50d1e7e9..d6058925 100644 --- a/packages/it-reduce/README.md +++ b/packages/it-reduce/README.md @@ -23,7 +23,7 @@ Mostly useful for tests or when you want to be explicit about consuming an itera ## Usage ```javascript -const reduce = require('it-reduce') +import reduce from 'it-reduce' // This can also be an iterator, async iterator, generator, etc const values = [0, 1, 2, 3, 4] diff --git a/packages/it-skip/README.md b/packages/it-skip/README.md index 54cd9e94..54aa6004 100644 --- a/packages/it-skip/README.md +++ b/packages/it-skip/README.md @@ -23,7 +23,7 @@ For when you are only interested in later values from an iterable. ## Usage ```javascript -const take = require('it-skip') +import take from 'it-skip' import all from 'it-all' // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-sort/README.md b/packages/it-sort/README.md index 8535cd7b..3d3af7d6 100644 --- a/packages/it-sort/README.md +++ b/packages/it-sort/README.md @@ -21,7 +21,7 @@ $ npm i it-sort ## Usage ```javascript -const sort = require('it-sort') +import sort from 'it-sort' import all from 'it-all' const sorter = (a, b) => { diff --git a/packages/it-split/README.md b/packages/it-split/README.md index a0f00b7f..6bac2672 100644 --- a/packages/it-split/README.md +++ b/packages/it-split/README.md @@ -21,7 +21,8 @@ $ npm i it-split ## Usage ```javascript -const split = require('it-split') +import split from 'it-split' + const encoder = new TextEncoder() // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-take/README.md b/packages/it-take/README.md index 844d119f..daa891c1 100644 --- a/packages/it-take/README.md +++ b/packages/it-take/README.md @@ -23,7 +23,7 @@ For when you only want a few values out of an iterable. ## Usage ```javascript -const take = require('it-take') +import take from 'it-take' import all from 'it-all' // This can also be an iterator, async iterator, generator, etc diff --git a/packages/it-to-browser-readablestream/README.md b/packages/it-to-browser-readablestream/README.md index 5c1970c7..df502e78 100644 --- a/packages/it-to-browser-readablestream/README.md +++ b/packages/it-to-browser-readablestream/README.md @@ -21,7 +21,7 @@ $ npm i it-to-browser-readablestream ## Usage ```javascript -const toBrowserReadableStream = require('it-to-browser-readablestream') +import toBrowserReadableStream from 'it-to-browser-readablestream' // This can also be an iterator, async iterator, generator, etc const values = [Buffer.from([0, 1]), Buffer.from([2, 3])] diff --git a/packages/it-to-buffer/README.md b/packages/it-to-buffer/README.md index 97b7cab8..b02fb4df 100644 --- a/packages/it-to-buffer/README.md +++ b/packages/it-to-buffer/README.md @@ -21,7 +21,7 @@ $ npm i it-to-buffer ## Usage ```javascript -const toBuffer = require('it-to-buffer') +import toBuffer from 'it-to-buffer' // This can also be an iterator, async iterator, generator, etc const values = [Buffer.from([0, 1]), Buffer.from([2, 3])] From 60acd2a43f1f78f4bb1e322b457dafd7f840492d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 17 Oct 2022 07:06:54 +0100 Subject: [PATCH 7/8] chore: update all deps --- packages/it-buffer-stream/package.json | 2 +- packages/it-buffer-stream/src/index.ts | 1 - packages/it-glob/package.json | 4 ++-- packages/it-merge/package.json | 2 +- packages/it-merge/src/index.ts | 6 ++++-- packages/it-multipart/package.json | 8 ++++---- packages/it-multipart/src/index.ts | 9 ++++++--- packages/it-multipart/test/index.spec.ts | 2 +- packages/it-parallel-batch/package.json | 2 +- packages/it-parallel/package.json | 4 ++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/it-buffer-stream/package.json b/packages/it-buffer-stream/package.json index 2e04c78d..21e994a0 100644 --- a/packages/it-buffer-stream/package.json +++ b/packages/it-buffer-stream/package.json @@ -135,7 +135,7 @@ "release": "aegir release" }, "dependencies": { - "iso-random-stream": "^1.1.1" + "iso-random-stream": "^2.0.2" }, "devDependencies": { "aegir": "^37.5.0", diff --git a/packages/it-buffer-stream/src/index.ts b/packages/it-buffer-stream/src/index.ts index da3936a7..9755fdab 100644 --- a/packages/it-buffer-stream/src/index.ts +++ b/packages/it-buffer-stream/src/index.ts @@ -1,4 +1,3 @@ -// @ts-expect-error - untyped dependency import randomBytes from 'iso-random-stream/src/random.js' export interface BufferStreamOptions { diff --git a/packages/it-glob/package.json b/packages/it-glob/package.json index 55262374..bc2c448f 100644 --- a/packages/it-glob/package.json +++ b/packages/it-glob/package.json @@ -131,8 +131,8 @@ "release": "aegir release" }, "dependencies": { - "@types/minimatch": "^3.0.4", - "minimatch": "^3.0.4" + "@types/minimatch": "^5.1.2", + "minimatch": "^5.1.0" }, "devDependencies": { "aegir": "^37.5.0", diff --git a/packages/it-merge/package.json b/packages/it-merge/package.json index a60c3956..405bd079 100644 --- a/packages/it-merge/package.json +++ b/packages/it-merge/package.json @@ -135,7 +135,7 @@ "release": "aegir release" }, "dependencies": { - "it-pushable": "^1.4.2" + "it-pushable": "^3.1.0" }, "devDependencies": { "aegir": "^37.5.0", diff --git a/packages/it-merge/src/index.ts b/packages/it-merge/src/index.ts index 7c27cc4b..7ff40fd5 100644 --- a/packages/it-merge/src/index.ts +++ b/packages/it-merge/src/index.ts @@ -1,4 +1,4 @@ -import pushable from 'it-pushable' +import { pushable } from 'it-pushable' /** * Treat one or more iterables as a single iterable. @@ -7,7 +7,9 @@ import pushable from 'it-pushable' * order of emitted items is not guaranteed. */ export default async function * merge (...sources: Array|Iterable>): AsyncGenerator { - const output = pushable() + const output = pushable({ + objectMode: true + }) void Promise.resolve().then(async () => { try { diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index 33501ca7..0bc04990 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -131,13 +131,13 @@ "release": "aegir release" }, "dependencies": { - "formidable": "^1.2.2", - "it-pushable": "^1.4.2" + "formidable": "^2.0.1", + "it-pushable": "^3.1.0" }, "devDependencies": { - "@types/formidable": "^1.2.1", + "@types/formidable": "^2.0.5", "aegir": "^37.5.0", - "form-data": "^3.0.0", + "form-data": "^4.0.0", "it-drain": "^1.0.5", "node-fetch": "^3.2.10", "uint8arrays": "^4.0.2" diff --git a/packages/it-multipart/src/index.ts b/packages/it-multipart/src/index.ts index f6f2a6dc..a5480f68 100644 --- a/packages/it-multipart/src/index.ts +++ b/packages/it-multipart/src/index.ts @@ -1,5 +1,5 @@ import formidable from 'formidable' -import pushable from 'it-pushable' +import { pushable } from 'it-pushable' import type { IncomingMessage, IncomingHttpHeaders } from 'http' export interface Part { @@ -11,7 +11,9 @@ export interface Part { * Streaming multipart HTTP message parser */ export default async function * multipart (request: IncomingMessage): AsyncGenerator { - const output = pushable() + const output = pushable({ + objectMode: true + }) if (request == null) { output.end(new Error('request missing')) @@ -28,7 +30,7 @@ export default async function * multipart (request: IncomingMessage): AsyncGener }) form.onPart = (part) => { - const body = pushable() + const body = pushable() part.on('data', buf => { body.push(buf) @@ -41,6 +43,7 @@ export default async function * multipart (request: IncomingMessage): AsyncGener }) output.push({ + // @ts-expect-error headers is not part of formidable api but is present headers: part.headers, body }) diff --git a/packages/it-multipart/test/index.spec.ts b/packages/it-multipart/test/index.spec.ts index cb0920b2..5088599c 100644 --- a/packages/it-multipart/test/index.spec.ts +++ b/packages/it-multipart/test/index.spec.ts @@ -40,7 +40,7 @@ describe('it-multipart', () => { res.end(files) }) .catch(err => { - if (err.message.includes('bad content-type header') === true) { + if (err.message.includes('bad content-type header') || err.message.includes('no parser found')) { res.writeHead(400) } else { res.writeHead(500) diff --git a/packages/it-parallel-batch/package.json b/packages/it-parallel-batch/package.json index 770d8398..2ecf374e 100644 --- a/packages/it-parallel-batch/package.json +++ b/packages/it-parallel-batch/package.json @@ -139,7 +139,7 @@ }, "devDependencies": { "aegir": "^37.5.0", - "delay": "^4.3.0", + "delay": "^5.0.0", "it-all": "^1.0.0" } } diff --git a/packages/it-parallel/package.json b/packages/it-parallel/package.json index c7ab4dd2..a06457ba 100644 --- a/packages/it-parallel/package.json +++ b/packages/it-parallel/package.json @@ -135,11 +135,11 @@ "release": "aegir release" }, "dependencies": { - "p-defer": "^3.0.0" + "p-defer": "^4.0.0" }, "devDependencies": { "aegir": "^37.5.0", - "delay": "^4.3.0", + "delay": "^5.0.0", "it-all": "^1.0.0" } } From 57465a1d6ac715717e320c1b72043d854c76322d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 17 Oct 2022 07:13:53 +0100 Subject: [PATCH 8/8] chore: linting --- packages/it-multipart/test/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/it-multipart/test/index.spec.ts b/packages/it-multipart/test/index.spec.ts index 5088599c..3caf9af0 100644 --- a/packages/it-multipart/test/index.spec.ts +++ b/packages/it-multipart/test/index.spec.ts @@ -40,7 +40,7 @@ describe('it-multipart', () => { res.end(files) }) .catch(err => { - if (err.message.includes('bad content-type header') || err.message.includes('no parser found')) { + if (err.message.includes('bad content-type header') === true || err.message.includes('no parser found') === true) { res.writeHead(400) } else { res.writeHead(500)