ply
v0.1.0
Published
Function.prototype.apply wrappers.
Downloads
57
Maintainers
Readme
Synopsis
ply is a collection of wrappers around Function.prototype.apply
.
Why?
It's trivial to implement, but in order to keep code DRY (and avoid silly mistakes) it makes sense to define this function only once per project. This library is the logical consequence of that.
Install
Node.js
With NPM
npm install ply
From source
git clone https://github.com/pluma/ply.git
cd ply
npm install
make
Browser
With component
component install pluma/ply
With bower
bower install ply
With a CommonJS module loader
Download the latest minified CommonJS release and add it to your project.
Learn more about CommonJS modules.
With an AMD module loader
Download the latest minified AMD release and add it to your project.
As a standalone library
Download the latest minified standalone release and add it to your project.
<script src="/your/js/path/ply.globals.min.js"></script>
This makes the ply
module available in the global namespace.
Basic usage example
var mcall = require('ply').mcall;
mcall(console, 'log', 'Hello', 'World'); // 'Hello' 'World'
API
apply(fn:Function, self:Object, args:Array)
Equivalent to the following:
fn.apply(self, args);
call(fn:Function, self:Object, args...)
Equivalent to the following:
fn.call(self, args...);
fapply(fn:Function, args:Array)
Equivalent to the following:
fn.apply(this, args);
fcall(fn:Function, args...)
Equivalent to the following:
fn.call(this, args...);
mapply(obj:Object, name:String, args:Array)
Equivalent to the following:
obj[name].apply(obj, args);
mcall(obj:Object, name:String, args...)
Equivalent to the following:
obj[name].call(obj, args...);
Unlicense
This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.