util-ex

    0.3.15 • Public • Published

    util-ex Build Status npm downloads license

    Browser-friendly enhanced util fully compatible with standard node.js util

    This package modifies and enhances the standard util from node.js

    API

    definePropery

    definePropery(object, key, value[, aOptions])
    

    Define a porperty on the object.

    usage

    definePropery = require 'util-ex/lib/definePropery'
     
    propValue = ''
    definePropery this'prop''simpleValue'
    definePropery this'prop'undefined,
      get: -> propValue
      set: (value) -> propValue = value
     

    newFunction

    newFunction(name, arguments, body[, scope[, values]])
    newFunction(functionString[, scope[, values]])
    

    create a function via sring.

    newFunction = require('util-ex/lib/new-function')
     
    var fn = newFunction('yourFuncName', ['arg1', 'arg2'], 'return log(arg1+arg2);', {log:console.log})
    newFunction('function yourFuncName(){}')
    newFunction('function yourFuncName(arg1, arg2){return log(arg1+arg2);}', {log:console.log})
    newFunction('function yourFuncName(arg1, arg2){return log(arg1+arg2);}', ['log'], [console.log])
     
    //fn.toString() is :
     "function yourFuncName(arg1, arg2) {
        return log(arg1+arg2);
     }"
     

    Install

    npm i util-ex

    DownloadsWeekly Downloads

    10,138

    Version

    0.3.15

    License

    MIT

    Last publish

    Collaborators

    • riceball