relational algebra-inspired object modification


relational algebra-inspired object modification!

var projector = require('projector')

var secretUser = {
  _id: 5,
  name: 'bob',
  hashedPassword: 'ediojjf'
  favoriteBand: 'Spice Girls'
  bio: 'some really long thing, it goes on for paragraphs'

var sanitize = projector({
  _id: true,
  name: true,
  bio: function (bio) { return bio.substr(0,30) + '...' }

var safeUser = sanitize(secretUser)

using jsig

Creates a function which limits the resulting object to the specified keys. Similar to MongoDB's fields object

Creates a function which adds a field or fields to an object. The leaf nodes on the map argument object must be functions, which are called on the original object.

$ npm install projector

From package root:

$ npm install
$ npm test

MIT. (c) 2013 jden See