diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 62c76b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-02T01:00:13.933Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 56a418d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index fbca1a7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var WritableStream = require( 'readable-stream' ).Writable; // eslint-disable-line stdlib/no-redeclare -var bench = require( '@stdlib/bench-harness' ); -var inherit = require( '@stdlib/utils-inherit' ); -var noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::throughput,baseline', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return nextTick( onTick ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function onTick() { - if ( i !== i ) { - b.fail( 'should not be NaN' ); - } - next(); - } -}); - -bench( pkg+'::throughput', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar debug = require( 'debug' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.js","../lib/main.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar debug = require( 'debug' );\n\n\n// EXPORTS //\n\nexport default debug;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\n}\n\n\n// EXPORTS //\n\nexport default objectMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\n\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport objectMode from './object_mode.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var logger = require( 'debug' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b9f70fe..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var objectMode = require( './object_mode.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'objectMode', objectMode ); -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 64f25a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 084a9f9..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 47a870b..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index c878fde..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = require( './../lib/main.js' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a factory function', function test( t ) { - var createStream = factory(); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a factory function (options)', function test( t ) { - var createStream = factory( {} ); - t.equal( typeof createStream, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..0000000 --- a/test/test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream in object mode', function test( t ) { - t.equal( typeof debugStream.objectMode, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to main export is a method to create a stream factory', function test( t ) { - t.equal( typeof debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - var s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - function onError( err ) { - count += 1; - if ( err ) { - t.ok( true, err.message ); - } else { - t.ok( false, 'does not error' ); - } - if ( count === 2 ) { - t.end(); - } - } - function onClose() { - count += 1; - t.ok( true, 'stream closes' ); - if ( count === 2 ) { - t.end(); - } - } -}); - -tape( 'the returned stream does not allow itself to be destroyed more than once', function test( t ) { - var s; - - s = new DebugStream(); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - // If the stream is closed twice, the test will error... - s.destroy(); - s.destroy(); - - function onClose() { - t.ok( true, 'stream closes' ); - t.end(); - } - function onError( err ) { - t.ok( false, err.message ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -/* eslint-disable no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = require( './../lib/main.js' ); -var objectMode = require( './../lib/object_mode.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof objectMode, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - objectMode( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* 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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if provided an options argument which is not an object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[ i ] ); - t.equals( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'objectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `highWaterMark` option which is not a nonnegative number', function test( t ) { - var values; - var err; - var i; - - values = [ - -5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'highWaterMark': values[ i ] - }); - t.equal( err instanceof TypeError, true, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized/unsupported options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': true, - 'boop': 'bop' - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, {}, 'does not set any option values' ); - t.end(); -});