🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

construct-from-spec

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

construct-from-spec

Construct JavaScript objects from specifications

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

construct-from-spec

A little helper to construct object from "specifications". Usage example:

var createConstructor = require('construct-from-spec')

var construct = createConstructor(
  'name', // name of the key which is used as a pointer to a function
  true    // if we need to use `new` operator when calling a function
);

var spec = {
  name: 'buffer:Buffer',
  subject: 'hello'
}

var buf = construct(spec) // the same as `new Buffer('hello')`

Where this can be useful? In configuration files, now you can construct entire objects from a JSON object. Please note, that this can lead to security vulnerabilities, cause config author can do an arbitrary code execution.

Installation

% npm install construct-from-spec

Keywords

configuration

FAQs

Package last updated on 19 Feb 2014

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