Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

ianstormtaylor/set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

set

Set a property on a model or object. For the reverse, checkout ianstormtaylor/get.

Installation

$ component install ianstormtaylor/set

Example

Plain objects:

var set = require('set');

var person = { name: 'ulysses' };
set(person, 'name', 'achilles');
person.name; // achilles

Getter/setter methods:

var set = require('set')
  , model = require('model');

var Person = model('person').attr('name');
var person = new Person({ name: 'ulysses' });
set(person, 'name' 'achilles'); 
person.name(); // achilles

Get methods:

var Backbone = require('backbone')
  , set = require('set');

var person = new Backbone.Model({ name: 'ulysses' });
set(person, 'name', 'achilles')); 
person.get('name'); // achilles

API

set(model, prop, value)

Get the model's prop to value`.

License

MIT

About

Set a property on a model or object.

Resources

Stars

Watchers

Forks

Packages

No packages published