Gathering detailed insights and metrics for one-time-execution-method
Gathering detailed insights and metrics for one-time-execution-method
Gathering detailed insights and metrics for one-time-execution-method
Gathering detailed insights and metrics for one-time-execution-method
npm install one-time-execution-method
Typescript
Module System
Min. Node Version
Node Version
NPM Version
66.6
Supply Chain
98.1
Quality
77.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
191,398
Last Day
33
Last Week
282
Last Month
1,361
Last Year
30,408
1,352 Commits
3 Watching
2 Branches
1 Contributors
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
Cumulative downloads
Total Downloads
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
6
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.
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();
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
Object symbol slot holding the state of the method.
With npm do:
1npm install one-time-execution-method
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
Reason
packaging workflow detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
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