@@ -49,14 +49,12 @@ getPublicArray(array = []): PublicArray
49
49
50
50
### Properties
51
51
52
- #### className: string (read-only)
52
+ #### data: any[ ] (read-writable)
53
+ ###### This is the array to be operated on.
53
54
54
55
#### copy: PublicArray (read-only)
55
56
###### an independent copy of the PublicArray instance
56
57
57
- #### data: any[ ] (read-writable)
58
- ###### This is the array to be operated on.
59
-
60
58
#### length: number (read-writable)
61
59
###### length of array
62
60
@@ -91,6 +89,79 @@ getConverted.each(mappingFunction: ((item, index?, array?) => any)): any[]
91
89
```
92
90
93
91
#### get: PublicArrayGetter (read-only)
92
+ ###### This has methods that return items copied from the array. None of them modify the array.
93
+ ```
94
+ get.copy(): any[]
95
+ // Returns independent copy of the array.
96
+
97
+ get.byIndex(index): any
98
+ // Returns 1 item. index can be negative or positive.
99
+
100
+ get.byIndexes(indexes): any[]
101
+ // indexes can be negative or positive.
102
+
103
+ get.head(numItems): any[]
104
+ // returns numItems from beginning
105
+
106
+ get.tail(numItems): any[]
107
+ // returns numItems from end
108
+
109
+ get.between(numItemsToIgnoreAtEachEnd): any[]
110
+ // Returns middle of array, between numItemsToIgnoreAtEachEnd
111
+
112
+ get.adjacentAt(startingIndex, numItems): any[]
113
+ // Returns adjacent items. startingIndex can be negative or positive.
114
+
115
+ get.adjacentToValue(info: IAdjacentToValueInfo): any[]
116
+ /**************
117
+ Returns adjacent items including, or near, a particular value.
118
+ Only applies to the first instance of value found in array.
119
+ The parameter 'info' is an object that looks like this:
120
+ {
121
+ value: any except object (the value to search for in the array),
122
+ offset: integer (tells function where, in relation to value, to begin selecting adjacent
123
+ items to return. If offset is zero, the selection will begin with value.)
124
+ howMany: integer greater than zero (it's how many adjacent items to return)
125
+ }
126
+ Example:
127
+ // arr.data is [1,2,3,4,5,6,7,8,9,10]
128
+ let numbers = arr.get.adjacentToValue({value:5, offset: -2, howMany:3});
129
+ // numbers is now [3,4,5]
130
+ ***************/
131
+
132
+ get.allAfterFirst(value: any): any[]
133
+ // value cannot be object
134
+
135
+ get.allBeforeFirst(value: any): any[]
136
+ // value cannot be object
137
+
138
+ get.allAfterLast(value: any): any[]
139
+ // value cannot be object
140
+
141
+ get.allBeforeLast(value: any): any[]
142
+ // value cannot be object
143
+
144
+ get.uniqueItems(): any[]
145
+ // returns no duplicates.
146
+
147
+ get.duplicates(): any[]
148
+ // returns every instance of a duplicate, so you may get multiple instances.
149
+
150
+ get.shuffled(): any[]
151
+ // returns new, shuffled version of the array
152
+
153
+ get.byTest(testFunction: ((currentValue, currentIndex?, array?) => boolean)): IValueIndexPair[]
154
+ /***************
155
+ Almost exactly like Array.filter(), except it returns array of IValueIndexPairs.
156
+ A IValueIndexPair is this object: {value: any, index: integer}
157
+ It's both the value filtered by the testFunction and its index.
158
+ ***************/
159
+
160
+ get.byType(
161
+ type: 'object' | 'array' | 'number' | 'string' | 'boolean' | 'function' | 'undefined'
162
+ ): IValueIndexPair[]
163
+ // For explanation of IValueIndexPair, see explanation of byTest().
164
+ ```
94
165
95
166
#### getAndRemove: PublicArrayGetterRemover (read-only)
96
167
@@ -102,6 +173,8 @@ getConverted.each(mappingFunction: ((item, index?, array?) => any)): any[]
102
173
103
174
#### sort: PublicArraySorter (read-only)
104
175
176
+ #### className: string (read-only)
177
+
105
178
106
179
### Methods
107
180
0 commit comments