Socket
Socket
Sign inDemoInstall

function-bind

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-bind - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

.jscs.json

12

index.js

@@ -6,5 +6,3 @@ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';

module.exports = bind;
function bind(that) {
module.exports = function bind(that) {
var target = this;

@@ -37,9 +35,9 @@ if (typeof target !== 'function' || toStr.call(target) !== funcType) {

for (var i = 0; i < boundLength; i++) {
boundArgs.push("$" + i);
boundArgs.push('$' + i);
}
var bound = Function("binder", "return function (" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
if (target.prototype) {
function Empty() {}
var Empty = function Empty() {};
Empty.prototype = target.prototype;

@@ -51,3 +49,3 @@ bound.prototype = new Empty();

return bound;
}
};
{
"name": "function-bind",
"version": "1.0.0",
"description": "Implementation of function.prototype.bind",
"keywords": [],
"version": "1.0.2",
"description": "Implementation of Function.prototype.bind",
"keywords": [
"function",
"bind",
"shim",
"es5"
],
"author": "Raynos <raynos2@gmail.com>",

@@ -10,5 +15,11 @@ "repository": "git://github.com/Raynos/function-bind.git",

"homepage": "https://github.com/Raynos/function-bind",
"contributors": [{
"name": "Raynos"
}],
"contributors": [
{
"name": "Raynos"
},
{
"name": "Jordan Harband",
"url": "https://github.com/ljharb"
}
],
"bugs": {

@@ -20,13 +31,17 @@ "url": "https://github.com/Raynos/function-bind/issues",

"devDependencies": {
"tape": "~2.14.0",
"covert": "~0.4.0"
"tape": "~3.0.0",
"covert": "~1.0.0",
"jscs": "~1.6.2"
},
"licenses": [{
"type": "MIT",
"url": "http://github.com/Raynos/function-bind/raw/master/LICENSE"
}],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/Raynos/function-bind/raw/master/LICENSE"
}
],
"scripts": {
"test": "node test/index.js",
"test": "npm run lint && node test/index.js && npm run coverage-quiet",
"coverage": "covert test/*.js",
"coverage-quiet": "covert test/*.js --quiet"
"coverage-quiet": "covert test/*.js --quiet",
"lint": "jscs *.js */*.js"
},

@@ -33,0 +48,0 @@ "testling": {

# function-bind
<!--
[![build status][1]][2]
[![NPM version][3]][4]
[![build status][travis-svg]][travis-url]
[![NPM version][npm-badge-svg]][npm-url]
[![Coverage Status][5]][6]
[![gemnasium Dependency Status][7]][8]
[![Davis Dependency status][9]][10]
[![Dependency status][deps-svg]][deps-url]
[![Dev Dependency status][dev-deps-svg]][dev-deps-url]
-->

@@ -34,6 +35,6 @@

[1]: https://secure.travis-ci.org/Raynos/function-bind.png
[2]: https://travis-ci.org/Raynos/function-bind
[3]: https://badge.fury.io/js/function-bind.png
[4]: https://badge.fury.io/js/function-bind
[travis-svg]: https://travis-ci.org/Raynos/function-bind.svg
[travis-url]: https://travis-ci.org/Raynos/function-bind
[npm-badge-svg]: https://badge.fury.io/js/function-bind.svg
[npm-url]: https://npmjs.org/package/function-bind
[5]: https://coveralls.io/repos/Raynos/function-bind/badge.png

@@ -43,5 +44,7 @@ [6]: https://coveralls.io/r/Raynos/function-bind

[8]: https://gemnasium.com/Raynos/function-bind
[9]: https://david-dm.org/Raynos/function-bind.png
[10]: https://david-dm.org/Raynos/function-bind
[deps-svg]: https://david-dm.org/Raynos/function-bind.svg
[deps-url]: https://david-dm.org/Raynos/function-bind
[dev-deps-svg]: https://david-dm.org/Raynos/function-bind/dev-status.svg
[dev-deps-url]: https://david-dm.org/Raynos/function-bind#info=devDependencies
[11]: https://ci.testling.com/Raynos/function-bind.png
[12]: https://ci.testling.com/Raynos/function-bind

@@ -12,12 +12,12 @@ var test = require('tape');

test('non-functions', function (t) {
var errorPrefix = 'Function.prototype.bind called on incompatible ';
var nonFunctions = [true, false, [], {}, 42, 'foo', NaN, /a/g];
t.plan(nonFunctions.length * 2);
for (var i = 0; i < nonFunctions.length; ++i) {
try { functionBind.call(nonFunctions[i]); } catch (ex) {
t.ok(ex instanceof TypeError, 'throws when given ' + String(nonFunctions[i]));
t.equal(ex.message, errorPrefix + String(nonFunctions[i]), 'exception message is correct for ' + nonFunctions[i]);
}
}
t.end();
var errorPrefix = 'Function.prototype.bind called on incompatible ';
var nonFunctions = [true, false, [], {}, 42, 'foo', NaN, /a/g];
t.plan(nonFunctions.length * 2);
for (var i = 0; i < nonFunctions.length; ++i) {
try { functionBind.call(nonFunctions[i]); } catch (ex) {
t.ok(ex instanceof TypeError, 'throws when given ' + String(nonFunctions[i]));
t.equal(ex.message, errorPrefix + String(nonFunctions[i]), 'exception message is correct for ' + nonFunctions[i]);
}
}
t.end();
});

@@ -104,5 +104,5 @@

var A = function (x) {
this.name = x || "A";
this.name = x || 'A';
};
var B = functionBind.call(A, null, "B");
var B = functionBind.call(A, null, 'B');

@@ -216,2 +216,3 @@ var result = new B();

st.equal(subject.length, 3);
st.equal(subject(1, 2, 3), 6);
st.end();

@@ -223,2 +224,3 @@ });

st.equal(subject.length, 3);
st.equal(subject(1, 2, 3), 6);
st.end();

@@ -230,2 +232,3 @@ });

st.equal(subject.length, 2);
st.equal(subject(2, 3), 6);
st.end();

@@ -237,2 +240,3 @@ });

st.equal(subject.length, 2);
st.equal(subject(2, 3), 6);
st.end();

@@ -244,2 +248,3 @@ });

st.equal(subject.length, 0);
st.equal(subject(), 6);
st.end();

@@ -251,2 +256,3 @@ });

st.equal(subject.length, 0);
st.equal(subject(), 6);
st.end();

@@ -253,0 +259,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc