new-prop

Minimalistic, extendible properties

npm install new-prop
4 downloads in the last week
23 downloads in the last month

new-prop

Minimalistic, extendible property library for JavaScript

PI = prop(3.14)
PI()
// => 3.14

PI(3.14159)
PI()
// => 3.14159

Install

$ npm install new-prop # component install adaio/prop

API

extend

foo = prop(3.14)
  .extend(function(raw){

    return function(newValue){

      if(newValue){
        newValue*=10
        return raw(newValue)
      }

      return raw()
    }

  })

getter(Function)

Sets a getter function for the property.

foo = prop()
  .getter(function(value){
    return value + '.00$'
  })

foo(314)

foo()
// => 314.00$

foo.raw()
// => 314

setter(Function)

Sets a setter function for the property.

foo = prop()
  .setter(function(value){
    return value + '.00$'
  })

foo(314)

foo()
// => 314.00$

foo.raw()
// => 314.00$

npm loves you