0.1.6 • Published 9 years ago

bound-native-methods v0.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Bound Native Methods

This library exports a collection of bound native virtual methods - static methods of JavaScript standard built-in objects in their bound form - so that they can be used together with the proposed bind operator.

Install

$ npm install bound-native-methods

Usage

import * from 'bound-native-methods';

// Or, be more specific and cut down the build size: //

import {assign, keys} from 'bound-native-methods/object';
0::isInteger();
// true
[3, 6, 9]::max()::is(9);
// true
{'2015-06-01T15:30:00.000Z': 300}::assign({'2015-07-01T15:30:00.000Z': 42})
                                 ::keys()
                                  .map(x => x::toUnixOffset())
                                 ::toJSON();
// [1433172600000,1435764600000]

API

Most static methods have been exported as is, but a few have been renamed or excluded to better fit the context:

Object

Native FormBound Form
Object.getPrototypeOf()::getPrototype()
Object.setPrototypeOf()::setPrototype()

Symbol

Native FormBound Form
Symbol.for()::toSymbol() 1
Symbol.keyFor()::key()

Number

Native FormBound Form
Number.parseFloat()::toFloat() 1
Number.parseInt()::toInt() 1

Math

Native FormBound Form
Math.pow() 2×
Math.random()×

Date

Native FormBound Form
Date.UTC()×
Date.now()×
Date.parse()::toUnixOffset() 1

Array

Native FormBound Form
Array.from()×
Array.of()×

ArrayBuffer

JSON

Native FormBound Form
JSON.parse()::toObject() 1
JSON.stringify()::toJSON() 1
Notes:
  1. Bound methods whose names start with "to..." are to be applied to strings (with the exception of ::toJSON() which can be applied to a variety of data types)
  2. Please use the exponentiation operator ** instead

License

MIT © G. Kay Lee

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago