@ohos-ports/stdlib-object 0.0.0-stage → 0.4.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +262 -2
  4. package/SECURITY.md +5 -0
  5. package/any-in-by/README.md +217 -0
  6. package/any-in-by/docs/repl.txt +41 -0
  7. package/any-in-by/docs/types/index.d.ts +102 -0
  8. package/any-in-by/docs/types/test.ts +53 -0
  9. package/any-in-by/lib/index.js +50 -0
  10. package/any-in-by/lib/main.js +75 -0
  11. package/any-in-by/package.json +66 -0
  12. package/any-own-by/README.md +221 -0
  13. package/any-own-by/docs/repl.txt +43 -0
  14. package/any-own-by/docs/types/index.d.ts +101 -0
  15. package/any-own-by/docs/types/test.ts +63 -0
  16. package/any-own-by/lib/index.js +46 -0
  17. package/any-own-by/lib/main.js +77 -0
  18. package/any-own-by/package.json +70 -0
  19. package/assign/README.md +139 -0
  20. package/assign/docs/repl.txt +34 -0
  21. package/assign/docs/types/index.d.ts +113 -0
  22. package/assign/docs/types/test.ts +47 -0
  23. package/assign/lib/builtin.js +55 -0
  24. package/assign/lib/has_object_assign.js +33 -0
  25. package/assign/lib/index.js +52 -0
  26. package/assign/lib/polyfill.js +86 -0
  27. package/assign/package.json +64 -0
  28. package/assign-in/README.md +145 -0
  29. package/assign-in/docs/repl.txt +34 -0
  30. package/assign-in/docs/types/index.d.ts +175 -0
  31. package/assign-in/docs/types/test.ts +44 -0
  32. package/assign-in/lib/index.js +54 -0
  33. package/assign-in/lib/main.js +92 -0
  34. package/assign-in/package.json +60 -0
  35. package/bifurcate-in/README.md +298 -0
  36. package/bifurcate-in/docs/repl.txt +68 -0
  37. package/bifurcate-in/docs/types/index.d.ts +189 -0
  38. package/bifurcate-in/docs/types/test.ts +97 -0
  39. package/bifurcate-in/lib/index.js +106 -0
  40. package/bifurcate-in/lib/main.js +148 -0
  41. package/bifurcate-in/lib/return_keys.js +81 -0
  42. package/bifurcate-in/lib/return_pairs.js +87 -0
  43. package/bifurcate-in/lib/return_values.js +87 -0
  44. package/bifurcate-in/lib/validate.js +76 -0
  45. package/bifurcate-in/package.json +72 -0
  46. package/bifurcate-own/README.md +255 -0
  47. package/bifurcate-own/docs/repl.txt +63 -0
  48. package/bifurcate-own/docs/types/index.d.ts +183 -0
  49. package/bifurcate-own/docs/types/test.ts +97 -0
  50. package/bifurcate-own/lib/index.js +87 -0
  51. package/bifurcate-own/lib/main.js +127 -0
  52. package/bifurcate-own/lib/return_keys.js +81 -0
  53. package/bifurcate-own/lib/return_pairs.js +87 -0
  54. package/bifurcate-own/lib/return_values.js +87 -0
  55. package/bifurcate-own/lib/validate.js +76 -0
  56. package/bifurcate-own/package.json +71 -0
  57. package/capitalize-keys/README.md +139 -0
  58. package/capitalize-keys/docs/repl.txt +28 -0
  59. package/capitalize-keys/docs/types/index.d.ts +46 -0
  60. package/capitalize-keys/docs/types/test.ts +33 -0
  61. package/capitalize-keys/lib/index.js +45 -0
  62. package/capitalize-keys/lib/main.js +69 -0
  63. package/capitalize-keys/package.json +76 -0
  64. package/common-keys/README.md +125 -0
  65. package/common-keys/docs/repl.txt +29 -0
  66. package/common-keys/docs/types/index.d.ts +70 -0
  67. package/common-keys/docs/types/test.ts +33 -0
  68. package/common-keys/lib/index.js +51 -0
  69. package/common-keys/lib/main.js +106 -0
  70. package/common-keys/package.json +70 -0
  71. package/common-keys-in/README.md +125 -0
  72. package/common-keys-in/docs/repl.txt +29 -0
  73. package/common-keys-in/docs/types/index.d.ts +70 -0
  74. package/common-keys-in/docs/types/test.ts +33 -0
  75. package/common-keys-in/lib/index.js +51 -0
  76. package/common-keys-in/lib/main.js +106 -0
  77. package/common-keys-in/package.json +72 -0
  78. package/ctor/README.md +536 -0
  79. package/ctor/docs/repl.txt +592 -0
  80. package/ctor/docs/types/index.d.ts +56 -0
  81. package/ctor/docs/types/test.ts +33 -0
  82. package/ctor/lib/index.js +54 -0
  83. package/ctor/lib/main.js +58 -0
  84. package/ctor/package.json +58 -0
  85. package/deep-get/README.md +181 -0
  86. package/deep-get/docs/repl.txt +63 -0
  87. package/deep-get/docs/types/index.d.ts +125 -0
  88. package/deep-get/docs/types/test.ts +109 -0
  89. package/deep-get/lib/defaults.js +38 -0
  90. package/deep-get/lib/dget.js +57 -0
  91. package/deep-get/lib/factory.js +94 -0
  92. package/deep-get/lib/index.js +58 -0
  93. package/deep-get/lib/main.js +101 -0
  94. package/deep-get/lib/validate.js +66 -0
  95. package/deep-get/package.json +68 -0
  96. package/deep-set/README.md +273 -0
  97. package/deep-set/docs/repl.txt +87 -0
  98. package/deep-set/docs/types/index.d.ts +180 -0
  99. package/deep-set/docs/types/test.ts +134 -0
  100. package/deep-set/lib/defaults.js +39 -0
  101. package/deep-set/lib/dset.js +80 -0
  102. package/deep-set/lib/factory.js +99 -0
  103. package/deep-set/lib/index.js +58 -0
  104. package/deep-set/lib/main.js +120 -0
  105. package/deep-set/lib/validate.js +74 -0
  106. package/deep-set/package.json +69 -0
  107. package/docs/types/index.d.ts +964 -0
  108. package/every-in-by/README.md +156 -0
  109. package/every-in-by/docs/repl.txt +43 -0
  110. package/every-in-by/docs/types/index.d.ts +83 -0
  111. package/every-in-by/docs/types/test.ts +60 -0
  112. package/every-in-by/lib/index.js +51 -0
  113. package/every-in-by/lib/main.js +70 -0
  114. package/every-in-by/package.json +67 -0
  115. package/every-own-by/README.md +223 -0
  116. package/every-own-by/docs/repl.txt +43 -0
  117. package/every-own-by/docs/types/index.d.ts +102 -0
  118. package/every-own-by/docs/types/test.ts +62 -0
  119. package/every-own-by/lib/index.js +46 -0
  120. package/every-own-by/lib/main.js +77 -0
  121. package/every-own-by/package.json +68 -0
  122. package/for-in/README.md +218 -0
  123. package/for-in/docs/repl.txt +44 -0
  124. package/for-in/docs/types/index.d.ts +65 -0
  125. package/for-in/docs/types/test.ts +50 -0
  126. package/for-in/lib/index.js +54 -0
  127. package/for-in/lib/main.js +82 -0
  128. package/for-in/package.json +74 -0
  129. package/for-own/README.md +209 -0
  130. package/for-own/docs/repl.txt +49 -0
  131. package/for-own/docs/types/index.d.ts +63 -0
  132. package/for-own/docs/types/test.ts +50 -0
  133. package/for-own/lib/index.js +50 -0
  134. package/for-own/lib/main.js +85 -0
  135. package/for-own/package.json +71 -0
  136. package/inverse/README.md +163 -0
  137. package/inverse/docs/repl.txt +53 -0
  138. package/inverse/docs/types/index.d.ts +66 -0
  139. package/inverse/docs/types/test.ts +60 -0
  140. package/inverse/lib/index.js +59 -0
  141. package/inverse/lib/main.js +123 -0
  142. package/inverse/package.json +69 -0
  143. package/inverse-by/README.md +205 -0
  144. package/inverse-by/docs/repl.txt +67 -0
  145. package/inverse-by/docs/types/index.d.ts +160 -0
  146. package/inverse-by/docs/types/test.ts +81 -0
  147. package/inverse-by/lib/index.js +78 -0
  148. package/inverse-by/lib/main.js +148 -0
  149. package/inverse-by/package.json +75 -0
  150. package/lib/index.js +276 -0
  151. package/lowercase-keys/README.md +139 -0
  152. package/lowercase-keys/docs/repl.txt +28 -0
  153. package/lowercase-keys/docs/types/index.d.ts +46 -0
  154. package/lowercase-keys/docs/types/test.ts +33 -0
  155. package/lowercase-keys/lib/index.js +45 -0
  156. package/lowercase-keys/lib/main.js +63 -0
  157. package/lowercase-keys/package.json +74 -0
  158. package/move-property/README.md +144 -0
  159. package/move-property/docs/repl.txt +38 -0
  160. package/move-property/docs/types/index.d.ts +53 -0
  161. package/move-property/docs/types/test.ts +46 -0
  162. package/move-property/lib/index.js +46 -0
  163. package/move-property/lib/main.js +74 -0
  164. package/move-property/package.json +69 -0
  165. package/none-in-by/README.md +241 -0
  166. package/none-in-by/docs/repl.txt +42 -0
  167. package/none-in-by/docs/types/index.d.ts +101 -0
  168. package/none-in-by/docs/types/test.ts +61 -0
  169. package/none-in-by/lib/index.js +46 -0
  170. package/none-in-by/lib/main.js +71 -0
  171. package/none-in-by/package.json +68 -0
  172. package/none-own-by/README.md +177 -0
  173. package/none-own-by/docs/repl.txt +42 -0
  174. package/none-own-by/docs/types/index.d.ts +102 -0
  175. package/none-own-by/docs/types/test.ts +61 -0
  176. package/none-own-by/lib/index.js +50 -0
  177. package/none-own-by/lib/main.js +75 -0
  178. package/none-own-by/package.json +68 -0
  179. package/package.json +66 -4
  180. package/some-in-by/README.md +232 -0
  181. package/some-in-by/docs/repl.txt +45 -0
  182. package/some-in-by/docs/types/index.d.ts +104 -0
  183. package/some-in-by/docs/types/test.ts +66 -0
  184. package/some-in-by/lib/index.js +46 -0
  185. package/some-in-by/lib/main.js +87 -0
  186. package/some-in-by/package.json +75 -0
  187. package/some-own-by/README.md +251 -0
  188. package/some-own-by/docs/repl.txt +45 -0
  189. package/some-own-by/docs/types/index.d.ts +103 -0
  190. package/some-own-by/docs/types/test.ts +66 -0
  191. package/some-own-by/lib/index.js +46 -0
  192. package/some-own-by/lib/main.js +85 -0
  193. package/some-own-by/package.json +72 -0
  194. package/uncapitalize-keys/README.md +139 -0
  195. package/uncapitalize-keys/docs/repl.txt +28 -0
  196. package/uncapitalize-keys/docs/types/index.d.ts +46 -0
  197. package/uncapitalize-keys/docs/types/test.ts +33 -0
  198. package/uncapitalize-keys/lib/index.js +45 -0
  199. package/uncapitalize-keys/lib/main.js +69 -0
  200. package/uncapitalize-keys/package.json +76 -0
  201. package/uppercase-keys/README.md +139 -0
  202. package/uppercase-keys/docs/repl.txt +28 -0
  203. package/uppercase-keys/docs/types/index.d.ts +46 -0
  204. package/uppercase-keys/docs/types/test.ts +33 -0
  205. package/uppercase-keys/lib/index.js +45 -0
  206. package/uppercase-keys/lib/main.js +63 -0
  207. package/uppercase-keys/package.json +74 -0
@@ -0,0 +1,964 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2022 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /* eslint-disable max-lines */
22
+
23
+ import anyInBy = require( './../../any-in-by' );
24
+ import anyOwnBy = require( './../../any-own-by' );
25
+ import assign = require( './../../assign' );
26
+ import assignIn = require( './../../assign-in' );
27
+ import bifurcateIn = require( './../../bifurcate-in' );
28
+ import bifurcateOwn = require( './../../bifurcate-own' );
29
+ import capitalizeKeys = require( './../../capitalize-keys' );
30
+ import commonKeys = require( './../../common-keys' );
31
+ import commonKeysIn = require( './../../common-keys-in' );
32
+ import Object = require( './../../ctor' );
33
+ import deepGet = require( './../../deep-get' );
34
+ import deepSet = require( './../../deep-set' );
35
+ import everyInBy = require( './../../every-in-by' );
36
+ import everyOwnBy = require( './../../every-own-by' );
37
+ import forIn = require( './../../for-in' );
38
+ import forOwn = require( './../../for-own' );
39
+ import inverse = require( './../../inverse' );
40
+ import inverseBy = require( './../../inverse-by' );
41
+ import lowercaseKeys = require( './../../lowercase-keys' );
42
+ import moveProperty = require( './../../move-property' );
43
+ import noneInBy = require( './../../none-in-by' );
44
+ import noneOwnBy = require( './../../none-own-by' );
45
+ import someInBy = require( './../../some-in-by' );
46
+ import someOwnBy = require( './../../some-own-by' );
47
+ import uncapitalizeKeys = require( './../../uncapitalize-keys' );
48
+ import uppercaseKeys = require( './../../uppercase-keys' );
49
+
50
+ /**
51
+ * Interface describing the `object` namespace.
52
+ */
53
+ interface Namespace {
54
+ /**
55
+ * Tests whether at least one property in an object passes a test implemented by a predicate function.
56
+ *
57
+ * ## Notes
58
+ *
59
+ * - The predicate function is provided three arguments:
60
+ *
61
+ * - `value`: property value
62
+ * - `key`: property key
63
+ * - `obj`: the input object
64
+ *
65
+ * - The function immediately returns upon encountering a truthy return value.
66
+ *
67
+ * - If provided an empty object, the function returns `false`.
68
+ *
69
+ * @param obj - input object
70
+ * @param predicate - test function
71
+ * @param thisArg - execution context
72
+ * @returns boolean indicating whether at least one property passes a test
73
+ *
74
+ * @example
75
+ * function isNegative( v ) {
76
+ * return ( v < 0 );
77
+ * }
78
+ *
79
+ * var obj = { 'a': 1, 'b': -2, 'c': 3 };
80
+ *
81
+ * var bool = ns.anyInBy( obj, isNegative );
82
+ * // returns true
83
+ */
84
+ anyInBy: typeof anyInBy;
85
+
86
+ /**
87
+ * Tests whether any property of an object passes a test implemented by a predicate function.
88
+ *
89
+ * ## Notes
90
+ *
91
+ * - The predicate function is provided three arguments:
92
+ *
93
+ * - `value`: property value
94
+ * - `key`: property key
95
+ * - `object`: the input object
96
+ *
97
+ * - The function immediately returns upon encountering a truthy return value.
98
+ * - If provided an empty object, the function returns `false`.
99
+ *
100
+ * @param object - input object
101
+ * @param predicate - test function
102
+ * @param thisArg - execution context
103
+ * @returns boolean indicating whether any own property pass a test
104
+ *
105
+ * @example
106
+ * function isPositive( v ) {
107
+ * return ( v > 0 );
108
+ * }
109
+ *
110
+ * var obj = { 'a': -1, 'b': 2, 'c': -3 };
111
+ *
112
+ * var bool = ns.anyOwnBy( obj, isPositive );
113
+ * // returns true
114
+ */
115
+ anyOwnBy: typeof anyOwnBy;
116
+
117
+ /**
118
+ * Copies own enumerable properties from one or more source objects to a target object.
119
+ *
120
+ * ## Notes
121
+ *
122
+ * - If a property key is present in multiple sources, the property from the last source that defines the key prevails.
123
+ * - The target object is mutated.
124
+ * - Both string and symbol properties are copied.
125
+ *
126
+ * @param target - target object
127
+ * @param source - source object(s)
128
+ * @throws first argument must not be null or undefined
129
+ * @returns target object
130
+ *
131
+ * @example
132
+ * var obj1 = {
133
+ * 'a': 'beep'
134
+ * };
135
+ * var obj2 = {
136
+ * 'b': 'boop'
137
+ * };
138
+ *
139
+ * var out = ns.assign( obj1, obj2 );
140
+ * // returns { 'a': 'beep', 'b': 'boop' }
141
+ */
142
+ assign: typeof assign;
143
+
144
+ /**
145
+ * Copies own and inherited enumerable properties from one or more source objects to a target object.
146
+ *
147
+ * ## Notes
148
+ *
149
+ * - If a property key is present in multiple sources, the property from the last source that defines the key prevails.
150
+ * - The target object is mutated.
151
+ * - Both string and symbol properties are copied.
152
+ *
153
+ * @param target - target object
154
+ * @param source - source object(s)
155
+ * @throws first argument must not be null or undefined
156
+ * @returns target object
157
+ *
158
+ * @example
159
+ * function Foo() {
160
+ * this.a = 1;
161
+ * return this;
162
+ * }
163
+ *
164
+ * Foo.prototype.b = 2;
165
+ *
166
+ * function Bar() {
167
+ * this.c = 3;
168
+ * return this;
169
+ * }
170
+ *
171
+ * Bar.prototype.d = 4;
172
+ *
173
+ * var out = ns.assignIn( {}, new Foo(), new Bar() );
174
+ * // returns { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
175
+ */
176
+ assignIn: typeof assignIn;
177
+
178
+ /**
179
+ * Splits an object's own and inherited property values into two groups according to a predicate function.
180
+ *
181
+ * ## Notes
182
+ *
183
+ * - When invoked, the predicate function is provided two arguments:
184
+ *
185
+ * - `value`: object value
186
+ * - `key`: object key
187
+ *
188
+ * - If a predicate function returns a truthy value, a value is placed in the first group; otherwise, a value is placed in the second group.
189
+ *
190
+ * - If provided an empty object with no prototype, the function returns an empty array.
191
+ *
192
+ * - The function iterates over an object's own and inherited properties.
193
+ *
194
+ * - Key iteration order is *not* guaranteed, and, thus, result order is *not* guaranteed.
195
+ *
196
+ * @param obj - input object
197
+ * @param options - function options
198
+ * @param options.thisArg - execution context
199
+ * @param options.returns - if `'values'`, values are returned; if `'keys'`, keys are returned; if `'*'`, both keys and values are returned (default: 'values')
200
+ * @param predicate - predicate function indicating which group an element in the input object belongs to
201
+ * @returns group results
202
+ *
203
+ * @example
204
+ * function predicate( v ) {
205
+ * return v[ 0 ] === 'b';
206
+ * }
207
+ *
208
+ * function Foo() {
209
+ * this.a = 'beep';
210
+ * this.b = 'boop';
211
+ * return this;
212
+ * }
213
+ *
214
+ * Foo.prototype = Object.create( null );
215
+ * Foo.prototype.c = 'foo';
216
+ * Foo.prototype.d = 'bar';
217
+ *
218
+ * var obj = new Foo();
219
+ *
220
+ * var opts = {
221
+ * 'returns': 'keys'
222
+ * };
223
+ * var out = ns.bifurcateIn( obj, opts, predicate );
224
+ * // e.g., returns [ [ 'a', 'b', 'd' ], [ 'c' ] ]
225
+ *
226
+ * @example
227
+ * function predicate( v ) {
228
+ * return v[ 0 ] === 'b';
229
+ * }
230
+ *
231
+ * function Foo() {
232
+ * this.a = 'beep';
233
+ * this.b = 'boop';
234
+ * return this;
235
+ * }
236
+ *
237
+ * Foo.prototype = Object.create( null );
238
+ * Foo.prototype.c = 'foo';
239
+ * Foo.prototype.d = 'bar';
240
+ *
241
+ * var obj = new Foo();
242
+ *
243
+ * var opts = {
244
+ * 'returns': '*'
245
+ * };
246
+ * var out = ns.bifurcateIn( obj, opts, predicate );
247
+ * // e.g., returns [ [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], [ [ 'c', 'foo' ] ] ]
248
+ */
249
+ bifurcateIn: typeof bifurcateIn;
250
+
251
+ /**
252
+ * Splits an object's own property values into two groups according to a predicate function.
253
+ *
254
+ * @param obj - input object
255
+ * @param options - function options
256
+ * @param options.thisArg - execution context
257
+ * @param options.returns - if `'values'`, values are returned; if `'keys'`, keys are returned; if `'*'`, both keys and values are returned
258
+ * @param predicate - predicate function indicating which group an element in the input object belongs to
259
+ * @returns group results
260
+ *
261
+ * @example
262
+ * function predicate( v ) {
263
+ * return v[ 0 ] === 'b';
264
+ * }
265
+ * var obj = {
266
+ * 'a': 'beep',
267
+ * 'b': 'boop',
268
+ * 'c': 'foo',
269
+ * 'd': 'bar'
270
+ * };
271
+ * var out = ns.bifurcateOwn( obj, predicate );
272
+ * // e.g., returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
273
+ *
274
+ * @example
275
+ * function predicate( v ) {
276
+ * return v[ 0 ] === 'b';
277
+ * }
278
+ * var obj = {
279
+ * 'a': 'beep',
280
+ * 'b': 'boop',
281
+ * 'c': 'foo',
282
+ * 'd': 'bar'
283
+ * };
284
+ * var opts = {
285
+ * 'returns': 'keys'
286
+ * };
287
+ * var out = ns.bifurcateOwn( obj, opts, predicate );
288
+ * // e.g., returns [ [ 'a', 'b', 'd' ], [ 'c' ] ]
289
+ *
290
+ * @example
291
+ * function predicate( v ) {
292
+ * return v[ 0 ] === 'b';
293
+ * }
294
+ * var obj = {
295
+ * 'a': 'beep',
296
+ * 'b': 'boop',
297
+ * 'c': 'foo',
298
+ * 'd': 'bar'
299
+ * };
300
+ * var opts = {
301
+ * 'returns': '*'
302
+ * };
303
+ * var out = ns.bifurcateOwn( obj, opts, predicate );
304
+ * // e.g., returns [ [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], [ [ 'c', 'foo' ] ] ]
305
+ */
306
+ bifurcateOwn: typeof bifurcateOwn;
307
+
308
+ /**
309
+ * Converts the first letter of each object key to uppercase.
310
+ *
311
+ * ## Notes
312
+ *
313
+ * - The function only transforms own properties. Hence, the function does not transform inherited properties.
314
+ * - The function shallow copies key values.
315
+ *
316
+ * @param obj - source object
317
+ * @returns new object
318
+ *
319
+ * @example
320
+ * var obj1 = {
321
+ * 'aa': 1,
322
+ * 'bb': 2
323
+ * };
324
+ *
325
+ * var obj2 = ns.capitalizeKeys( obj1 );
326
+ * // returns { 'Aa': 1, 'Bb': 2 }
327
+ */
328
+ capitalizeKeys: typeof capitalizeKeys;
329
+
330
+ /**
331
+ * Returns the common own property names of two or more objects.
332
+ *
333
+ * @param obj1 - first object
334
+ * @param obj2 - second object
335
+ * @param obj - additional objects
336
+ * @returns common keys of objects
337
+ *
338
+ * @example
339
+ * var obj = {
340
+ * 'a': 1,
341
+ * 'b': 2,
342
+ * 'c': 3
343
+ * };
344
+ *
345
+ * var obj2 = {
346
+ * 'a': 1,
347
+ * 'b': 2
348
+ * };
349
+ *
350
+ * var keys = ns.commonKeys( obj, obj2 );
351
+ * // returns [ 'a', 'b' ]
352
+ *
353
+ * @example
354
+ * var obj1 = {
355
+ * 'a': 1,
356
+ * 'b': 2,
357
+ * 'c': 3
358
+ * };
359
+ *
360
+ * var obj2 = {
361
+ * 'a': 1,
362
+ * 'b': 2
363
+ * };
364
+ *
365
+ * var obj3 = {
366
+ * 'a': 1,
367
+ * };
368
+ *
369
+ * var keys = ns.commonKeys( obj1, obj2, obj3 );
370
+ * // returns [ 'a' ]
371
+ */
372
+ commonKeys: typeof commonKeys;
373
+
374
+ /**
375
+ * Returns the common own and inherited property names of two or more objects.
376
+ *
377
+ * @param obj1 - first object
378
+ * @param obj2 - second object
379
+ * @param obj - additional objects
380
+ * @returns common keys
381
+ *
382
+ * @example
383
+ * var obj = {
384
+ * 'a': 1,
385
+ * 'b': 2,
386
+ * 'c': 3
387
+ * };
388
+ *
389
+ * var obj2 = {
390
+ * 'a': 1,
391
+ * 'b': 2
392
+ * };
393
+ *
394
+ * var keys = ns.commonKeysIn( obj, obj2 );
395
+ * // returns [ 'a', 'b' ]
396
+ *
397
+ * @example
398
+ * var obj1 = {
399
+ * 'a': 1,
400
+ * 'b': 2,
401
+ * 'c': 3
402
+ * };
403
+ *
404
+ * var obj2 = {
405
+ * 'a': 1,
406
+ * 'b': 2
407
+ * };
408
+ *
409
+ * var obj3 = {
410
+ * 'a': 1,
411
+ * };
412
+ *
413
+ * var keys = ns.commonKeysIn( obj1, obj2, obj3 );
414
+ * // returns [ 'a' ]
415
+ */
416
+ commonKeysIn: typeof commonKeysIn;
417
+
418
+ /**
419
+ * Returns an object.
420
+ *
421
+ * ## Notes
422
+ *
423
+ * - If provided `null` or `undefined`, the function returns an empty object.
424
+ * - If provided an existing object, the function returns the input value unchanged.
425
+ * - Otherwise, if provided any other value (e.g., a number, string, etc), the function will return an object of the corresponding type.
426
+ *
427
+ * @param value - input value
428
+ * @returns object
429
+ *
430
+ * @example
431
+ * var o = new ns.Object( null );
432
+ * // returns {}
433
+ *
434
+ * @example
435
+ * var o = new ns.Object( 5.0 );
436
+ * // returns <Number>
437
+ *
438
+ * @example
439
+ * var o = new ns.Object( 'beep' );
440
+ * // returns <String>
441
+ *
442
+ * @example
443
+ * var o1 = {};
444
+ *
445
+ * var o2 = new ns.Object( o1 );
446
+ * // returns {}
447
+ *
448
+ * var bool = ( o1 === o2 );
449
+ * // returns true
450
+ */
451
+ Object: typeof Object;
452
+
453
+ /**
454
+ * Returns a nested property value.
455
+ *
456
+ * @param obj - input object
457
+ * @param path - key path
458
+ * @param options - function options
459
+ * @param options.sep - key path separator (default: '.')
460
+ * @returns nested property value
461
+ *
462
+ * @example
463
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
464
+ *
465
+ * var val = ns.deepGet( obj, 'a.b.c' );
466
+ * // returns 'd'
467
+ *
468
+ * @example
469
+ * var dget = ns.deepGet.factory( 'a/b/c', {
470
+ * 'sep': '/'
471
+ * });
472
+ *
473
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
474
+ *
475
+ * var val = dget( obj );
476
+ * // returns 'd'
477
+ */
478
+ deepGet: typeof deepGet;
479
+
480
+ /**
481
+ * Sets a nested property value.
482
+ *
483
+ * @param obj - input object
484
+ * @param path - key path
485
+ * @param value - value to set
486
+ * @param options - function options
487
+ * @param options.create - boolean indicating whether to create a path if the key path does not already exist (default: false)
488
+ * @param options.sep - key path separator (default: '.')
489
+ * @returns boolean indicating if the property was successfully set
490
+ *
491
+ * @example
492
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
493
+ * var bool = ns.deepSet( obj, 'a.b.c', 'woot' );
494
+ * // returns true
495
+ *
496
+ * @example
497
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
498
+ * var bool = ns.deepSet( obj, 'a.beep.c', 'boop' );
499
+ * // returns false
500
+ *
501
+ * @example
502
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
503
+ * var bool = ns.deepSet( null, 'a.beep.c', 'boop' );
504
+ * // returns false
505
+ *
506
+ * @example
507
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
508
+ * bool = ns.deepSet( 'bap', 'a.beep.c', 'boop' );
509
+ * // returns false
510
+ *
511
+ * @example
512
+ * var arr = [
513
+ * { 'a': [ {'x': 5} ] },
514
+ * { 'a': [ {'x': 10} ] }
515
+ * ];
516
+ * var bool = ns.deepSet( arr, '1.a.0.x', 25 );
517
+ * // returns true
518
+ *
519
+ * @example
520
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
521
+ * var bool = ns.deepSet( obj, 'a/b/c', 'beep', {
522
+ * 'sep': '/'
523
+ * });
524
+ * // returns true
525
+ *
526
+ * @example
527
+ * var obj = { 'a': { 'b': { 'c': 'd' } } };
528
+ * var bool = ns.deepSet( obj, 'a.e.c', 'boop', {
529
+ * 'create': true
530
+ * });
531
+ * // returns true
532
+ */
533
+ deepSet: typeof deepSet;
534
+
535
+ /**
536
+ * Checks whether all own and inherited properties in an object pass a test implemented by a predicate function.
537
+ *
538
+ * @param obj - object to iterate over
539
+ * @param predicate - test function to apply to each property
540
+ * @param thisArg - optional execution context for the predicate function
541
+ * @throws if `obj` is not an object or if `predicate` is not a function
542
+ * @returns boolean indicating whether all properties pass the test
543
+ */
544
+ everyInBy: typeof everyInBy;
545
+
546
+ /**
547
+ * Tests whether every property of an object passes a test implemented by a predicate function.
548
+ *
549
+ * ## Notes
550
+ *
551
+ * - The predicate function is provided three arguments:
552
+ *
553
+ * - `value`: collection value
554
+ * - `key`: collection key
555
+ * - `object`: the input object
556
+ *
557
+ * - The function immediately returns upon encountering a truthy return value.
558
+ * - If provided an empty object, the function returns `true`.
559
+ *
560
+ * @param object - input object
561
+ * @param predicate - test function
562
+ * @param thisArg - execution context
563
+ * @returns boolean indicating whether all own elements pass a test
564
+ *
565
+ * @example
566
+ * function isPositive( v ) {
567
+ * return ( v > 0 );
568
+ * }
569
+ *
570
+ * var obj = { 'a': 1, 'b': 2, 'c': 3 };
571
+ *
572
+ * var bool = ns.everyOwnBy( obj, isPositive );
573
+ * // returns true
574
+ */
575
+ everyOwnBy: typeof everyOwnBy;
576
+
577
+ /**
578
+ * Invokes a function once for each own and inherited enumerable property of an object.
579
+ *
580
+ * ## Notes
581
+ *
582
+ * - When invoked, the function is provided three arguments:
583
+ *
584
+ * - `value`: object property value
585
+ * - `key`: object property
586
+ * - `obj`: the input object
587
+ *
588
+ * - To terminate iteration before visiting all properties, the provided function must explicitly return `false`.
589
+ *
590
+ * - Iteration order is **not** guaranteed.
591
+ *
592
+ *
593
+ * @param obj - input object
594
+ * @param fcn - function to invoke
595
+ * @param thisArg - execution context
596
+ * @returns obj - input object
597
+ *
598
+ * @example
599
+ * function log( v, key ) {
600
+ * console.log( '%s: %d', key, v );
601
+ * }
602
+ *
603
+ * function Foo() {
604
+ * this.a = 1;
605
+ * this.b = 2;
606
+ * return this;
607
+ * }
608
+ *
609
+ * Foo.prototype.c = 3;
610
+ * Foo.prototype.d = 4;
611
+ *
612
+ * var obj = new Foo();
613
+ *
614
+ * ns.forIn( obj, log );
615
+ */
616
+ forIn: typeof forIn;
617
+
618
+ /**
619
+ * Invokes a function once for each own enumerable property of an object.
620
+ *
621
+ * ## Notes
622
+ *
623
+ * - When invoked, the function is provided three arguments:
624
+ *
625
+ * - `value`: object property value
626
+ * - `key`: object property
627
+ * - `obj`: the input object
628
+ *
629
+ * - To terminate iteration before visiting all properties, the provided function must explicitly return `false`.
630
+ *
631
+ * - The function determines the list of own enumerable properties *before* invoking the provided function. Hence, any modifications made to the input object *after* calling this function (such as adding and removing properties) will *not* affect the list of visited properties.
632
+ *
633
+ * - Iteration order is **not** guaranteed.
634
+ *
635
+ *
636
+ * @param obj - input object
637
+ * @param fcn - function to invoke
638
+ * @param thisArg - execution context
639
+ * @returns obj - input object
640
+ *
641
+ * @example
642
+ * function log( v, key ) {
643
+ * console.log( '%s: %d', key, v );
644
+ * }
645
+ *
646
+ * var obj = {
647
+ * 'a': 1,
648
+ * 'b': 2,
649
+ * 'c': 3,
650
+ * 'd': 4
651
+ * };
652
+ *
653
+ * ns.forOwn( obj, log );
654
+ */
655
+ forOwn: typeof forOwn;
656
+
657
+ /**
658
+ * Inverts an object, such that keys become values and values become keys.
659
+ *
660
+ * @param obj - input object
661
+ * @param options - function options
662
+ * @param options.duplicates - boolean indicating whether to store duplicate keys (default: true)
663
+ * @returns inverted object
664
+ *
665
+ * @example
666
+ * var out = ns.inverse({
667
+ * 'a': 'beep',
668
+ * 'b': 'boop'
669
+ * });
670
+ * // returns { 'beep': 'a', 'boop': 'b' }
671
+ *
672
+ * @example
673
+ * var out = ns.inverse({
674
+ * 'a': 'beep',
675
+ * 'b': 'beep'
676
+ * });
677
+ * // returns { 'beep': [ 'a', 'b' ] }
678
+ *
679
+ * @example
680
+ * var obj = {};
681
+ * obj.a = 'beep';
682
+ * obj.b = 'boop';
683
+ * obj.c = 'beep'; // inserted after `a`
684
+ *
685
+ * var out = ns.inverse( obj, {
686
+ * 'duplicates': false
687
+ * });
688
+ * // returns { 'beep': 'c', 'boop': 'b' }
689
+ */
690
+ inverse: typeof inverse;
691
+
692
+ /**
693
+ * Inverts an object, such that keys become values and values become keys, according to a transform function.
694
+ *
695
+ * ## Notes
696
+ *
697
+ * - The transform function is provided three arguments:
698
+ *
699
+ * - `key`: object key.
700
+ * - `value`: object value corresponding to `key`.
701
+ * - `obj`: the input object.
702
+ *
703
+ * - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
704
+ *
705
+ * - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
706
+ *
707
+ * @param obj - input object
708
+ * @param opts - function options
709
+ * @param opts.duplicates - boolean indicating whether to store duplicate keys (default: true)
710
+ * @param transform - transform function
711
+ * @returns inverted object
712
+ *
713
+ * @example
714
+ * function transform( key, value ) {
715
+ * return value;
716
+ * }
717
+ *
718
+ * var obj = {};
719
+ * obj.a = 'beep';
720
+ * obj.b = 'boop';
721
+ * obj.c = 'beep'; // inserted after `a`
722
+ *
723
+ * var opts = {
724
+ * 'duplicates': false
725
+ * };
726
+ * var out = ns.inverseBy( obj, opts, transform );
727
+ * // returns { 'beep': 'c', 'boop': 'b' }
728
+ */
729
+ inverseBy: typeof inverseBy;
730
+
731
+ /**
732
+ * Converts each object key to lowercase.
733
+ *
734
+ * ## Notes
735
+ *
736
+ * - The function only transforms own properties. Hence, the function does not transform inherited properties.
737
+ * - The function shallow copies key values.
738
+ *
739
+ * @param obj - source object
740
+ * @returns new object
741
+ *
742
+ * @example
743
+ * var obj1 = {
744
+ * 'A': 1,
745
+ * 'B': 2
746
+ * };
747
+ *
748
+ * var obj2 = ns.lowercaseKeys( obj1 );
749
+ * // returns { 'a': 1, 'b': 2 }
750
+ */
751
+ lowercaseKeys: typeof lowercaseKeys;
752
+
753
+ /**
754
+ * Moves a property from one object to another object.
755
+ *
756
+ * ## Notes
757
+ *
758
+ * - The property is deleted from the source object and the property's descriptor is preserved during transfer.
759
+ * - If a source property is not configurable, the function throws an error, as the property cannot be deleted from the source object.
760
+ *
761
+ * @param source - source object
762
+ * @param prop - property to move
763
+ * @param target - target object
764
+ * @returns boolean indicating whether operation was successful
765
+ *
766
+ * @example
767
+ * var obj1 = { 'a': 'b' };
768
+ * var obj2 = {};
769
+ *
770
+ * var bool = ns.moveProperty( obj1, 'a', obj2 );
771
+ * // returns true
772
+ *
773
+ * @example
774
+ * var obj1 = { 'a': 'b' };
775
+ * var obj2 = {};
776
+ *
777
+ * var bool = ns.moveProperty( obj1, 'c', obj2 );
778
+ * // returns false
779
+ */
780
+ moveProperty: typeof moveProperty;
781
+
782
+ /**
783
+ * Tests whether every property in a object fail a test implemented by a predicate function.
784
+ *
785
+ * ## Notes
786
+ *
787
+ * - The predicate function is provided three arguments:
788
+ *
789
+ * - `value`: property value
790
+ * - `key`: property key
791
+ * - `object`: the input object
792
+ *
793
+ * - The function immediately returns upon encountering a truthy return value.
794
+ * - If provided an empty object, the function returns `true`.
795
+ *
796
+ * @param object - input object
797
+ * @param predicate - test function
798
+ * @param thisArg - execution context
799
+ * @returns boolean indicating whether all property fails a test
800
+ *
801
+ * @example
802
+ * function isPositive( v ) {
803
+ * return ( v > 0 );
804
+ * }
805
+ *
806
+ * var obj = { 'a': -1, 'b': -2, 'c': -3, 'd': -4 };
807
+ *
808
+ * var bool = ns.noneInBy( obj, isPositive );
809
+ * // returns true
810
+ */
811
+ noneInBy: typeof noneInBy;
812
+
813
+ /**
814
+ * Tests whether every property of an object fails a test implemented by a predicate function.
815
+ *
816
+ * ## Notes
817
+ *
818
+ * - The predicate function is provided three arguments:
819
+ *
820
+ * - `value`: property value
821
+ * - `key`: property key
822
+ * - `object`: the input object
823
+ *
824
+ * - The function immediately returns upon encountering a truthy return value.
825
+ * - If provided an empty object, the function returns `true`.
826
+ *
827
+ * @param object - input object
828
+ * @param predicate - test function
829
+ * @param thisArg - execution context
830
+ * @returns boolean indicating whether every property fails a test
831
+ *
832
+ * @example
833
+ * function isUnderage( v ) {
834
+ * return ( v < 18 );
835
+ * }
836
+ *
837
+ * var obj = { 'a': 20, 'b': 22, 'c': 25 };
838
+ *
839
+ * var bool = ns.noneOwnBy( obj, isUnderage );
840
+ * // returns true
841
+ */
842
+ noneOwnBy: typeof noneOwnBy;
843
+
844
+ /**
845
+ * Tests whether an object contains at least `n` properties (own and inherited) which pass a test implemented by a predicate function.
846
+ *
847
+ * ## Notes
848
+ *
849
+ * - The predicate function is provided three arguments:
850
+ *
851
+ * - `value`: object value
852
+ * - `key`: object key
853
+ * - `obj`: the input object
854
+ *
855
+ * - The function immediately returns upon finding `n` successful properties.
856
+ *
857
+ * - If provided an empty object, the function returns `false`.
858
+ *
859
+ * @param obj - input object
860
+ * @param n - number of properties
861
+ * @param predicate - test function
862
+ * @param thisArg - execution context
863
+ * @throws second argument must be a positive integer
864
+ * @returns boolean indicating whether an object contains at least `n` properties which pass a test
865
+ *
866
+ * @example
867
+ * function isNegative( v ) {
868
+ * return ( v < 0 );
869
+ * }
870
+ *
871
+ * var obj = { 'a': 1, 'b': 2, 'c': -3, 'd': 4, 'e': -1 };
872
+ *
873
+ * var bool = ns.someInBy( obj, 2, isNegative );
874
+ * // returns true
875
+ */
876
+ someInBy: typeof someInBy;
877
+
878
+ /**
879
+ * Tests whether an object contains at least `n` own properties which pass a test implemented by a predicate function.
880
+ *
881
+ * ## Notes
882
+ *
883
+ * - The predicate function is provided three arguments:
884
+ *
885
+ * - `value`: object value
886
+ * - `key`: object key
887
+ * - `obj`: the input object
888
+ *
889
+ * - The function immediately returns upon finding `n` successful properties.
890
+ *
891
+ * - If provided an empty object, the function returns `false`.
892
+ *
893
+ * @param obj - input object
894
+ * @param n - number of properties
895
+ * @param predicate - test function
896
+ * @param thisArg - execution context
897
+ * @returns boolean indicating whether an object contains at least `n` own properties which pass a test
898
+ *
899
+ * @example
900
+ * function isNegative( v ) {
901
+ * return ( v < 0 );
902
+ * }
903
+ *
904
+ * var obj = { a: 1, b: 2, c: -3, d: 4, e: -1 };
905
+ *
906
+ * var bool = ns.someOwnBy( obj, 2, isNegative );
907
+ * // returns true
908
+ */
909
+ someOwnBy: typeof someOwnBy;
910
+
911
+ /**
912
+ * Converts the first letter of each object key to lowercase.
913
+ *
914
+ * ## Notes
915
+ *
916
+ * - The function only transforms own properties. Hence, the function does not transform inherited properties.
917
+ * - The function shallow copies key values.
918
+ *
919
+ * @param obj - source object
920
+ * @returns new object
921
+ *
922
+ * @example
923
+ * var obj1 = {
924
+ * 'AA': 1,
925
+ * 'BB': 2
926
+ * };
927
+ *
928
+ * var obj2 = ns.uncapitalizeKeys( obj1 );
929
+ * // returns { 'aA': 1, 'bB': 2 }
930
+ */
931
+ uncapitalizeKeys: typeof uncapitalizeKeys;
932
+
933
+ /**
934
+ * Converts each object key to uppercase.
935
+ *
936
+ * ## Notes
937
+ *
938
+ * - The function only transforms own properties. Hence, the function does not transform inherited properties.
939
+ * - The function shallow copies key values.
940
+ *
941
+ * @param obj - source object
942
+ * @returns new object
943
+ *
944
+ * @example
945
+ * var obj1 = {
946
+ * 'a': 1,
947
+ * 'b': 2
948
+ * };
949
+ *
950
+ * var obj2 = ns.uppercaseKeys( obj1 );
951
+ * // returns { 'A': 1, 'B': 2 }
952
+ */
953
+ uppercaseKeys: typeof uppercaseKeys;
954
+ }
955
+
956
+ /**
957
+ * Object.
958
+ */
959
+ declare var ns: Namespace;
960
+
961
+
962
+ // EXPORTS //
963
+
964
+ export = ns;