1 | **Protege is a versatile NodeJS extension library that aims to make code as simple as possible**
|
2 |
|
3 |
|
4 | ## Installation
|
5 |
|
6 | To install Protege, use [npm](http://github.com/isaacs/npm):
|
7 |
|
8 | $ npm install -g protege
|
9 |
|
10 | ## Usage
|
11 |
|
12 | ```require('protege')``` - it's that easy
|
13 |
|
14 | ### Array
|
15 | ```
|
16 | .clone() - Duplicates the array into a new reference.
|
17 |
|
18 | .merge(arr) - Adds array arr to array
|
19 | .unique() - Returns a copy of the array with duplicates removed
|
20 | .flatten() - Returns a one-dimensional copy of the array
|
21 | .compact() - Returns a copy of the array with all undefined and null items removed
|
22 | .intersect(arr) - Returns an array of all items in both arr and the array
|
23 |
|
24 | .size() - Returns size of array
|
25 | .first() - Returns first value or array or undefined
|
26 | .last() - Returns last value or array or undefined
|
27 |
|
28 | .remove(value) - Removes first instance of value from array
|
29 | .removeAll(value) - Removes all instances of value from array.
|
30 | .removeAllIgnoreCase(value) - Removes all instances of value from array ignoring case
|
31 | .removeIndex(idx) - Removes index of idx from array
|
32 | .clear() - Removes all items from array
|
33 | ```
|
34 |
|
35 | ### String
|
36 | ```
|
37 | .upcase() - Alias for toUpperCase(), inspired by Ruby syntax
|
38 | .downcase() - Alias for toLowerCase(), inspired by Ruby syntax
|
39 |
|
40 | .strip() - Alias for trim(), inspired by Ruby syntax
|
41 | .stripr() - Alias for trimRight(), inspired by Ruby syntax
|
42 | .stripl() - Alias for trimLeft(), inspired by Ruby syntax
|
43 |
|
44 | .contains(value) - Returns true if the string contains value, inspired by Java syntax
|
45 | .containsIgnoreCase(value) - Returns true if the string contains value ignoring case, inspired by Java syntax
|
46 | .equals(value) - Returns true if the string is value, inspired by Java syntax
|
47 | .equalsIgnoreCase(value) - Returns true if the string equals value ignoring case, inspired by Java syntax
|
48 | ```
|
49 |
|
50 | ### Object
|
51 | ```
|
52 | .clone() - Duplicates the object into a new reference
|
53 |
|
54 | Object.isObject(object) - Returns true if object is an object
|
55 | Object.isArray(object) - Returns true if object is an array
|
56 | Object.isElement(object) - Returns true if object is a DOM element
|
57 | Object.isBoolean(object) - Returns true if object is a boolean
|
58 | Object.isNumber(object) - Returns true if object is a number
|
59 | Object.isString(object) - Returns true if object is a string
|
60 | Object.isFunction(object) - Returns true if object is a function
|
61 | Object.isXML(object) - Returns true if object is an XML object
|
62 |
|
63 | .keys() - Returns all keys in the object
|
64 | .values() - Returns all values in the object
|
65 | .getKey() - Returns first key in object
|
66 | .getValue() - Returns first value in object
|
67 | .getKeys(value) - Returns all keys for the corresponding value
|
68 | .getValues(key) - Returns all values for the corresponding key
|
69 |
|
70 | .stringify() - Returns JSON string for object
|
71 | ```
|
72 |
|
73 | ## Examples
|
74 |
|
75 | You can view further examples in the [example folder.](https://github.com/Contra/protege/tree/master/examples)
|
76 |
|
77 | ## Contributors
|
78 |
|
79 | - [Contra](https://github.com/Contra)
|
80 |
|
81 | ## LICENSE
|
82 |
|
83 | (MIT License)
|
84 |
|
85 | Copyright (c) 2011 Contra <contra@australia.edu>
|
86 |
|
87 | Permission is hereby granted, free of charge, to any person obtaining
|
88 | a copy of this software and associated documentation files (the
|
89 | "Software"), to deal in the Software without restriction, including
|
90 | without limitation the rights to use, copy, modify, merge, publish,
|
91 | distribute, sublicense, and/or sell copies of the Software, and to
|
92 | permit persons to whom the Software is furnished to do so, subject to
|
93 | the following conditions:
|
94 |
|
95 | The above copyright notice and this permission notice shall be
|
96 | included in all copies or substantial portions of the Software.
|
97 |
|
98 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
99 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
100 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
101 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
102 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
103 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
104 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
105 |
|
\ | No newline at end of file |