# es5-ext
## ECMAScript 5 extensions
### (with respect to ECMAScript 6 standard)
Shims for upcoming ES6 standard and other goodies implemented strictly with ECMAScript conventions in mind.
It's designed to be used in compliant ECMAScript 5 or ECMAScript 6 environments. Older environments are not supported, although most of the features should work with correct ECMAScript 5 shim on board.
When used in ECMAScript 6 environment, native implementation (if valid) takes precedence over shims.
### Installation
$ npm install es5-ext
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
### Usage
#### ECMAScript 6 features
You can force ES6 features to be implemented in your environment, e.g. following will assign `from` function to `Array` (only if it's not implemented already).
```javascript
require('es5-ext/array/from/implement');
Array.from('foo'); // ['f', 'o', 'o']
```
You can also access shims directly, without fixing native objects. Following will return native `Array.from` if it's available and fallback to shim if it's not.
```javascript
var aFrom = require('es5-ext/array/from');
aFrom('foo'); // ['f', 'o', 'o']
```
If you want to use shim unconditionally (even if native implementation exists) do:
```javascript
var aFrom = require('es5-ext/array/from/shim');
aFrom('foo'); // ['f', 'o', 'o']
```
##### List of ES6 shims
It's about properties introduced with ES6 and those that have been updated in new spec.
- `Array.from` -> `require('es5-ext/array/from')`
- `Array.of` -> `require('es5-ext/array/of')`
- `Array.prototype.concat` -> `require('es5-ext/array/#/concat')`
- `Array.prototype.copyWithin` -> `require('es5-ext/array/#/copy-within')`
- `Array.prototype.entries` -> `require('es5-ext/array/#/entries')`
- `Array.prototype.fill` -> `require('es5-ext/array/#/fill')`
- `Array.prototype.filter` -> `require('es5-ext/array/#/filter')`
- `Array.prototype.find` -> `require('es5-ext/array/#/find')`
- `Array.prototype.findIndex` -> `require('es5-ext/array/#/find-index')`
- `Array.prototype.keys` -> `require('es5-ext/array/#/keys')`
- `Array.prototype.map` -> `require('es5-ext/array/#/map')`
- `Array.prototype.slice` -> `require('es5-ext/array/#/slice')`
- `Array.prototype.splice` -> `require('es5-ext/array/#/splice')`
- `Array.prototype.values` -> `require('es5-ext/array/#/values')`
- `Array.prototype[@@iterator]` -> `require('es5-ext/array/#/@@iterator')`
- `Math.acosh` -> `require('es5-ext/math/acosh')`
- `Math.asinh` -> `require('es5-ext/math/asinh')`
- `Math.atanh` -> `require('es5-ext/math/atanh')`
- `Math.cbrt` -> `require('es5-ext/math/cbrt')`
- `Math.clz32` -> `require('es5-ext/math/clz32')`
- `Math.cosh` -> `require('es5-ext/math/cosh')`
- `Math.exmp1` -> `require('es5-ext/math/expm1')`
- `Math.fround` -> `require('es5-ext/math/fround')`
- `Math.hypot` -> `require('es5-ext/math/hypot')`
- `Math.imul` -> `require('es5-ext/math/imul')`
- `Math.log1p` -> `require('es5-ext/math/log1p')`
- `Math.log2` -> `require('es5-ext/math/log2')`
- `Math.log10` -> `require('es5-ext/math/log10')`
- `Math.sign` -> `require('es5-ext/math/sign')`
- `Math.signh` -> `require('es5-ext/math/signh')`
- `Math.tanh` -> `require('es5-ext/math/tanh')`
- `Math.trunc` -> `require('es5-ext/math/trunc')`
- `Number.EPSILON` -> `require('es5-ext/number/epsilon')`
- `Number.MAX_SAFE_INTEGER` -> `require('es5-ext/number/max-safe-integer')`
- `Number.MIN_SAFE_INTEGER` -> `require('es5-ext/number/min-safe-integer')`
- `Number.isFinite` -> `require('es5-ext/number/is-finite')`
- `Number.isInteger` -> `require('es5-ext/number/is-integer')`
- `Number.isNaN` -> `require('es5-ext/number/is-nan')`
- `Number.isSafeInteger` -> `require('es5-ext/number/is-safe-integer')`
- `Object.assign` -> `require('es5-ext/object/assign')`
- `Object.keys` -> `require('es5-ext/object/keys')`
- `Object.setPrototypeOf` -> `require('es5-ext/object/set-prototype-of')`
- `RegExp.prototype.match` -> `require('es5-ext/reg-exp/#/match')`
- `RegExp.prototype.replace` -> `require('es5-ext/reg-exp/#/replace')`
- `RegExp.prototype.search` -> `require('es5-ext/reg-exp/#/search')`
- `RegExp.prototype.split` -> `require('es5-ext/reg-exp/#/split')`
- `RegExp.prototype.sticky` -> Implement with `require('es5-ext/reg-exp/#/sticky/implement')`, use as function with `require('es5-ext/reg-exp/#/is-sticky')`
- `RegExp.prototype.unicode` -> Implement with `require('es5-ext/reg-exp/#/unicode/implement')`, use as function with `require('es5-ext/reg-exp/#/is-unicode')`
- `String.fromCodePoint` -> `require('es5-ext/string/from-code-point')`
- `String.raw` -> `require('es5-ext/string/raw')`
- `String.prototype.codePointAt` -> `require('es5-ext/string/#/code-point-at')`
- `String.prototype.contains` -> `require('es5-ext/string/#/contains')`
- `String.prototype.endsWith` -> `require('es5-ext/string/#/ends-with')`
- `String.prototype.normalize` -> `require('es5-ext/string/#/normalize')`
- `String.prototype.repeat` -> `require('es5-ext/string/#/repeat')`
- `String.prototype.startsWith` -> `require('es5-ext/string/#/starts-with')`
- `String.prototype[@@iterator]` -> `require('es5-ext/string/#/@@iterator')`
#### Non ECMAScript standard features
__es5-ext__ provides also other utils, and implements them as if they were proposed for a standard. It mostly offers methods (not functions) which can directly be assigned to native prototypes:
```javascript
Object.defineProperty(Function.prototype, 'partial', { value: require('es5-ext/function/#/partial'),
configurable: true, enumerable: false, writable: true });
Object.defineProperty(Array.prototype, 'flatten', { value: require('es5-ext/array/#/flatten'),
configurable: true, enumerable: false, writable: true });
Object.defineProperty(String.prototype, 'capitalize', { value: require('es5-ext/string/#/capitalize'),
configurable: true, enumerable: false, writable: true });
```
See [es5-extend](https://github.com/wookieb/es5-extend#es5-extend), a great utility that automatically will extend natives for you.
__Important:__ Remember to __not__ extend natives in scope of generic reusable packages (e.g. ones you intend to publish to npm). Extending natives is fine __only__ if you're the _owner_ of the global scope, so e.g. in final project you lead development of.
When you're in situation when native extensions are not good idea, then you should use methods indirectly:
```javascript
var flatten = require('es5-ext/array/#/flatten');
flatten.call([1, [2, [3, 4]]]); // [1, 2, 3, 4]
```
for better convenience you can turn methods into functions:
```javascript
var call = Function.prototype.call
var flatten = call.bind(require('es5-ext/array/#/flatten'));
flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4]
```
You can configure custom toolkit (like [underscorejs](http://underscorejs.org/)), and use it throughout your application
```javascript
var util = {};
util.partial = call.bind(require('es5-ext/function/#/partial'));
util.flatten = call.bind(require('es5-ext/array/#/flatten'));
util.startsWith = call.bind(require('es5-ext/string/#/starts-with'));
util.flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4]
```
As with native ones most methods are generic and can be run on any type of object.
## API
### Global extensions
#### global _(es5-ext/global)_
Object that represents global scope
### Array Constructor extensions
#### from(arrayLike[, mapFn[, thisArg]]) _(es5-ext/array/from)_
[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from).
Returns array representation of _iterable_ or _arrayLike_. If _arrayLike_ is an instance of array, its copy is returned.
#### generate([length[, …fill]]) _(es5-ext/array/generate)_
Generate an array of pre-given _length_ built of repeated arguments.
#### isPlainArray(x) _(es5-ext/array/is-plain-array)_
Returns true
没有合适的资源?快使用搜索试试~ 我知道了~
Electron-node-ffi编译通过源码
共1800个文件
js:1056个
c:160个
md:84个
4星 · 超过85%的资源 需积分: 50 37 下载量 27 浏览量
2017-12-18
18:29:58
上传
评论 1
收藏 9.64MB ZIP 举报
温馨提示
Electron-node-ffi编译通过源码,可以自己下node-gyp失败,可能ffi无法直接安装,那么这个源码是基于github上的代码,自己编译通过的,可以直接加入node_moduble使用
资源推荐
资源详情
资源评论
收起资源包目录
Electron-node-ffi编译通过源码 (1800个子文件)
he.1 3KB
ffi_call.3 2KB
ffi_prep_cif_var.3 1KB
ffi_prep_cif.3 1KB
ffi.3 891B
_mocha 13KB
_mocha 303B
configure.ac 15KB
Makefile.am 7KB
Makefile.am 4KB
Makefile.am 258B
Makefile.am 215B
win32.asm 12KB
win64.asm 4KB
utf16le.bin 74KB
dlmalloc.c 184KB
ffi.c 40KB
ffi_darwin.c 38KB
ffi.c 27KB
ffi.c 25KB
ffi.c 23KB
ffi.c 21KB
ffi.c 20KB
ffi64.c 18KB
ffi.c 18KB
closures.c 17KB
ffi.c 16KB
ffi.c 16KB
huge_struct.c 15KB
ffi.c 13KB
ffi.c 11KB
ffi.c 10KB
java_raw_api.c 9KB
ffi.c 9KB
ffi.c 8KB
ffi.c 8KB
ffi.c 7KB
prep_cif.c 7KB
raw_api.c 6KB
ffi.c 6KB
nested_struct1.c 5KB
stret_large2.c 5KB
nested_struct.c 5KB
stret_large.c 5KB
cls_pointer_stack.c 4KB
cls_64byte.c 4KB
stret_medium2.c 4KB
stret_medium.c 4KB
cls_align_longdouble_split.c 4KB
nested_struct10.c 4KB
nested_struct8.c 4KB
nested_struct9.c 4KB
nested_struct6.c 3KB
cls_7_1_byte.c 3KB
cls_24byte.c 3KB
cls_align_longdouble_split2.c 3KB
cls_6_1_byte.c 3KB
closure_loc_fn0.c 3KB
closure_fn6.c 3KB
closure_fn5.c 3KB
cls_5_1_byte.c 3KB
closure_fn4.c 3KB
closure_fn0.c 3KB
cls_19byte.c 3KB
closure_fn3.c 3KB
types.c 3KB
closure_fn2.c 3KB
cls_4_1byte.c 3KB
closure_fn1.c 3KB
cls_longdouble.c 3KB
nested_struct7.c 3KB
nested_struct5.c 3KB
nested_struct3.c 3KB
nested_struct4.c 3KB
cls_18byte.c 3KB
cls_6byte.c 3KB
nested_struct2.c 3KB
cls_7byte.c 3KB
float_va.c 3KB
cls_align_pointer.c 3KB
cls_3_1byte.c 3KB
cls_5byte.c 3KB
cls_align_uint64.c 3KB
cls_align_sint64.c 3KB
cls_16byte.c 3KB
cls_align_longdouble.c 3KB
cls_align_float.c 3KB
cls_20byte1.c 3KB
cls_20byte.c 3KB
cls_12byte.c 3KB
cls_align_uint16.c 3KB
cls_align_sint16.c 3KB
cls_align_uint32.c 3KB
cls_align_double.c 3KB
cls_align_sint32.c 3KB
cls_3byte2.c 3KB
pyobjc-tc.c 2KB
cls_3byte1.c 2KB
cls_9byte1.c 2KB
cls_9byte2.c 2KB
共 1800 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
- 丧心病狂的呆毛2021-01-04好东西,可以试试
- iamdair2018-07-16能说说怎么部署吗
Ants-double
- 粉丝: 54
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功