@stdlib/function-ctor
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@stdlib/function-ctor", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Function constructor.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
122
README.md
@@ -51,4 +51,2 @@ <!-- | ||
<!-- eslint-disable stdlib/no-redeclare --> | ||
```javascript | ||
@@ -62,4 +60,2 @@ var Function = require( '@stdlib/function-ctor' ); | ||
<!-- eslint-disable stdlib/no-redeclare --> | ||
```javascript | ||
@@ -74,2 +70,114 @@ var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); | ||
* * * | ||
### Properties | ||
<a name="prop-length"></a> | ||
#### Function.prototype.length | ||
A number representing the number of arguments expected by the function. | ||
```javascript | ||
var greet = new Function( 'name', 'return "Hello, "+name+"!"' ); | ||
var v = greet.length; | ||
// returns 1 | ||
``` | ||
<a name="prop-name"></a> | ||
#### Function.prototype.name | ||
**Read-only** property representing the name of the function. | ||
```javascript | ||
function greet( name ) { | ||
return 'Hello, '+name+'!'; | ||
} | ||
v = greet.name; | ||
// returns 'greet' | ||
// Functions created with the Function constructor are anonymous: | ||
var fcn = new Function( 'name', 'return "Hello, "+name+"!"' ); | ||
var v = fcn.name; | ||
// returns 'anonymous' | ||
``` | ||
<a name="prop-prototype"></a> | ||
#### Function.prototype.prototype | ||
**Read-only** property representing the prototype of the function. | ||
```javascript | ||
function greet( name ) { | ||
return 'Hello, '+name+'!'; | ||
} | ||
var proto = greet.prototype; | ||
// returns {} | ||
``` | ||
* * * | ||
### Methods | ||
<a name="method-apply"></a> | ||
#### Function.prototype.apply( thisArg, args ) | ||
Calls the specified function witht he given `this` argument and arguments provided as an array-like object. | ||
```javascript | ||
function add( x, y ) { | ||
return x + y; | ||
} | ||
var v = add.apply( null, [ 1, 2 ] ); | ||
// returns 3 | ||
``` | ||
<a name="method-bind"></a> | ||
#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] ) | ||
Returns a new function which invokes the original function with the given `this` value and arguments. | ||
```javascript | ||
functiona add( x, y ) { | ||
return x + y; | ||
} | ||
var add1 = add.bind( null, 1 ); | ||
var v = add1( 2 ); | ||
// returns 3 | ||
``` | ||
<a name="method-call"></a> | ||
#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] ) | ||
Calls the specified function with the given `this` value and arguments. | ||
```javascript | ||
function add( x, y ) { | ||
return x + y; | ||
} | ||
var v = add.call( null, 1, 2 ); | ||
// returns 3 | ||
``` | ||
<a name="method-to-string"></a> | ||
#### Function.prototype.toString() | ||
Returns a string representing the function. | ||
```javascript | ||
function add( x, y ) { | ||
return x + y; | ||
} | ||
var v = add.toString(); | ||
// returns 'function add( x, y ) {\n return x + y;\n}' | ||
``` | ||
</section> | ||
@@ -102,4 +210,2 @@ | ||
<!-- eslint-disable stdlib/no-redeclare --> | ||
```javascript | ||
@@ -173,4 +279,4 @@ var Function = require( '@stdlib/function-ctor' ); | ||
[test-image]: https://github.com/stdlib-js/function-ctor/actions/workflows/test.yml/badge.svg?branch=v0.0.1 | ||
[test-url]: https://github.com/stdlib-js/function-ctor/actions/workflows/test.yml?query=branch:v0.0.1 | ||
[test-image]: https://github.com/stdlib-js/function-ctor/actions/workflows/test.yml/badge.svg?branch=v0.0.2 | ||
[test-url]: https://github.com/stdlib-js/function-ctor/actions/workflows/test.yml?query=branch:v0.0.2 | ||
@@ -177,0 +283,0 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/function-ctor/main.svg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24830
310