Installations
npm install one-time-execution-method
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=16.20.2
Node Version
20.11.0
NPM Version
10.4.0
Score
66.6
Supply Chain
98.1
Quality
77.9
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (100%)
Developer
arlac77
Download Statistics
Total Downloads
191,398
Last Day
33
Last Week
282
Last Month
1,361
Last Year
30,408
GitHub Statistics
1,352 Commits
3 Watching
2 Branches
1 Contributors
Package Meta Information
Latest Version
3.1.1
Package Id
one-time-execution-method@3.1.1
Unpacked Size
9.44 kB
Size
3.33 kB
File Count
5
NPM Version
10.4.0
Node Version
20.11.0
Publised On
09 Feb 2024
Total Downloads
Cumulative downloads
Total Downloads
191,398
Last day
-55.4%
33
Compared to previous day
Last week
-6.6%
282
Compared to previous week
Last month
0.6%
1,361
Compared to previous month
Last year
-19.9%
30,408
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
6
one-time-execution-method
Define methods that will be executed only once.
For async functions the resulting Promise of the 1st. invocation will be preserved and always delivered in the future.
example
1import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method"; 2 3class MyClass { 4 constructor() { 5 this.executions = 0; 6 } 7 8 initialize() { 9 this.executions++; 10 return new Promise(resolve => setTimeout(resolve, 1000)); 11 } 12} 13 14// replace initialize() method of MyClass to be executed only once 15replaceWithOneTimeExecutionMethod(MyClass.prototype, "initialize"); 16 17async doit() { 18 const object = new MyClass(); 19 20 // start several initializations in parallel 21 Promise.all([object.initialize(), object.initialize(), object.initialize()]); 22 23 await object.initialize(); 24 25 // even after several parallel executions only one run is done 26 console.log(this.executions); // -> 1 27} 28 29doit();
API
Table of Contents
replaceWithOneTimeExecutionMethod
Replace a given method with one that will only be executed once. For async functions the resulting Promise of the 1st. invocation will be preserved and always delivered in the future.
1class MyClass { 2 async initialize() { 3 // code here will be executed only once 4 } 5} 6replaceWithOneTimeExecutionMethod(MyClass.prototype, "initialize"); 7 8const object = new MyClass(); 9object.initialize(); // body will/can be executed only once 10object.initialize(); // 2nd. call immediatly returns
Parameters
transitionState
Object symbol slot holding the state of the method.
- undefined -> call func and store Promise
- Promise -> func currently running or fullfilled -> deliver this Promise
install
With npm do:
1npm install one-time-execution-method
license
BSD-2-Clause
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: BSD Zero Clause License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/ci.yml:69
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 20 commits out of 30 are checked with a SAST tool
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/auto_approve.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/auto_approve.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:102: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql_analysis.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/codeql_analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql_analysis.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/codeql_analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql_analysis.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/codeql_analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql_analysis.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/codeql_analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr_labeler.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/pr_labeler.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update_package_lock.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_package_lock.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update_package_lock.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_package_lock.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update_package_lock.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_package_lock.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update_readme_api.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_readme_api.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update_readme_api.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_readme_api.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update_readme_api.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/arlac77/one-time-execution-method/update_readme_api.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/update_package_lock.yml:30
- Info: 0 out of 15 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 5 third-party GitHubAction dependencies pinned
- Info: 5 out of 6 npmCommand dependencies pinned
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/pr_labeler.yml:6
- Warn: no topLevel permission defined: .github/workflows/auto_approve.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:12
- Warn: no topLevel permission defined: .github/workflows/codeql_analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/pr_labeler.yml:1
- Warn: no topLevel permission defined: .github/workflows/update_package_lock.yml:1
- Warn: no topLevel permission defined: .github/workflows/update_readme_api.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
5.3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More