Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julienetie/run-once
Simply do something once, or once under a condition
https://github.com/julienetie/run-once
Last synced: 16 days ago
JSON representation
Simply do something once, or once under a condition
- Host: GitHub
- URL: https://github.com/julienetie/run-once
- Owner: julienetie
- License: mit
- Created: 2016-10-17T20:33:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-17T20:59:01.000Z (about 8 years ago)
- Last Synced: 2024-12-07T21:35:26.112Z (24 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# run-once
Simply do something once, or once under a condition using custom namespaces.```javascript
function colorOfTheSky(color){
var skyColor
if(once('colorOfTheSky')){
skyColor = 'The sky is' + color
}else{
skyColor = 'The sky is falling'
}
console.log(skyColor)
}
colorOfTheSky('blue')
// Run once: The sky is blue
// Run again: The sky is falling
// Run and on: The sky is faling
// ...
```
***
```javascript
function colorOfTheSky(color){
var skyColor
if(once('colorOfTheSky' + color)){
skyColor = 'The sky is' + color
}else{
skyColor = 'The sky is falling'
}
console.log(skyColor)
}
colorOfTheSky('blue')
// Run once: The sky is blue
// Run again: The sky is falling
// Run and on: The sky is faling
// ...
colorOfTheSky('red')
// Run once: The sky is red
// Run again: The sky is falling
// Run and on: The sky is faling
// ...
```(c) 2016 Julien Etienne
MIT