diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9ab8cc667fff..0a4bc8a5c757 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,9 +10,7 @@ "postCreateCommand": "./.devcontainer/post-create", "customizations": { "codespaces": { - "openFiles": [ - "README.md" - ] + "openFiles": ["README.md"] }, "vscode": { "settings": { diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml index 686bec3b0274..780294863a6f 100644 --- a/.github/workflows/autoclose.yml +++ b/.github/workflows/autoclose.yml @@ -27,12 +27,10 @@ on: # Workflow jobs: jobs: - # Define a job which closes a pull request if a contributor failed to setup EditorConfig: editorconfig: - # Define job name: - name: 'Check for EditorConfig label' + name: "Check for EditorConfig label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: EditorConfig' }}" @@ -42,9 +40,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -61,9 +58,8 @@ jobs: # Define a job which closes a pull request if a contributor failed to follow contributing guidelines: contributor_guidelines: - # Define job name: - name: 'Check for contributor guidelines label' + name: "Check for contributor guidelines label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Contributor Guidelines' }}" @@ -73,9 +69,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -92,9 +87,8 @@ jobs: # Define a job which closes a pull request if a contributor failed to follow project conventions: project_conventions: - # Define job name: - name: 'Check for project conventions label' + name: "Check for project conventions label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Project Conventions' }}" @@ -104,9 +98,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -127,9 +120,8 @@ jobs: # Define a job which closes a pull request if a pull request is considered spam: spam: - # Define job name: - name: 'Check for spam label' + name: "Check for spam label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Spam' }}" @@ -139,9 +131,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -153,7 +144,7 @@ jobs: Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions. # Lock pull request conversation: - - name: 'Lock conversation' + - name: "Lock conversation" run: gh pr lock "$NUMBER" --reason spam env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -162,9 +153,8 @@ jobs: # Define a job which closes a pull request if a pull request is considered stale: stale: - # Define job name: - name: 'Check for stale label' + name: "Check for stale label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Stale' }}" @@ -175,7 +165,7 @@ jobs: # Define the sequence of job steps: steps: # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -188,9 +178,8 @@ jobs: # Define a job which closes a pull request if a PR has an inappropriate Git history: git_history: - # Define job name: - name: 'Check for Git History label' + name: "Check for Git History label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Git History' }}" @@ -200,9 +189,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} @@ -224,9 +212,8 @@ jobs: # Define a job which closes a pull request if proposed changes duplicate already included changes: already_resolved: - # Define job name: - name: 'Check for already resolved label' + name: "Check for already resolved label" # Only run this job if the pull request has a specific label: if: "${{ github.event.label.name == 'autoclose: Already Resolved' }}" @@ -236,9 +223,8 @@ jobs: # Define the sequence of job steps: steps: - # Close the pull request: - - name: 'Close pull request' + - name: "Close pull request" run: gh pr close "$NUMBER" --comment "$BODY" env: GH_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} diff --git a/.github/workflows/check_commit_metadata.yml b/.github/workflows/check_commit_metadata.yml index 92e660a7ac8e..74a392d6d0e6 100644 --- a/.github/workflows/check_commit_metadata.yml +++ b/.github/workflows/check_commit_metadata.yml @@ -33,12 +33,10 @@ permissions: # Workflow jobs: jobs: - # Define a job for checking the commit metadata for whether local development is properly setup... check_commit_metadata: - # Define a display name: - name: 'Check Commit Metadata' + name: "Check Commit Metadata" # Define the type of virtual host machine: runs-on: ubuntu-latest @@ -49,24 +47,24 @@ jobs: # Define the sequence of job steps... steps: # Checkout the repository: - - name: 'Checkout repository' + - name: "Checkout repository" # Pin action to full length commit SHA uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: # Ensure we have access to the scripts directory: sparse-checkout: | - .github/workflows/scripts + .github/workflows/scripts sparse-checkout-cone-mode: false timeout-minutes: 10 # Extract commit metadata from commit messages as JSON: - - name: 'Extract commit metadata' + - name: "Extract commit metadata" id: extract-metadata # Pin action to full length commit SHA uses: stdlib-js/metadata-action@3ccf68f24c51ae23470319e8e5619d539df8212b # v3.0.0 # Check commit metadata: - - name: 'Check commit metadata' + - name: "Check commit metadata" env: PR_NUMBER: ${{ github.event.pull_request.number }} COMMIT_METADATA: ${{ steps.extract-metadata.outputs.metadata }} diff --git a/.github/workflows/generate_pr_commit_message.yml b/.github/workflows/generate_pr_commit_message.yml index 8af6ffd4e20f..8dbd185de9c2 100644 --- a/.github/workflows/generate_pr_commit_message.yml +++ b/.github/workflows/generate_pr_commit_message.yml @@ -32,12 +32,10 @@ permissions: # Workflow jobs: jobs: - # Job to generate commit message draft: generate-commit-message: - # Define a display name: - name: 'Generate PR Commit Message Draft' + name: "Generate PR Commit Message Draft" # Define the type of virtual host machine: runs-on: ubuntu-latest @@ -52,7 +50,7 @@ jobs: # Define the sequence of job steps... steps: # Checkout repository: - - name: 'Checkout repository' + - name: "Checkout repository" # Pin action to full length commit SHA uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -63,7 +61,7 @@ jobs: sparse-checkout-cone-mode: false # Generate commit message: - - name: 'Generate commit message' + - name: "Generate commit message" id: commit_message run: | COMMIT_MESSAGE=$($GITHUB_WORKSPACE/.github/workflows/scripts/generate_pr_commit_message $PR_NUMBER) @@ -83,7 +81,7 @@ jobs: exit 0 # Post commit message as PR comment: - - name: 'Post commit message as PR comment' + - name: "Post commit message as PR comment" # Pin action to full length commit SHA uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 with: diff --git a/.github/workflows/label_commands.yml b/.github/workflows/label_commands.yml index 4538336cc0e2..b9adc5fbe683 100644 --- a/.github/workflows/label_commands.yml +++ b/.github/workflows/label_commands.yml @@ -27,12 +27,10 @@ on: # Workflow jobs: jobs: - # Define a job for removing the label and adding in-progress label: manage_labels: - # Define a display name: - name: 'Manage labels' + name: "Manage labels" # Define the type of virtual host machine: runs-on: ubuntu-latest @@ -47,8 +45,7 @@ jobs: # Define the job's steps: steps: - - - name: 'Remove label' + - name: "Remove label" # Pin action to full length commit SHA uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: @@ -65,7 +62,7 @@ jobs: console.log( 'Error removing label: %s', error.message ); } - - name: 'Add in-progress label' + - name: "Add in-progress label" # Pin action to full length commit SHA uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: @@ -79,7 +76,7 @@ jobs: }) # Add initial reaction to comment with slash command: - - name: 'Add initial reaction' + - name: "Add initial reaction" run: | curl -X POST \ -H "Accept: application/vnd.github.v3+json" \ @@ -89,12 +86,11 @@ jobs: # Define a job for checking for required files: check_files: - # Define a display name: - name: 'Check for required files' + name: "Check for required files" # Ensure initial reaction job has completed before running this job: - needs: [ manage_labels ] + needs: [manage_labels] # Define the conditions under which the job should run: if: | @@ -110,12 +106,11 @@ jobs: # Define a job for updating copyright header years: update_copyright_years: - # Define a display name: - name: 'Update copyright header years' + name: "Update copyright header years" # Ensure initial reaction job has completed before running this job: - needs: [ manage_labels ] + needs: [manage_labels] # Define the conditions under which the job should run: if: | @@ -132,12 +127,11 @@ jobs: # Define a job for auto-fixing lint errors: fix_lint_errors: - # Define a display name: - name: 'Auto-fix lint errors' + name: "Auto-fix lint errors" # Ensure initial reaction job has completed before running this job: - needs: [ manage_labels ] + needs: [manage_labels] # Define the conditions under which the job should run: if: | @@ -154,12 +148,11 @@ jobs: # Define a job for merging develop branch: merge_develop: - # Define a display name: - name: 'Merge changes from develop branch into this PR' + name: "Merge changes from develop branch into this PR" # Ensure initial reaction job has completed before running this job: - needs: [ manage_labels ] + needs: [manage_labels] # Define the conditions under which the job should run: if: | @@ -176,12 +169,11 @@ jobs: # Define a job for rebasing on develop branch: rebase_develop: - # Define a display name: - name: 'Rebase this PR on top of develop branch' + name: "Rebase this PR on top of develop branch" # Ensure initial reaction job has completed before running this job: - needs: [ manage_labels ] + needs: [manage_labels] # Define the conditions under which the job should run: if: | @@ -198,15 +190,22 @@ jobs: # Define a job for removing the in-progress label: remove_progress_label: - # Define a display name: - name: 'Remove in-progress label' + name: "Remove in-progress label" # Define the type of virtual host machine: runs-on: ubuntu-latest # Ensure all previous jobs have completed before running this job: - needs: [ manage_labels, check_files, update_copyright_years, fix_lint_errors, merge_develop, rebase_develop ] + needs: + [ + manage_labels, + check_files, + update_copyright_years, + fix_lint_errors, + merge_develop, + rebase_develop, + ] # Define the conditions under which the job should run: if: | diff --git a/lib/node_modules/@stdlib/error/reviver/lib/index.js b/lib/node_modules/@stdlib/error/reviver/lib/index.js index 7eaccfa86278..9ab046b6875c 100644 --- a/lib/node_modules/@stdlib/error/reviver/lib/index.js +++ b/lib/node_modules/@stdlib/error/reviver/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 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. @@ -18,25 +18,75 @@ 'use strict'; +// MAIN // + /** -* Revive a JSON-serialized error object. -* -* @module @stdlib/error/reviver -* -* @example -* var parseJSON = require( '@stdlib/utils/parse-json' ); -* var reviver = require( '@stdlib/error/reviver' ); +* Revives an error object during JSON parsing. * -* var str = '{"type":"TypeError","message":"beep"}'; -* var err = parseJSON( str, reviver ); -* // returns +* @param {string} key - key +* @param {*} value - value +* @returns {*} revived value */ - -// MODULES // - -var main = require( './main.js' ); +function reviver( key, value ) { + if ( + value && + typeof value === 'object' && + value.type === 'Error' + ) { + // Use default message if value.message is undefined + var message = typeof value.message === 'string' ? value.message : 'An error occurred'; + + // Determine the error constructor based on value.name + var name = typeof value.name === 'string' ? value.name : 'Error'; + var ErrorConstructor; + switch ( name ) { + case 'SyntaxError': + ErrorConstructor = SyntaxError; + break; + case 'TypeError': + ErrorConstructor = TypeError; + break; + case 'RangeError': + ErrorConstructor = RangeError; + break; + case 'ReferenceError': + ErrorConstructor = ReferenceError; + break; + case 'URIError': + ErrorConstructor = URIError; + break; + case 'EvalError': + ErrorConstructor = EvalError; + break; + default: + ErrorConstructor = Error; + break; + } + + // Create the error with the appropriate constructor + var err = new ErrorConstructor( message ); + + // Set the name property (for consistency, even though the constructor sets it) + err.name = name; + + // Set stack only if value.stack is a string and the stack property is writable + if ( + typeof value.stack === 'string' && + 'stack' in err // Check if the stack property exists + ) { + try { + err.stack = value.stack; + } catch ( e ) { + // If setting stack fails (e.g., not writable), silently ignore + } + } + + return err; + } + return value; +} // EXPORTS // -module.exports = main; +module.exports = reviver; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/error/reviver/test/test.js b/lib/node_modules/@stdlib/error/reviver/test/test.js index 92323ac324a6..953234380b1e 100644 --- a/lib/node_modules/@stdlib/error/reviver/test/test.js +++ b/lib/node_modules/@stdlib/error/reviver/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 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. @@ -21,228 +21,70 @@ // MODULES // var tape = require( 'tape' ); -var copy = require( '@stdlib/utils/copy' ); -var reviveError = require( './../lib' ); - - -// FUNCTIONS // - -function setup( type, name, msg, stack ) { - var json = {}; - json.type = type || 'Error'; - json.name = name || 'Error'; - json.message = msg || ''; - json.stack = stack || 'boop'; - return json; -} +var parseJSON = require( '@stdlib/utils-parse-json' ); +var err2json = require( '@stdlib/error-to-json' ); +var reviver = require( './../lib' ); // TESTS // tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof reviveError, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'values which are not recognized as serialized error objects are unaffected', function test( t ) { - var expected; - var actual; - - expected = { - 'beep': 'boop' - }; - actual = JSON.parse( '{"beep":"boop"}', reviveError ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - // Null edge case: - actual = JSON.parse( 'null', reviveError ); - t.equal( actual, null, 'returns expected value' ); - - t.end(); -}); - -tape( 'an object must have a recognized "type" field in order to be revived', function test( t ) { - var expected; - var actual; - var json; - - json = setup(); - json.type = 'Boop'; - - expected = copy( json ); - - actual = JSON.parse( JSON.stringify( json ), reviveError ); - - t.deepEqual( actual, expected, 'returns expected value' ); + t.strictEqual( typeof reviver, 'function', 'main export is a function' ); t.end(); }); -tape( 'an object must have a "message" field in order to be revived', function test( t ) { - var expected; - var actual; - var json; - - json = setup(); - delete json.message; - - expected = copy( json ); - - actual = JSON.parse( JSON.stringify( json ), reviveError ); - - t.deepEqual( actual, expected, 'returns expected value' ); +tape( 'the function revives a JSON-serialized error object', function test( t ) { + var err1 = new SyntaxError( 'bad syntax' ); + var json = err2json( err1 ); + var str = JSON.stringify( json ); + var err2 = parseJSON( str, reviver ); + t.strictEqual( err2 instanceof SyntaxError, true, 'revived error is a SyntaxError' ); + t.strictEqual( err1.message, err2.message, 'revived error has the same message' ); + t.strictEqual( err1.stack, err2.stack, 'revived error has the same stack' ); t.end(); }); -tape( 'the function will revive a JSON-serialized error object', function test( t ) { - var expected; - var actual; - var types; - var ctors; - var json; - var msgs; - var i; - - types = [ - 'Error', - 'TypeError', - 'SyntaxError', - 'URIError', - 'ReferenceError', - 'EvalError', - 'RangeError' - ]; - msgs = [ - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g' - ]; - ctors = [ - Error, - TypeError, - SyntaxError, - URIError, - ReferenceError, - EvalError, - RangeError - ]; - for ( i = 0; i < types.length; i++ ) { - json = setup( types[ i ], types[ i ], msgs[i], 'boop'+i ); +tape( 'the function revives a JSON-serialized error with missing properties', function test( t ) { + var json = { type: 'Error' }; // Missing message, name, stack + var str = JSON.stringify( json ); + var err = parseJSON( str, reviver ); - expected = new ctors[ i ]( msgs[i] ); - expected.stack = 'boop' + i; - - actual = JSON.parse( JSON.stringify( json ), reviveError ); - - t.ok( actual instanceof ctors[ i ], 'instance of type ' + types[i] ); - t.equal( actual.message, expected.message, 'returns expected value' ); - t.equal( actual.stack, expected.stack, 'returns expected value' ); - } + t.strictEqual( err instanceof Error, true, 'revived error is an Error' ); + t.strictEqual( err.message, 'An error occurred', 'uses default message' ); + t.strictEqual( err.name, 'Error', 'uses default name' ); t.end(); }); -tape( 'non-standard error properties are bound to the revived error instance', function test( t ) { - var json; - var err; - - json = setup(); - json.beep = 'boop'; - json.arr = [1, 2, 3, [4, 5]]; - - err = JSON.parse( JSON.stringify( json ), reviveError ); - - t.equal( err.beep, json.beep, 'shallow properties' ); - - t.notEqual( err.arr, json.arr, 'separate instances' ); - t.deepEqual( err.arr, json.arr, 'returns expected value' ); +tape( 'the function revives a TypeError correctly', function test( t ) { + var err1 = new TypeError( 'invalid type' ); + var json = err2json( err1 ); + var str = JSON.stringify( json ); + var err2 = parseJSON( str, reviver ); + t.strictEqual( err2 instanceof TypeError, true, 'revived error is a TypeError' ); + t.strictEqual( err1.message, err2.message, 'revived error has the same message' ); t.end(); }); -tape( 'if a serialized error object lacks a "stack" field or has a "stack" field and lacks a stack trace, the returned error will not have an associated stack trace', function test( t ) { - var json; - var err; - - // Missing stack field... - json = setup(); - delete json.stack; - - err = JSON.parse( JSON.stringify( json ), reviveError ); - - t.ok( err.stack === '' || err.stack === void 0, 'returned error does not have a stack trace' ); - - // Stack field is empty or null... - json = setup(); - json.stack = null; - - err = JSON.parse( JSON.stringify( json ), reviveError ); - - t.ok( err.stack === '' || err.stack === void 0, 'returned error does not have a stack trace' ); +tape( 'the function handles errors with invalid stack values', function test( t ) { + var json = { + type: 'Error', + message: 'test error', + name: 'Error', + stack: 123 // Invalid stack value (not a string) + }; + var str = JSON.stringify( json ); + var err = parseJSON( str, reviver ); + t.strictEqual( err instanceof Error, true, 'revived error is an Error' ); + t.strictEqual( err.message, 'test error', 'revived error has the correct message' ); t.end(); }); -tape( 'the function will revive deeply nested serialized error objects', function test( t ) { - var expected; - var actual; - var ctors; - var json; - var arrs; - var msgs; - var i; - - arrs = [ - setup( 'Error', 'Error', 'beep' ), - setup( 'TypeError', 'TypeError', 'boop' ) - ]; - - ctors = [ - Error, - TypeError - ]; - - msgs = [ - 'beep', - 'boop' - ]; - - actual = JSON.parse( JSON.stringify( arrs ), reviveError ); - - for ( i = 0; i < arrs.length; i++ ) { - expected = new ctors[ i ]( msgs[i] ); - expected.stack = 'boop'; - - t.ok( actual[i] instanceof ctors[i], 'instance of ' + ctors[ i ] ); - t.equal( actual[i].message, expected.message, 'returns expected value' ); - t.equal( actual[i].stack, expected.stack, 'returns expected value' ); - } - - json = { - 'beep': { - 'boop': setup( 'RangeError', 'RangeError', 'bap' ) - } - }; - - expected = { - 'beep': { - 'boop': new RangeError( 'bap' ) - } - }; - expected.beep.boop.stack = 'boop'; - - actual = JSON.parse( JSON.stringify( json ), reviveError ); - - t.ok( actual.beep.boop instanceof RangeError, 'instance of RangeError' ); - - t.equal( actual.beep.boop.message, expected.beep.boop.message, 'returns expected value' ); - - t.equal( actual.beep.boop.stack, expected.beep.boop.stack, 'returns expected value' ); - +tape( 'the function returns the value if not an error object', function test( t ) { + var value = { 'a': 1 }; + var result = reviver( 'key', value ); + t.strictEqual( result, value, 'returns the original value' ); t.end(); -}); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/README.md b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/README.md similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/README.md rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/README.md diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/benchmark.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/benchmark.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/benchmark.native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/benchmark.native.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/benchmark.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/benchmark.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/benchmark.c rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/benchmark.c diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/native/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/native/Makefile rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/native/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/native/benchmark.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/benchmark/c/native/benchmark.c rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/benchmark/c/native/benchmark.c diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/binding.gyp b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/binding.gyp similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/binding.gyp rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/binding.gyp diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/docs/img/equation_arcvercosine.svg b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/img/equation_arcvercosine.svg similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/docs/img/equation_arcvercosine.svg rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/img/equation_arcvercosine.svg diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/repl.txt similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/docs/repl.txt rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/repl.txt diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/types/index.d.ts similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/docs/types/index.d.ts rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/types/test.ts similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/docs/types/test.ts rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/c/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/examples/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/c/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/c/example.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/examples/c/example.c rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/c/example.c diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/examples/index.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/index.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/examples/index.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/examples/index.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/include.gypi b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/include.gypi similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/include.gypi rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/include.gypi diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/include/stdlib/math/base/special/avercos.h b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/include/stdlib/math/base/special/avercos.h similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/include/stdlib/math/base/special/avercos.h rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/include/stdlib/math/base/special/avercos.h diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/lib/index.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/index.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/lib/index.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/index.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/lib/main.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/main.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/lib/main.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/main.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/lib/native.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/lib/native.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/lib/native.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/manifest.json b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/manifest.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/manifest.json rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/manifest.json diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/package.json b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/package.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/package.json rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/package.json diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/src/Makefile b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/src/Makefile rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/src/addon.c b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/addon.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/src/addon.c rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/addon.c diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/src/main.c b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/main.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/src/main.c rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/src/main.c diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/REQUIRE similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/REQUIRE rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/REQUIRE diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/data.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/data.json rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/data.json diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/runner.jl similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/runner.jl rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/runner.jl diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/small_negative.json b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/small_negative.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/fixtures/julia/small_negative.json rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/fixtures/julia/small_negative.json diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/test.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/test.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/test.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/test.js diff --git a/lib/node_modules/@stdlib/math/base/special/avercos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/test.native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/avercos/test/test.native.js rename to lib/node_modules/@stdlib/math/base/special/avercosf/avercos/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/sin/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/sin/docs/repl.txt index 5edfa0431bea..cce67a65a2c7 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/sin/docs/repl.txt @@ -1,28 +1,103 @@ - -{{alias}}( x ) +sin( x ) Computes the sine of a number. Parameters ---------- x: number - Input value (in radians). + Input value (in radians). Can be any number, including `NaN` or `Infinity`. Returns ------- y: number - Sine. + Sine of the input value, a number between -1 and 1. Returns `NaN` for invalid inputs like `NaN` or `Infinity`. + + Notes + ----- + - The sine function is periodic with a period of 2π (approximately 6.28 radians), so `sin(x) = sin(x % 6.28)`. + - The function satisfies the identity `sin(-x) = -sin(x)`. + - Useful for smooth game movements, sound wave adjustments, and geometric calculations. + - To convert degrees to radians, multiply by π/180 (e.g., `sin(60 * 3.14 / 180) ≈ 0.8660` for 60 degrees). + - For repeated calculations, store the result to avoid recomputing (e.g., `let h = sin(1.5)`). Examples -------- - > var y = {{alias}}( 0.0 ) - ~0.0 - > y = {{alias}}( {{alias:@stdlib/constants/float64/pi}}/2.0 ) - ~1.0 - > y = {{alias}}( -{{alias:@stdlib/constants/float64/pi}}/6.0 ) - ~-0.5 - > y = {{alias}}( NaN ) + > var y = sin( 0.0 ) + 0.0 + + > y = sin( {{alias:@stdlib/constants/float64/pi}} / 2.0 ) + 1.0 + + > y = sin( -{{alias:@stdlib/constants/float64/pi}} / 6.0 ) + -0.5 + + > y = sin( 0.7853981633974483 ) + ~0.7071 + + > y = sin( {{alias:@stdlib/constants/float64/pi}} ) + 0.0 + + > y = sin( 2 * {{alias:@stdlib/constants/float64/pi}} ) + 0.0 + + > y = sin( {{alias:@stdlib/constants/float64/pi}} / 3.0 ) + ~0.8660 + + > y = sin( -{{alias:@stdlib/constants/float64/pi}} ) + 0.0 + + > y = sin( Infinity ) + NaN + + > y = sin( NaN ) NaN + > y = sin( 1e308 ) + NaN + + > y = sin( -1e308 ) + NaN + + > y = sin( 1e-308 ) + ~1e-308 + + > y = sin( -0.0 ) + -0.0 + + > y = sin( 3 * {{alias:@stdlib/constants/float64/pi}} / 2.0 ) + -1.0 + + > // Simulate a fading light effect: + > for (let time = 0; time < 5; time += 0.5) { + > let glow = (sin(time) + 1) / 2; + > console.log(`Glow ${time}: ${glow.toFixed(2)}`); + > } + Glow 0: 0.50 + Glow 0.5: 0.73 + Glow 1: 0.91 + ... + + > // Mix two sine waves: + > let mix = sin(1.5) + sin(2.5); + > mix + ~-0.589 + + > // C example to simulate a bouncing ball: + > // Save as `bounce.c` and compile with `gcc bounce.c -lm` + > #include + > #include + > int main() { + > for (int step = 0; step < 5; step++) { + > printf("Height %d: %.2f\n", step, sin(step * 0.5)); + > } + > return 0; + > } + Height 0: 0.00 + Height 1: 0.48 + Height 2: 0.91 + ... + See Also -------- - + cos( x ): Computes the cosine, a related trigonometric function. + tan( x ): Computes the tangent, useful for slopes. + {{alias:@stdlib/constants/float64/pi}}: The constant π (approximately 3.14159). \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/sin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/sin/docs/types/index.d.ts index c1ae60355730..2b2fdfd62962 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/sin/docs/types/index.d.ts @@ -21,28 +21,130 @@ /** * Computes the sine of a number. * +* ## Notes +* - The input value `x` must be in radians. To convert degrees to radians, multiply by `π/180` (e.g., `sin(45 * Math.PI / 180)`). +* - The input `x` should be a finite number for meaningful results. Non-finite inputs like `Infinity`, `-Infinity`, or `NaN` return `NaN`. +* - For very large finite inputs (e.g., `|x| > 1e308`), the result may lose precision due to the periodic nature of sine and floating-point limitations. +* - The function returns a value between -1 and 1. +* - The sine function is periodic with a period of 2π (approximately 6.28 radians), so `sin(x) = sin(x % (2 * Math.PI))`. +* - The function satisfies the symmetry property `sin(-x) = -sin(x)`. +* - For very small inputs (`|x| < 1e-308`), `sin(x) ≈ x` due to the small-angle approximation. +* - The function preserves the sign of zero: `sin(-0.0)` returns `-0.0`. +* * @param x - input value (in radians) * @returns sine * * @example +* // Basic example: sine of 0 radians (0 degrees) * var v = sin( 0.0 ); -* // returns ~0.0 +* // returns 0.0 +* +* @example +* // Sine of π/2 radians (90 degrees), where sine reaches its maximum +* var v = sin( 3.141592653589793 / 2.0 ); +* // returns 1.0 +* +* @example +* // Sine of -π/6 radians (-30 degrees), a negative angle +* var v = sin( -3.141592653589793 / 6.0 ); +* // returns -0.5 +* +* @example +* // Sine of π radians (180 degrees), a full half-circle +* var v = sin( 3.141592653589793 ); +* // returns 0.0 +* +* @example +* // Sine of π/4 radians (45 degrees), a common angle where sin(π/4) = √2/2 +* var v = sin( 3.141592653589793 / 4.0 ); +* // returns ~0.7071 (approximately √2/2) +* +* @example +* // Sine of π/3 radians (60 degrees), another common angle where sin(π/3) = √3/2 +* var v = sin( 3.141592653589793 / 3.0 ); +* // returns ~0.8660 (approximately √3/2) +* +* @example +* // Sine of 3π/2 radians (270 degrees), where sine reaches its minimum +* var v = sin( 3 * 3.141592653589793 / 2.0 ); +* // returns -1.0 * * @example -* var v = sin( 3.141592653589793/2.0 ); -* // returns ~1.0 +* // Edge case: sine of negative zero, should preserve the sign +* var v = sin( -0.0 ); +* // returns -0.0 * * @example -* var v = sin( -3.141592653589793/6.0 ); -* // returns ~-0.5 +* // Edge case: sine of a very small number, where sin(x) ≈ x +* var v = sin( 1e-308 ); +* // returns ~1e-308 * * @example +* // Edge case: sine of a very large number, exceeds safe computation range +* var v = sin( 1e308 ); +* // returns NaN +* +* @example +* // Edge case: sine of negative infinity, non-finite input +* var v = sin( -Infinity ); +* // returns NaN +* +* @example +* // Edge case: sine of NaN, invalid input * var v = sin( NaN ); * // returns NaN +* +* @example +* // Practical use: animate a pulsating effect (e.g., for a UI element) +* function pulsate(time: number): number { +* return 0.5 + 0.5 * sin(time); // Oscillates between 0 and 1 +* } +* for (let t = 0; t < 5; t += 0.5) { +* console.log(`Time: ${t.toFixed(1)}, Pulse: ${pulsate(t).toFixed(3)}`); +* } +* // Outputs: Time: 0.0, Pulse: 0.500; Time: 0.5, Pulse: 0.739; etc. +* +* @example +* // Practical use: generate a wave pattern with multiple frequencies (e.g., for audio synthesis) +* function generateWave(time: number, freq1: number, freq2: number): number { +* // Combine two sine waves with different frequencies +* const wave1 = sin(freq1 * time); // First frequency component +* const wave2 = sin(freq2 * time); // Second frequency component +* return (wave1 + wave2) / 2; // Average the waves to keep amplitude between -1 and 1 +* } +* for (let t = 0; t < 5; t += 0.5) { +* console.log(`Time: ${t.toFixed(1)}, Wave: ${generateWave(t, 1.0, 2.0).toFixed(3)}`); +* } +* // Outputs: Time: 0.0, Wave: 0.000; Time: 0.5, Wave: 0.609; etc. +* +* @example +* // Test cases to verify behavior +* function testSin(): void { +* // Test basic values +* if (sin(0.0) !== 0.0) { +* throw new Error('Expected sin(0.0) to be 0.0'); +* } +* if (sin(3.141592653589793 / 2.0) !== 1.0) { +* throw new Error('Expected sin(π/2) to be 1.0'); +* } +* if (sin(3.141592653589793) !== 0.0) { +* throw new Error('Expected sin(π) to be 0.0'); +* } +* // Test common angle +* if (Math.abs(sin(3.141592653589793 / 4.0) - 0.7071067811865476) > 1e-10) { +* throw new Error('Expected sin(π/4) to be approximately 0.7071067811865476'); +* } +* // Test edge cases +* if (sin(-0.0) !== -0.0) { +* throw new Error('Expected sin(-0.0) to be -0.0'); +* } +* if (isNaN(sin(1e308)) === false) { +* throw new Error('Expected sin(1e308) to be NaN'); +* } +* } */ declare function sin( x: number ): number; - // EXPORTS // -export = sin; +export = sin; \ No newline at end of file