From f86f8484b11d100520523e165c7363601b7226f4 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 10 Jan 2022 08:20:22 +0000 Subject: [PATCH] chore: intial commit --- .github/dependabot.yml | 8 +++ .github/workflows/main.yml | 125 +++++++++++++++++++++++++++++++++++++ .gitignore | 5 ++ LICENSE | 2 + LICENSE-APACHE | 5 ++ LICENSE-MIT | 19 ++++++ README.md | 29 +++++++++ package.json | 108 ++++++++++++++++++++++++++++++++ src/index.ts | 13 ++++ tsconfig.json | 12 ++++ 10 files changed, 326 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..de46e32 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "11:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c9772b6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,125 @@ +name: test & maybe release +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + 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@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@v1 + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test: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' + steps: + - uses: actions/checkout@v2.4.0 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_USERNAME }} + 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/.gitignore b/.gitignore new file mode 100644 index 0000000..c4c0f8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +coverage +.nyc_output +package-lock.json +dist \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b0b237f --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 \ No newline at end of file diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..14478a3 --- /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 0000000..749aa1e --- /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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..535fb8b --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# it-stream-types + +[![Build Status](https://github.com/achingbrain/it-stream-types/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/achingbrain/it-stream-types/actions/new) +[![Dependencies Status](https://david-dm.org/achingbrain/it-stream-types/status.svg)](https://david-dm.org/achingbrain/it-stream-types) +[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) + +> Typescript types for sink/source/duplex streams + +## Install + +```sh +npm i it-stream-types +``` + +## Usage + +```js +import type { Duplex } from 'it-stream-types' + +... +``` + +## Contribute + +Feel free to dive in! [Open an issue](https://github.com/achingbrain/stream-types/issues/new) or submit PRs. + +## License + +[Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) diff --git a/package.json b/package.json new file mode 100644 index 0000000..1b8c657 --- /dev/null +++ b/package.json @@ -0,0 +1,108 @@ +{ + "name": "it-stream-types", + "version": "0.0.1", + "description": "Typescript types for AsyncIterable sink/source/duplex streams", + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist/src", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "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": "chore", + "release": "patch" + }, { + "type": "docs", + "release": "patch" + }, { + "type": "test", + "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": "Trivial Changes" + }, { + "type": "test", + "section": "Tests" + }] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, + "scripts": { + "lint": "aegir lint", + "dep-check": "aegir dep-check dist/src/**/*.js dist/test/**/*.js", + "build": "tsc", + "release": "semantic-release" + }, + "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", + "devDependencies": { + "aegir": "^36.1.3" + }, + "dependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/achingbrain/stream-types.git" + }, + "bugs": { + "url": "https://github.com/achingbrain/stream-types/issues" + }, + "homepage": "https://github.com/achingbrain/stream-types#readme" +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..f8711d4 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,13 @@ + +export interface Sink { + (source: AsyncIterable): Promise +} + +export interface Source { + (source: AsyncIterable): Promise +} + +export interface Duplex { + source: Source + sink: Sink +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f296f99 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist", + "emitDeclarationOnly": false, + "module": "ES2020" + }, + "include": [ + "src", + "test" + ] +}