-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
53 lines (53 loc) · 19.9 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"name": "es5-ext",
"version": "0.9.2",
"description": "ECMAScript5 extensions",
"keywords": [
"ecmascript",
"ecmascript5",
"es5",
"extensions",
"ext",
"addons",
"extras",
"javascript",
"util",
"utils",
"utilities"
],
"author": {
"name": "Mariusz Nowak",
"email": "medikoo+es5-ext@medikoo.com",
"url": "http://www.medikoo.com/"
},
"main": "lib",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/es5-ext.git"
},
"bugs": {
"url": "https://github.com/medikoo/es5-ext/issues",
"email": "medikoo+es5-ext@medikoo.com"
},
"engines": {
"node": ">=0.4"
},
"scripts": {
"test": "node ./node_modules/tad/bin/tad lib"
},
"devDependencies": {
"tad": "0.1.x"
},
"licence": "MIT",
"dependencies": {},
"optionalDependencies": {},
"readme": "# es5-ext - ECMAScript5 extensions\n\nMethods, functions and objects that are not part of the standard, written with\nEcmaScript conventions in mind.\n\n## Installation\n\nCan be used in any environment that implements EcmaScript 5th edition. \nMany extensions will also work with ECMAScript 3rd edition, if they're not let [es5-shim](https://github.com/kriskowal/es5-shim) be your aid.\n\n### NPM:\n\n\t$ npm install es5-ext\n\n### Browser:\n\nFor browser, you can create custom toolset with help of\n[modules-webmake](https://github.com/medikoo/modules-webmake)\n\n## Usage\n\n__es5-ext__ mostly offer methods (not functions) which can directly be\nassigned to native object's prototype:\n\n\tFunction.prototype.partial = require('es5-ext/lib/Function/prototype/partial');\n\n\tArray.prototype.flatten = require('es5-ext/lib/Array/prototype/flatten');\n\n\tString.prototype.startsWith = require('es5-ext/lib/String/prototype/starts-with');\n\nIf you decide not to extend native prototypes, which in many cases is good idea (see\n[extending-javascript-natives](http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/)\nfor more views on that matter), you can use methods as\nfunctions:\n\n\tvar util = {};\n\tvar call = Function.prototype.call;\n\n\tutil.partial = call.bind(require('es5-ext/lib/Function/prototype/partial'));\n\n\tutil.flatten = call.bind(require('es5-ext/lib/Array/prototype/flatten'));\n\n\tutil.startsWith = call.bind(require('es5-ext/lib/String/prototype/starts-with'));\n\nAs with native ones most methods are generic and can be run on any object.\nIn more detail:\n\n* `Array.prototype`, `Number.prototype` and `String.prototype`, methods can be run on any object (any\nvalue that's neither _null_ nor _undefined_),\n* `Date.prototype` methods should be called only on `Date` instances.\n* `Function.prototype` methods can be called on any callable objects (not\nnecessarily functions)\n\nAPI doesn't provide any methods for `Object.prototype` (extending such in any case should be avoided). All `Object` utils are provided as fuctions and most of them expect first input argument to be a valid object (any value that's neither _null_ nor _undefined_).\n\n# API\n\n## Global extensions\n\n### global\n\nObject that represents global scope\n\n### reserved\n\nList of EcmaScript 5th edition reserved keywords. \nAdditionally under _keywords_, _future_ and _futureStrict_ properties we have lists grouped thematically.\n\n## Array Constructor extensions\n\n### from(x)\n\n_In EcmaScript 6th Edition draft_ \nConvert array-like object to an Array\n\n### generate([length[, …fill]])\n\nGenerate an array of pregiven _length_ built of repeated arguments.\n\n### of([…items])\n\n_In EcmaScript 6th Edition draft_ \nCreate an array from given arguments.\n\n## Array Prototype extensions\n\n### binarySearch(compareFn)\n\nIn __sorted__ list search for index of item for which _compareFn_ returns value closest to _0_. \nIt's variant of binary search algorithm\n\n### clear()\n\nClears the array\n\n### commonLeft([…lists])\n\nReturns first index at which _lists_ start to differ\n\n### compact()\n\nReturns a copy of the list with all falsy values removed.\n\n### contains(searchElement[, position])\n\nWhether list contains the given value.\n\n### copy()\n\nReturns a copy of the list\n\n### diff(other)\n\nReturns the array of elements that are present in context list but not present in other list.\n\n### eIndexOf(searchElement[, fromIndex])\n\n[_egal_](http://wiki.ecmascript.org/doku.php?id=harmony:egal) version of `indexOf` method\n\n### eLastIndexOf(searchElement[, fromIndex])\n\n[_egal_](http://wiki.ecmascript.org/doku.php?id=harmony:egal) version of `lastIndexOf` method\n\n### exclusion([…lists]])\n\nReturns the array of elements that are found only in context list or lists given in arguments.\n\n### find(query[, thisArg])\n\nReturn first element for which given function returns true\n\n### first()\n\nReturns value for first declared index\n\n### firstIndex()\n\nReturns first declared index of the array\n\n### flatten()\n\nReturns flattened version of the array\n\n### forEachRight(cb[, thisArg])\n\n`forEach` starting from last element\n\n### group(cb[, thisArg])\n\nGroup list elements by value returned by _cb_ function\n\n### indexesOf(searchElement[, fromIndex])\n\nReturns array of all indexes of given value\n\n### intersection([…lists])\n\nComputes the array of values that are the intersection of all lists (context list and lists given in arguments)\n\n### isCopy(other)\n\nReturns true if both context and _other_ lists have same content\n\n### isUniq()\n\nReturns true if all values in array are unique\n\n### last()\n\nReturns value for last declared index\n\n### lastIndex()\n\nReturns last declared index of the array\n\n### remove(value)\n\nRemove value from the array\n\n### someRight(cb[, thisArg])\n\n`some` starting from last element\n\n### uniq()\n\nReturns duplicate-free version of the array\n\n## Boolean Constructor extensions\n\n### isBoolean(x)\n\nWhether value is boolean\n\n## Date Constructor extensions\n\n### isDate(x)\n\nWhether value is date instance\n\n### validDate(x)\n\nIf given object is not date throw TypeError in other case return it.\n\n## Date Prototype extensions\n\n### copy(date)\n\nReturns a copy of the date object\n\n### daysInMonth()\n\nReturns number of days of date's month\n\n### floorDay()\n\nSets the date time to 00:00:00.000\n\n### floorMonth()\n\nSets date day to 1 and date time to 00:00:00.000\n\n### floorYear()\n\nSets date month to 0, day to 1 and date time to 00:00:00.000\n\n### format(pattern)\n\nFormats date up to given string. Supported patterns:\n\n* `%Y` - Year with century, 1999, 2003\n* `%y` - Year without century, 99, 03\n* `%m` - Month, 01..12\n* `%d` - Day of the month 01..31\n* `%H` - Hour (24-hour clock), 00..23\n* `%M` - Minute, 00..59\n* `%S` - Second, 00..59\n* `%L` - Milliseconds, 000..999\n\n## Error Constructor extensions\n\n### isError(x)\n\nWhether value is error. \nIt returns true for all Error instances and Exception host instances (e.g. DOMException)\n\n### validError(x)\n\nIf given object is not error throw TypeError in other case return it.\n\n## Error Prototype extensions\n\n### throw()\n\nThrows error\n\n## Function Constructor extensions\n\nSome of the functions were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele\n\n### i(x)\n\nIdentity function. Returns first argument\n\n_i(x) =def x_\n\n### insert(name, value)\n\nReturns a function that will set _name_ to _value_ on given object\n\n_insert(name, value)(obj) =def object\\[name\\] = value_\n\n### invoke(name[, …args])\n\nReturns a function that takes an object as an argument, and applies object's\n_name_ method to arguments. \n_name_ can be name of the method or method itself.\n\n_invoke(name, …args)(object, …args2) =def object\\[name\\]\\(…args, …args2\\)_\n\n### isArguments(x)\n\nWhether value is arguments object\n\n### isFunction(arg)\n\nWether value is instance of function\n\n### k(x)\n\nReturns a constant function that returns pregiven argument\n\n_k(x)(y) =def x_\n\n### noop()\n\nNo operation function\n\n### pluck(name)\n\nReturns a function that takes an object, and returns the value of its _name_\nproperty\n\n_pluck(name)(obj) =def obj[name]_\n\n### remove(name)\n\nReturns a function that takes an object, and deletes object's _name_ property\n\n_remove(name)(obj) =def delete obj[name]_\n\n### validFunction(arg)\n\nIf given object is not function throw TypeError in other case return it.\n\n## Function Prototype extensions\n\nSome of the methods were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele\n\n### chain([…fns])\n\nApplies the functions in argument-list order.\n\n_f1.chain(f2, f3, f4)(…args) =def f4(f3(f2(f1(…arg))))_\n\n### curry([n])\n\nInvoking the function returned by this function only _n_ arguments are passed to the underlying function. If the underlying function is not saturated, the result is a function that passes all its arguments to the underlying function. \nIf _n_ is not provided then it defaults to context function length\n\n_f.curry(4)(arg1, arg2)(arg3)(arg4) =def f(arg1, args2, arg3, arg4)_\n\n### lock([…args])\n\nReturns a function that applies the underlying function to _args_, and ignores its own arguments.\n\n_f.lock(…args)(…args2) =def f(…args)_\n\n_Named after it's counterpart in Google Closure_\n\n### match()\n\nReturns a function that applies underlying function with first list argument\n\n_f.match()(args) =def f.apply(null, args)_\n\n### not()\n\nReturns a function that returns boolean negation of value returned by underlying function.\n\n_f.not()(…args) =def !f(…args)_\n\n### partial([…args])\n\nReturns a function that when called will behave like context function called with initially passed arguments. If more arguments are suplilied, they are appended to initial args.\n\n_f.partial(…args1)(…args2) =def f(…args1, …args2)_\n\n### silent()\n\nReturns a function that when called silents any error thrown by underlying function.\nIf underlying function throws error, it is the result fo the function.\n\n_function () { throw err; }.silent()() ==def err_\n\n### wrap(fn)\n\nWrap function with other function, it allows to specify before and after behavior, transform return value or prevent original function from being called.\n\nInspired by [Prototype's wrap](http://api.prototypejs.org/language/Function/prototype/wrap/)\n\n## Number Constructor extensions\n\n### isNaN(x)\n\n_In EcmaScript 6th Edition draft_ \n\nWhether value is NaN. Differs from global isNaN that it doesn't do type coercion.\nSee http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan\n\n### isNumber(x)\n\nWhether given value is number\n\n### toInt(x)\n\n_In EcmaScript 6th Edition draft_ \n\nConverts value to integer\n\n### toUint(x)\n\nConverts value to unsigned integer\n\n### toUint32(x)\n\nConverts value to unsigned 32 bit integer. This type is used for array lengths.\nSee: http://www.2ality.com/2012/02/js-integers.html\n\n## Number Prototype extensions\n\n### pad(length[, precision])\n\nPad given number with zeros. Returns string\n\n## Object Constructor extensions\n\n### clear(obj)\n\nRemove all enumerable own properties of the object\n\n### compact(obj)\n\nReturns copy of the object with all enumerable properties that have no falsy values\n\n### compare(obj1, obj2)\n\nUniversal cross-type compare function. To be used for e.g. array sort.\n\n### copy(obj[, deep])\n\nReturns copy of the object with all enumerable properties. Additionally nested objects can be copied as well\n\n### count(obj)\n\nCounts number of enumerable own properties on object\n\n### descriptor([mode[, value]])\n### descriptor.gs([mode[, get[, set]]])\n\nDescriptor factory.\n_mode_ is string, through we which we define whether value should be _configurable_, _enumerable_ and/or _writable_, it's accepted as string of tokens, e.g.: `c`, `ce`, `cew`, `cw`, `e`, `ew`, `w`\nIf _mode_ is not provided than `cw` _mode_ is assumed (it's how standard methods are defined on native objects). \nTo setup descriptor with getter and/or setter use `descriptor.gs`, _mode_ is configured same way as in _value_ version, only difference is that settings for _writable_ attribute are ignored.\n\n### diff(obj1, obj2)\n\nReturns differences between two objects (taking into account only its own enumerable properties). Returned object is array of three arrays. Each array holds property names:\n\n* 0 - properties that were not present in `obj2`\n* 1 - properties that have different values\n* 2 - properties that were not present in `obj1`\n\n### every(obj, cb[, thisArg[, compareFn]])\n\nAnalogous to Array.prototype.every. Returns true if every key-value pair in this object satisfies the provided testing function. \nOptionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key).\n\n### extend(dest[, …src])\n\nExtend _dest_ by enumerable own properties of other objects. Properties found in both objects will be overwritten.\n\n### extendDeep(dest[, …src])\n\nExtend _dest_ by enumerable own properties of other objects. Properties found in both objects will be overwritten with exception of plain objects which again reiterated so only matching properties from other nested plain objects are affected\n\n### extendProperties(dest[, …src])\n\nExtend _dest_ by all own properties of other objects. Properties found in both objects will be overwritten (unless they're not configrable and cannot be overwritten).\n\n### filter(obj, cb[, thisArg])\n\nAnalogous to Array.prototype.filter. Returns new object with properites for which _cb_ function returned truthy value.\n\n### flatten(obj)\n\nReturns new object, with flatten properties of input object\n\n_flatten({ a: { b: 1 }, c: { d: 1 } }) =def { b: 1, d: 1 }_\n\n### forEach(obj, cb[, thisArg[, compareFn]])\n\nAnalogous to Array.prototype.forEach. Calls a function for each key-value pair found in object\nOptionally _compareFn_ can be provided which assures that properties are iterated in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key).\n\n### getPropertyNames()\n\nGet all (not just own) property names of the object\n\n### is(x, y)\n\n_In EcmaScript 6th Edition draft as `is` operator_ \n\nWhether two values are equal, takes into account NaN and -0/+0 cases\n\n### isCallable(x)\n\nWhether object is callable\n\n### isCopy(x, y[, depth])\n\nTwo values are considered a copy of same value when they meet following rules:\n\n1. Are of same type (`typeof` check)\n2. Have same string representation\n3. (Objects only) Own enumerable properties of first object match own\nenumerable properties of other object. Optionally depth can be provided at which relaxed comparision rules need to be applied. This allows deep comparision of different objects.\n\nObjects can contain self references, algorithm is aware of possible infinite loop traps and won't into them.\n\n### isEmpty(obj)\n\nTrue if object doesn't have any own enumerable property\n\n### isList(x)\n\nWhether object is array-like object\n\n### isObject(arg)\n\nWhether value is not primitive\n\n### isPlainObject(arg)\n\nWhether object is plain object, its protototype should be Object.prototype and it cannot be host object.\n\n### keyOf(obj, searchValue)\n\nSearch object for value\n\n### map(obj, cb[, thisArg])\n\nAnalogous to Array.prototype.map. Creates a new object with properties which values are results of calling a provided function on every key-value pair in this object.\n\n### mapKeys(obj, cb[, thisArg])\n\nCreate new object with same values, but remapped keys\n\n### mapToArray(obj[, cb[, thisArg[, compareFn]]])\n\nCreates an array of results of calling a provided function on every key-value pair in this object. \nOptionally _compareFn_ can be provided which assures that results are added in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key).\n\n### reduce(obj, cb[, initial[, compareFn]])\n\nAnalogous to Array.prototype.reduce. Apply a function against an accumulator and each value of the object.\nOptionally _compareFn_ can be provided which assures that object keys are iterated in given order. If _compareFn_ is equal to `true`, then order is alphabetical (by key).\nIf we need to provide _compareFn_ but don't want to provide _initial_ value, then we have to pass `reduce.NO_INITIAL` as initial argument.\n\n### safeTraverse(obj[, …names])\n\nSave navigation of object properties. See http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator\n\n### some(obj, cb[, thisArg[, compareFn]])\n\nAnalogous to Array.prototype.some Returns true if any key-value pair satisfies the provided\ntesting function. \nOptionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key).\n\n### toPlainObject(x)\n\nReturns plain object build from x object and it's prototypes enumerable properties\nIf x is not given, then empty object is returned.\n\n### validCallable(x)\n\nIf given object is not callable throw TypeError in other case return it.\n\n### validValue(x)\n\nThrows error if given value is `null` or `undefined`, otherwise returns value.\n\n### values(obj)\n\nReturn array of object own enumerable properties\n\n## RegExp Constructor extensions\n\n### isRegExp(x)\n\nWhether object is regular expression\n\n## String Constructor extensions\n\n### isString(x)\n\nWhether object is string\n\n## String Prototype extensions\n\n### camelToHyphen()\n\nConvert camelCase string to hyphen separated, e.g. one-two-three -> oneTwoThree.\nUseful when converting names from js property convention into filename convention.\n\n### capitalize()\n\nCapitalize first character of a string\n\n### caseInsensitiveCompare(str)\n\nCase insensitive compare\n\n### contains(searchString[, position])\n\n_In EcmaScript 6th Edition draft_ \nWhether string contains given string.\n\n### endsWith(searchString[, endPosition])\n\n_In EcmaScript 6th Edition draft_ \nWhether strings ends with given string\n\n### format(fmap[, thisArg])\n\nFormats given template up to provided map, e.g.:\n\n```javascript\n\"%capital is a capital of %country\".format({\n\tcapital: \"Warsaw\",\n\tcountry: \"Poland\"\n}); // -> \"Warsaw is a capital of Poland\"\n```\nMap may also provide not direct values but functions that resolve value, in that case optional _thisArg_ determines the context in which functions are called.\n\n### hyphenToCamel()\n\nConvert hyphen separated string to camelCase, e.g. one-two-three -> oneTwoThree.\nUseful when converting names from filename convention to js property name convention.\n\n### indent(str[, count])\n\nIndents each line with provided _str_ (if _count_ given then _str_ is repeated _count_ times).\n\n### last()\n\nReturn last character\n\n### pad(fill[, length])\n\nPad string with _fill_.\nIf _length_ si given than _fill_ is reapated _length_ times.\nIf _length_ is negative then pad is applied from right.\n\n### repeat(n)\n\nRepeat given string _n_ times\n\n### simpleReplace(search, replace)\n\nSimple `replace` version. Doesn't support regular expressions. Replaces just first occurence of search string. Doesn't support insert patterns, therefore it is safe to replace text with text obtained programmatically (there's no need for additional _$_ characters escape in such case).\n\n### startsWith(searchString[, position])\n\n_In EcmaScript 6th Edition draft_ \nWhether strings starts with given string\n\n### trimCommonLeft([…strings])\n\nReturns string left trimmed by characters same for all strings\n\n## Math Object extensions\n\n### sign(n)\n\n_In EcmaScript 6th Edition draft_ \nReturns sign of a number value\n\n## Tests [![Build Status](https://secure.travis-ci.org/medikoo/es5-ext.png?branch=master)](https://secure.travis-ci.org/medikoo/es5-ext)\n\n\t$ npm test\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/medikoo/es5-ext",
"_id": "es5-ext@0.9.2",
"dist": {
"shasum": "af21e0cee10701efd1657c6b0542964143076964"
},
"_from": "es5-ext@0.9.2",
"_resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.9.2.tgz"
}