Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Convert property access strings to a function ("user.name.first" etc)

tag: 1.1.0

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 test
Octocat-spinner-32 .gitignore add tests September 30, 2012
Octocat-spinner-32 History.md
Octocat-spinner-32 Makefile add tests September 30, 2012
Octocat-spinner-32 Readme.md
Octocat-spinner-32 component.json
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Readme.md

to-function

Convert property access strings into functions

Installation

$ component install component/to-function

Example

var toFunction = require('to-function');
var fn = toFunction('name.first');
var user = { name: { first: 'Tobi' }};
fn(user);
// => "Tobi"

Converts

  • strings to expressions, for ex foo.bar() becomes return _.foo.bar()
  • regexps to re.test(val) calls
  • functions to themselves
  • defaults to === equality

License

MIT

Something went wrong with that request. Please try again.