🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

run-once

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run-once

Simply do something once, or once under a condition

1.0.0
latest
Source
npm
Version published
Weekly downloads
54
350%
Maintainers
1
Weekly downloads
 
Created
Source

run-once

Simply do something once, or once under a condition using custom namespaces.

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
// ...
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

Keywords

run once

FAQs

Package last updated on 17 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts