Socket
Book a 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
npmnpm
Version published
Maintainers
1
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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.