Socket
Socket
Sign inDemoInstall

resetable

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resetable

A sweet to define temporary values and clear them off conditionally


Version published
Weekly downloads
3.7K
decreased by-10.05%
Maintainers
1
Weekly downloads
 
Created
Source

= Resetable A sweet to define temporary values and clear them off conditionally

== Setup [source, bash]

npm i --save resetable

== Usage [source, javascript]

const Resetable = require('resetable') const name = new Resetable('defaultValue')

== What is this? You all love creating chainable functions, which set global value and once to use that global, you clean it off. Okay wait! Let's check the below example.

=== Without Resetable

[source, javascript]

const carStore = {} let carModel = null let carType = null

carStore.model = (model) => { carModel = model return carStore }

carStore.type = (type) => { carType = type return carStore }

carStore.search = () => { const model = carModel const type = carType carModel = null carType = null

// perform search

}

carStore .model('1990') .type('stang') .search()

=== With Resetable

[source, javascript]

const Resetable = require('resetable')

const carStore = {} let carModel = new Resetable(null) <1> let carType = new Resetable(null)

carStore.model = (model) => { carModel.set(model) <2> return carStore }

carStore.type = (type) => { carType.set(type) return carStore }

carStore.search = () => { const model = carModel.pull() <3> const type = carType.pull()

// perform search

}

carStore .model('1990') .type('stang') .search()

<1> Define the temporary variable as resetable with a default value. <2> Make use of the set method to set the value. <3> Calling the pull method will clear the resetable variable back to the original value.

Keywords

FAQs

Package last updated on 30 May 2017

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc