UNPKG

3.61 kBMarkdownView Raw
1**Protege is a supah wikkit sikk NodeJS coffee-script library that takes pointers from PrototypeJS and Ruby**
2
3
4## Installation
5
6To 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()
38.downcase() - Alias for toLowerCase()
39
40.strip() - Alias for trim()
41.stripr() - Alias for trimRight()
42.stripl() - Alias for trimLeft()
43
44.contains(value) - Returns true if the string contains value
45.containsIgnoreCase(value) - Returns true if the string contains value ignoring case
46.equals(value) - Returns true if the string is value
47.equalsIgnoreCase(value) - Returns true if the string equals value ignoring case
48```
49
50### Object
51```
52.clone() - Duplicates the object into a new reference
53
54.isObject() - Returns true if object is an object
55.isArray() - Returns true if object is an array
56.isElement() - Returns true if object is a DOM element
57.isHash() - Returns true if object is a Hash
58.isBoolean() - Returns true if object is a boolean
59.isNumber() - Returns true if object is a number
60.isString() - Returns true if object is a string
61.isFunction() - Returns true if object is a function
62.isXML() - Returns true if object is an XML object
63
64.values() - Returns all values in the object
65.getKeys(value) - Returns all keys for the corresponding value
66.getValues(key) - Returns all values for the corresponding key
67
68.stringify() - Returns JSON string for object
69```
70
71## Examples
72
73You can view further examples in the [example folder.](https://github.com/Contra/protege/tree/master/examples)
74
75## Contributors
76
77- [Contra](https://github.com/Contra)
78
79## LICENSE
80
81(MIT License)
82
83Copyright (c) 2011 Contra <contra@australia.edu>
84
85Permission is hereby granted, free of charge, to any person obtaining
86a copy of this software and associated documentation files (the
87"Software"), to deal in the Software without restriction, including
88without limitation the rights to use, copy, modify, merge, publish,
89distribute, sublicense, and/or sell copies of the Software, and to
90permit persons to whom the Software is furnished to do so, subject to
91the following conditions:
92
93The above copyright notice and this permission notice shall be
94included in all copies or substantial portions of the Software.
95
96THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
97EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
98MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
99NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
100LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
101OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
102WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
103
\No newline at end of file