ply

Function.prototype.apply wrappers.

npm install ply
2 downloads in the last week
6 downloads in the last month

Synopsis

ply is a collection of wrappers around Function.prototype.apply.

stability 5 - locked license - Unlicense Flattr this

browser support

Build Status Coverage Status Dependencies

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

Learn more about component.

With bower

bower install ply

Learn more about bower.

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.

Learn more about AMD modules.

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.

npm loves you