@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.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +262 -2
- package/SECURITY.md +5 -0
- package/any-in-by/README.md +217 -0
- package/any-in-by/docs/repl.txt +41 -0
- package/any-in-by/docs/types/index.d.ts +102 -0
- package/any-in-by/docs/types/test.ts +53 -0
- package/any-in-by/lib/index.js +50 -0
- package/any-in-by/lib/main.js +75 -0
- package/any-in-by/package.json +66 -0
- package/any-own-by/README.md +221 -0
- package/any-own-by/docs/repl.txt +43 -0
- package/any-own-by/docs/types/index.d.ts +101 -0
- package/any-own-by/docs/types/test.ts +63 -0
- package/any-own-by/lib/index.js +46 -0
- package/any-own-by/lib/main.js +77 -0
- package/any-own-by/package.json +70 -0
- package/assign/README.md +139 -0
- package/assign/docs/repl.txt +34 -0
- package/assign/docs/types/index.d.ts +113 -0
- package/assign/docs/types/test.ts +47 -0
- package/assign/lib/builtin.js +55 -0
- package/assign/lib/has_object_assign.js +33 -0
- package/assign/lib/index.js +52 -0
- package/assign/lib/polyfill.js +86 -0
- package/assign/package.json +64 -0
- package/assign-in/README.md +145 -0
- package/assign-in/docs/repl.txt +34 -0
- package/assign-in/docs/types/index.d.ts +175 -0
- package/assign-in/docs/types/test.ts +44 -0
- package/assign-in/lib/index.js +54 -0
- package/assign-in/lib/main.js +92 -0
- package/assign-in/package.json +60 -0
- package/bifurcate-in/README.md +298 -0
- package/bifurcate-in/docs/repl.txt +68 -0
- package/bifurcate-in/docs/types/index.d.ts +189 -0
- package/bifurcate-in/docs/types/test.ts +97 -0
- package/bifurcate-in/lib/index.js +106 -0
- package/bifurcate-in/lib/main.js +148 -0
- package/bifurcate-in/lib/return_keys.js +81 -0
- package/bifurcate-in/lib/return_pairs.js +87 -0
- package/bifurcate-in/lib/return_values.js +87 -0
- package/bifurcate-in/lib/validate.js +76 -0
- package/bifurcate-in/package.json +72 -0
- package/bifurcate-own/README.md +255 -0
- package/bifurcate-own/docs/repl.txt +63 -0
- package/bifurcate-own/docs/types/index.d.ts +183 -0
- package/bifurcate-own/docs/types/test.ts +97 -0
- package/bifurcate-own/lib/index.js +87 -0
- package/bifurcate-own/lib/main.js +127 -0
- package/bifurcate-own/lib/return_keys.js +81 -0
- package/bifurcate-own/lib/return_pairs.js +87 -0
- package/bifurcate-own/lib/return_values.js +87 -0
- package/bifurcate-own/lib/validate.js +76 -0
- package/bifurcate-own/package.json +71 -0
- package/capitalize-keys/README.md +139 -0
- package/capitalize-keys/docs/repl.txt +28 -0
- package/capitalize-keys/docs/types/index.d.ts +46 -0
- package/capitalize-keys/docs/types/test.ts +33 -0
- package/capitalize-keys/lib/index.js +45 -0
- package/capitalize-keys/lib/main.js +69 -0
- package/capitalize-keys/package.json +76 -0
- package/common-keys/README.md +125 -0
- package/common-keys/docs/repl.txt +29 -0
- package/common-keys/docs/types/index.d.ts +70 -0
- package/common-keys/docs/types/test.ts +33 -0
- package/common-keys/lib/index.js +51 -0
- package/common-keys/lib/main.js +106 -0
- package/common-keys/package.json +70 -0
- package/common-keys-in/README.md +125 -0
- package/common-keys-in/docs/repl.txt +29 -0
- package/common-keys-in/docs/types/index.d.ts +70 -0
- package/common-keys-in/docs/types/test.ts +33 -0
- package/common-keys-in/lib/index.js +51 -0
- package/common-keys-in/lib/main.js +106 -0
- package/common-keys-in/package.json +72 -0
- package/ctor/README.md +536 -0
- package/ctor/docs/repl.txt +592 -0
- package/ctor/docs/types/index.d.ts +56 -0
- package/ctor/docs/types/test.ts +33 -0
- package/ctor/lib/index.js +54 -0
- package/ctor/lib/main.js +58 -0
- package/ctor/package.json +58 -0
- package/deep-get/README.md +181 -0
- package/deep-get/docs/repl.txt +63 -0
- package/deep-get/docs/types/index.d.ts +125 -0
- package/deep-get/docs/types/test.ts +109 -0
- package/deep-get/lib/defaults.js +38 -0
- package/deep-get/lib/dget.js +57 -0
- package/deep-get/lib/factory.js +94 -0
- package/deep-get/lib/index.js +58 -0
- package/deep-get/lib/main.js +101 -0
- package/deep-get/lib/validate.js +66 -0
- package/deep-get/package.json +68 -0
- package/deep-set/README.md +273 -0
- package/deep-set/docs/repl.txt +87 -0
- package/deep-set/docs/types/index.d.ts +180 -0
- package/deep-set/docs/types/test.ts +134 -0
- package/deep-set/lib/defaults.js +39 -0
- package/deep-set/lib/dset.js +80 -0
- package/deep-set/lib/factory.js +99 -0
- package/deep-set/lib/index.js +58 -0
- package/deep-set/lib/main.js +120 -0
- package/deep-set/lib/validate.js +74 -0
- package/deep-set/package.json +69 -0
- package/docs/types/index.d.ts +964 -0
- package/every-in-by/README.md +156 -0
- package/every-in-by/docs/repl.txt +43 -0
- package/every-in-by/docs/types/index.d.ts +83 -0
- package/every-in-by/docs/types/test.ts +60 -0
- package/every-in-by/lib/index.js +51 -0
- package/every-in-by/lib/main.js +70 -0
- package/every-in-by/package.json +67 -0
- package/every-own-by/README.md +223 -0
- package/every-own-by/docs/repl.txt +43 -0
- package/every-own-by/docs/types/index.d.ts +102 -0
- package/every-own-by/docs/types/test.ts +62 -0
- package/every-own-by/lib/index.js +46 -0
- package/every-own-by/lib/main.js +77 -0
- package/every-own-by/package.json +68 -0
- package/for-in/README.md +218 -0
- package/for-in/docs/repl.txt +44 -0
- package/for-in/docs/types/index.d.ts +65 -0
- package/for-in/docs/types/test.ts +50 -0
- package/for-in/lib/index.js +54 -0
- package/for-in/lib/main.js +82 -0
- package/for-in/package.json +74 -0
- package/for-own/README.md +209 -0
- package/for-own/docs/repl.txt +49 -0
- package/for-own/docs/types/index.d.ts +63 -0
- package/for-own/docs/types/test.ts +50 -0
- package/for-own/lib/index.js +50 -0
- package/for-own/lib/main.js +85 -0
- package/for-own/package.json +71 -0
- package/inverse/README.md +163 -0
- package/inverse/docs/repl.txt +53 -0
- package/inverse/docs/types/index.d.ts +66 -0
- package/inverse/docs/types/test.ts +60 -0
- package/inverse/lib/index.js +59 -0
- package/inverse/lib/main.js +123 -0
- package/inverse/package.json +69 -0
- package/inverse-by/README.md +205 -0
- package/inverse-by/docs/repl.txt +67 -0
- package/inverse-by/docs/types/index.d.ts +160 -0
- package/inverse-by/docs/types/test.ts +81 -0
- package/inverse-by/lib/index.js +78 -0
- package/inverse-by/lib/main.js +148 -0
- package/inverse-by/package.json +75 -0
- package/lib/index.js +276 -0
- package/lowercase-keys/README.md +139 -0
- package/lowercase-keys/docs/repl.txt +28 -0
- package/lowercase-keys/docs/types/index.d.ts +46 -0
- package/lowercase-keys/docs/types/test.ts +33 -0
- package/lowercase-keys/lib/index.js +45 -0
- package/lowercase-keys/lib/main.js +63 -0
- package/lowercase-keys/package.json +74 -0
- package/move-property/README.md +144 -0
- package/move-property/docs/repl.txt +38 -0
- package/move-property/docs/types/index.d.ts +53 -0
- package/move-property/docs/types/test.ts +46 -0
- package/move-property/lib/index.js +46 -0
- package/move-property/lib/main.js +74 -0
- package/move-property/package.json +69 -0
- package/none-in-by/README.md +241 -0
- package/none-in-by/docs/repl.txt +42 -0
- package/none-in-by/docs/types/index.d.ts +101 -0
- package/none-in-by/docs/types/test.ts +61 -0
- package/none-in-by/lib/index.js +46 -0
- package/none-in-by/lib/main.js +71 -0
- package/none-in-by/package.json +68 -0
- package/none-own-by/README.md +177 -0
- package/none-own-by/docs/repl.txt +42 -0
- package/none-own-by/docs/types/index.d.ts +102 -0
- package/none-own-by/docs/types/test.ts +61 -0
- package/none-own-by/lib/index.js +50 -0
- package/none-own-by/lib/main.js +75 -0
- package/none-own-by/package.json +68 -0
- package/package.json +66 -4
- package/some-in-by/README.md +232 -0
- package/some-in-by/docs/repl.txt +45 -0
- package/some-in-by/docs/types/index.d.ts +104 -0
- package/some-in-by/docs/types/test.ts +66 -0
- package/some-in-by/lib/index.js +46 -0
- package/some-in-by/lib/main.js +87 -0
- package/some-in-by/package.json +75 -0
- package/some-own-by/README.md +251 -0
- package/some-own-by/docs/repl.txt +45 -0
- package/some-own-by/docs/types/index.d.ts +103 -0
- package/some-own-by/docs/types/test.ts +66 -0
- package/some-own-by/lib/index.js +46 -0
- package/some-own-by/lib/main.js +85 -0
- package/some-own-by/package.json +72 -0
- package/uncapitalize-keys/README.md +139 -0
- package/uncapitalize-keys/docs/repl.txt +28 -0
- package/uncapitalize-keys/docs/types/index.d.ts +46 -0
- package/uncapitalize-keys/docs/types/test.ts +33 -0
- package/uncapitalize-keys/lib/index.js +45 -0
- package/uncapitalize-keys/lib/main.js +69 -0
- package/uncapitalize-keys/package.json +76 -0
- package/uppercase-keys/README.md +139 -0
- package/uppercase-keys/docs/repl.txt +28 -0
- package/uppercase-keys/docs/types/index.d.ts +46 -0
- package/uppercase-keys/docs/types/test.ts +33 -0
- package/uppercase-keys/lib/index.js +45 -0
- package/uppercase-keys/lib/main.js +63 -0
- package/uppercase-keys/package.json +74 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}( value )
|
|
3
|
+
Returns an object.
|
|
4
|
+
|
|
5
|
+
If provided `null` or `undefined`, the function returns an empty object.
|
|
6
|
+
|
|
7
|
+
If provided an existing object, the function returns the input value
|
|
8
|
+
unchanged.
|
|
9
|
+
|
|
10
|
+
Otherwise, if provided any other value (e.g., a number, string, etc), the
|
|
11
|
+
function will return an object of the corresponding type.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
value: any
|
|
16
|
+
Input value.
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
out: Object
|
|
21
|
+
Output object.
|
|
22
|
+
|
|
23
|
+
Examples
|
|
24
|
+
--------
|
|
25
|
+
> var o = new {{alias}}( null )
|
|
26
|
+
{}
|
|
27
|
+
> o = new {{alias}}( 5.0 )
|
|
28
|
+
<Number>
|
|
29
|
+
> o = new {{alias}}( 'beep' )
|
|
30
|
+
<String>
|
|
31
|
+
|
|
32
|
+
{{alias}}.assign( target, ...sources )
|
|
33
|
+
Assigns enumerable and own properties from source objects to a target
|
|
34
|
+
object.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
target: Object
|
|
39
|
+
Target object.
|
|
40
|
+
|
|
41
|
+
sources: ...Object
|
|
42
|
+
Source objects.
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
out: Object
|
|
47
|
+
Target object.
|
|
48
|
+
|
|
49
|
+
Examples
|
|
50
|
+
--------
|
|
51
|
+
> var o = {{alias}}.assign( {}, { 'a': 1 }, { 'b': 2 } )
|
|
52
|
+
{ 'a': 1, 'b': 2 }
|
|
53
|
+
|
|
54
|
+
{{alias}}.create( prototype, properties )
|
|
55
|
+
Creates a new object with a specified prototype object and properties.
|
|
56
|
+
|
|
57
|
+
Parameters
|
|
58
|
+
----------
|
|
59
|
+
prototype: Object
|
|
60
|
+
Prototype object.
|
|
61
|
+
|
|
62
|
+
properties: Object
|
|
63
|
+
Properties object.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
out: Object
|
|
68
|
+
New object.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
> var o = {{alias}}.create( {}, { 'a': { 'value': 1 } } )
|
|
73
|
+
{ 'a': 1 }
|
|
74
|
+
|
|
75
|
+
{{alias}}.defineProperties( obj, properties )
|
|
76
|
+
Defines properties for an object.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
obj: Object
|
|
81
|
+
Object.
|
|
82
|
+
|
|
83
|
+
properties: Object
|
|
84
|
+
Properties object.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
out: Object
|
|
89
|
+
Object.
|
|
90
|
+
|
|
91
|
+
Examples
|
|
92
|
+
--------
|
|
93
|
+
> var o = {{alias}}.defineProperties( {}, { 'a': { 'value': 1 } } )
|
|
94
|
+
{ 'a': 1 }
|
|
95
|
+
|
|
96
|
+
{{alias}}.defineProperty( obj, key, descriptor )
|
|
97
|
+
Defines a property for an object.
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
obj: Object
|
|
102
|
+
Object.
|
|
103
|
+
|
|
104
|
+
key: string
|
|
105
|
+
Property key.
|
|
106
|
+
|
|
107
|
+
descriptor: Object
|
|
108
|
+
Property descriptor.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
out: Object
|
|
113
|
+
Object.
|
|
114
|
+
|
|
115
|
+
Examples
|
|
116
|
+
--------
|
|
117
|
+
> var o = {{alias}}.defineProperty( {}, 'a', {
|
|
118
|
+
'value': 1,
|
|
119
|
+
'enumerable': true,
|
|
120
|
+
'configurable': true,
|
|
121
|
+
'writable': false
|
|
122
|
+
})
|
|
123
|
+
{ 'a': 1 }
|
|
124
|
+
|
|
125
|
+
{{alias}}.entries( obj )
|
|
126
|
+
Returns an array of an object's own enumerable string-keyed property
|
|
127
|
+
[key, value] pairs.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
obj: Object
|
|
132
|
+
Object.
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
out: Array
|
|
137
|
+
Array of [key, value] pairs.
|
|
138
|
+
|
|
139
|
+
Examples
|
|
140
|
+
--------
|
|
141
|
+
> var o = {{alias}}.entries( { 'a': 1, 'b': 2 } )
|
|
142
|
+
[ [ 'a', 1 ], [ 'b', 2 ] ]
|
|
143
|
+
|
|
144
|
+
{{alias}}.freeze( obj )
|
|
145
|
+
Freezes an object.
|
|
146
|
+
|
|
147
|
+
Parameters
|
|
148
|
+
----------
|
|
149
|
+
obj: Object
|
|
150
|
+
Object.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
out: Object
|
|
155
|
+
Object.
|
|
156
|
+
|
|
157
|
+
Examples
|
|
158
|
+
--------
|
|
159
|
+
> var o = {{alias}}.freeze( { 'a': 1 } )
|
|
160
|
+
{ 'a': 1 }
|
|
161
|
+
|
|
162
|
+
{{alias}}.getOwnPropertyDescriptor( obj, key )
|
|
163
|
+
Returns an object's own property descriptor.
|
|
164
|
+
|
|
165
|
+
Parameters
|
|
166
|
+
----------
|
|
167
|
+
obj: Object
|
|
168
|
+
Object.
|
|
169
|
+
|
|
170
|
+
key: string
|
|
171
|
+
Property key.
|
|
172
|
+
|
|
173
|
+
Returns
|
|
174
|
+
-------
|
|
175
|
+
out: Object
|
|
176
|
+
Property descriptor.
|
|
177
|
+
|
|
178
|
+
Examples
|
|
179
|
+
--------
|
|
180
|
+
> var o = {{alias}}.getOwnPropertyDescriptor( { 'a': 1 }, 'a' )
|
|
181
|
+
{ 'value': 1, 'enumerable': true, 'configurable': true, 'writable': true }
|
|
182
|
+
|
|
183
|
+
{{alias}}.getOwnPropertyDescriptors( obj )
|
|
184
|
+
Returns an object's own property descriptors.
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
obj: Object
|
|
189
|
+
Object.
|
|
190
|
+
|
|
191
|
+
Returns
|
|
192
|
+
-------
|
|
193
|
+
out: Object
|
|
194
|
+
Property descriptors.
|
|
195
|
+
|
|
196
|
+
Examples
|
|
197
|
+
--------
|
|
198
|
+
> var o = {{alias}}.getOwnPropertyDescriptors( { 'a': 1, 'b': 2 } )
|
|
199
|
+
{
|
|
200
|
+
'a': {
|
|
201
|
+
'value': 1,
|
|
202
|
+
'enumerable': true,
|
|
203
|
+
'configurable': true,
|
|
204
|
+
'writable': true
|
|
205
|
+
},
|
|
206
|
+
'b': {
|
|
207
|
+
'value': 2,
|
|
208
|
+
'enumerable': true,
|
|
209
|
+
'configurable': true,
|
|
210
|
+
'writable': true
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
{{alias}}.getOwnPropertyNames( obj )
|
|
215
|
+
Returns an array of an object's own enumerable and non-enumerable
|
|
216
|
+
property names.
|
|
217
|
+
|
|
218
|
+
Parameters
|
|
219
|
+
----------
|
|
220
|
+
obj: Object
|
|
221
|
+
Object.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
out: Array
|
|
226
|
+
Array of property names.
|
|
227
|
+
|
|
228
|
+
Examples
|
|
229
|
+
--------
|
|
230
|
+
> var o = {{alias}}.getOwnPropertyNames( { 'a': 1, 'b': 2 } )
|
|
231
|
+
[ 'a', 'b' ]
|
|
232
|
+
|
|
233
|
+
{{alias}}.getOwnPropertySymbols( obj )
|
|
234
|
+
Returns an array of an object's own enumerable and non-enumerable
|
|
235
|
+
symbol property names.
|
|
236
|
+
|
|
237
|
+
Parameters
|
|
238
|
+
----------
|
|
239
|
+
obj: Object
|
|
240
|
+
Object.
|
|
241
|
+
|
|
242
|
+
Returns
|
|
243
|
+
-------
|
|
244
|
+
out: Array
|
|
245
|
+
Array of symbol property names.
|
|
246
|
+
|
|
247
|
+
Examples
|
|
248
|
+
--------
|
|
249
|
+
> var o = {{alias}}.getOwnPropertySymbols( { 'a': 1, 'b': 2 } )
|
|
250
|
+
[]
|
|
251
|
+
|
|
252
|
+
{{alias}}.getPrototypeOf( obj )
|
|
253
|
+
Returns an object's prototype.
|
|
254
|
+
|
|
255
|
+
Parameters
|
|
256
|
+
----------
|
|
257
|
+
obj: Object
|
|
258
|
+
Object.
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
out: Object
|
|
263
|
+
Prototype.
|
|
264
|
+
|
|
265
|
+
Examples
|
|
266
|
+
--------
|
|
267
|
+
> var o = {{alias}}.getPrototypeOf( { 'a': 1, 'b': 2 } )
|
|
268
|
+
<Object>
|
|
269
|
+
|
|
270
|
+
{{alias}}.hasOwn( obj, p )
|
|
271
|
+
Returns a boolean indicating whether an object has a property with the
|
|
272
|
+
specified name.
|
|
273
|
+
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
obj: Object
|
|
277
|
+
Object.
|
|
278
|
+
|
|
279
|
+
p: string
|
|
280
|
+
Property name.
|
|
281
|
+
|
|
282
|
+
Returns
|
|
283
|
+
-------
|
|
284
|
+
out: boolean
|
|
285
|
+
Boolean indicating whether an object has a property with the specified
|
|
286
|
+
name.
|
|
287
|
+
|
|
288
|
+
Examples
|
|
289
|
+
--------
|
|
290
|
+
> var o = {{alias}}.hasOwn( { 'a': 1, 'b': 2 }, 'a' )
|
|
291
|
+
true
|
|
292
|
+
|
|
293
|
+
{{alias}}.is( value1, value2 )
|
|
294
|
+
Returns a boolean indicating whether two values are the same value.
|
|
295
|
+
|
|
296
|
+
Parameters
|
|
297
|
+
----------
|
|
298
|
+
value1: any
|
|
299
|
+
First value.
|
|
300
|
+
|
|
301
|
+
value2: any
|
|
302
|
+
Second value.
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
-------
|
|
306
|
+
out: boolean
|
|
307
|
+
Boolean indicating whether two values are the same value.
|
|
308
|
+
|
|
309
|
+
Examples
|
|
310
|
+
--------
|
|
311
|
+
> var o = {{alias}}.is( 1, 1 )
|
|
312
|
+
true
|
|
313
|
+
> var o = {{alias}}.is( 1, '1' )
|
|
314
|
+
false
|
|
315
|
+
|
|
316
|
+
{{alias}}.isExtensible( obj )
|
|
317
|
+
Returns a boolean indicating whether an object is extensible.
|
|
318
|
+
|
|
319
|
+
Parameters
|
|
320
|
+
----------
|
|
321
|
+
obj: Object
|
|
322
|
+
Object.
|
|
323
|
+
|
|
324
|
+
Returns
|
|
325
|
+
-------
|
|
326
|
+
out: boolean
|
|
327
|
+
Boolean indicating whether an object is extensible.
|
|
328
|
+
|
|
329
|
+
Examples
|
|
330
|
+
--------
|
|
331
|
+
> var o = {{alias}}.isExtensible( { 'a': 1 } )
|
|
332
|
+
true
|
|
333
|
+
|
|
334
|
+
{{alias}}.isFrozen( obj )
|
|
335
|
+
Returns a boolean indicating whether an object is frozen.
|
|
336
|
+
|
|
337
|
+
Parameters
|
|
338
|
+
----------
|
|
339
|
+
obj: Object
|
|
340
|
+
Object.
|
|
341
|
+
|
|
342
|
+
Returns
|
|
343
|
+
-------
|
|
344
|
+
out: boolean
|
|
345
|
+
Boolean indicating whether an object is frozen.
|
|
346
|
+
|
|
347
|
+
Examples
|
|
348
|
+
--------
|
|
349
|
+
> var o = {{alias}}.isFrozen( { 'a': 1 } )
|
|
350
|
+
false
|
|
351
|
+
> var o = {{alias}}.isFrozen( {{alias}}.freeze( { 'a': 1 } ) )
|
|
352
|
+
true
|
|
353
|
+
|
|
354
|
+
{{alias}}.isSealed( obj )
|
|
355
|
+
Returns a boolean indicating whether an object is sealed.
|
|
356
|
+
|
|
357
|
+
Parameters
|
|
358
|
+
----------
|
|
359
|
+
obj: Object
|
|
360
|
+
Object.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
out: boolean
|
|
365
|
+
Boolean indicating whether an object is sealed.
|
|
366
|
+
|
|
367
|
+
Examples
|
|
368
|
+
--------
|
|
369
|
+
> var o = {{alias}}.isSealed( { 'a': 1 } )
|
|
370
|
+
false
|
|
371
|
+
> var o = {{alias}}.isSealed( {{alias}}.seal( { 'a': 1 } ) )
|
|
372
|
+
true
|
|
373
|
+
|
|
374
|
+
{{alias}}.keys( obj )
|
|
375
|
+
Returns an array of an object's own enumerable string-keyed property
|
|
376
|
+
names.
|
|
377
|
+
|
|
378
|
+
Parameters
|
|
379
|
+
----------
|
|
380
|
+
obj: Object
|
|
381
|
+
Object.
|
|
382
|
+
|
|
383
|
+
Returns
|
|
384
|
+
-------
|
|
385
|
+
out: Array
|
|
386
|
+
Array of property names.
|
|
387
|
+
|
|
388
|
+
Examples
|
|
389
|
+
--------
|
|
390
|
+
> var o = {{alias}}.keys( { 'a': 1, 'b': 2 } )
|
|
391
|
+
[ 'a', 'b' ]
|
|
392
|
+
|
|
393
|
+
{{alias}}.preventExtensions( obj )
|
|
394
|
+
Prevents the addition of new properties to an object.
|
|
395
|
+
|
|
396
|
+
Parameters
|
|
397
|
+
----------
|
|
398
|
+
obj: Object
|
|
399
|
+
Object.
|
|
400
|
+
|
|
401
|
+
Returns
|
|
402
|
+
-------
|
|
403
|
+
out: Object
|
|
404
|
+
Object.
|
|
405
|
+
|
|
406
|
+
Examples
|
|
407
|
+
--------
|
|
408
|
+
> var o = {{alias}}.preventExtensions( { 'a': 1 } )
|
|
409
|
+
{ 'a': 1 }
|
|
410
|
+
> o.b = 2;
|
|
411
|
+
> o
|
|
412
|
+
{ 'a': 1 }
|
|
413
|
+
|
|
414
|
+
{{alias}}.seal( obj )
|
|
415
|
+
Prevents the addition of new properties to an object and marks all
|
|
416
|
+
existing properties as non-configurable.
|
|
417
|
+
|
|
418
|
+
Parameters
|
|
419
|
+
----------
|
|
420
|
+
obj: Object
|
|
421
|
+
Object.
|
|
422
|
+
|
|
423
|
+
Returns
|
|
424
|
+
-------
|
|
425
|
+
out: Object
|
|
426
|
+
Object.
|
|
427
|
+
|
|
428
|
+
Examples
|
|
429
|
+
--------
|
|
430
|
+
> var o = {{alias}}.seal( { 'a': 1 } )
|
|
431
|
+
{ 'a': 1 }
|
|
432
|
+
> o.b = 2;
|
|
433
|
+
> o
|
|
434
|
+
{ 'a': 1 }
|
|
435
|
+
> delete o.a;
|
|
436
|
+
> o
|
|
437
|
+
{ 'a': 1 }
|
|
438
|
+
|
|
439
|
+
{{alias}}.setPrototypeOf( obj, proto )
|
|
440
|
+
Sets an object's prototype.
|
|
441
|
+
|
|
442
|
+
Parameters
|
|
443
|
+
----------
|
|
444
|
+
obj: Object
|
|
445
|
+
Object.
|
|
446
|
+
|
|
447
|
+
proto: Object
|
|
448
|
+
Prototype.
|
|
449
|
+
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
out: Object
|
|
453
|
+
Object.
|
|
454
|
+
|
|
455
|
+
Examples
|
|
456
|
+
--------
|
|
457
|
+
> var o = {{alias}}.setPrototypeOf( { 'a': 1 }, { 'b': 2 } )
|
|
458
|
+
{ 'a': 1 }
|
|
459
|
+
> o.b
|
|
460
|
+
2
|
|
461
|
+
|
|
462
|
+
{{alias}}.values( obj )
|
|
463
|
+
Returns an array of an object's own enumerable property values.
|
|
464
|
+
|
|
465
|
+
Parameters
|
|
466
|
+
----------
|
|
467
|
+
obj: Object
|
|
468
|
+
Object.
|
|
469
|
+
|
|
470
|
+
Returns
|
|
471
|
+
-------
|
|
472
|
+
out: Array
|
|
473
|
+
Array of property values.
|
|
474
|
+
|
|
475
|
+
Examples
|
|
476
|
+
--------
|
|
477
|
+
> var o = {{alias}}.values( { 'a': 1, 'b': 2 } )
|
|
478
|
+
[ 1, 2 ]
|
|
479
|
+
|
|
480
|
+
{{alias}}.prototype.toLocaleString()
|
|
481
|
+
Returns a string representing the object.
|
|
482
|
+
|
|
483
|
+
Returns
|
|
484
|
+
-------
|
|
485
|
+
out: string
|
|
486
|
+
String representing the object.
|
|
487
|
+
|
|
488
|
+
Examples
|
|
489
|
+
--------
|
|
490
|
+
> var o = {{alias}}.prototype.toLocaleString.call( { 'a': 1, 'b': 2 } )
|
|
491
|
+
<string>
|
|
492
|
+
|
|
493
|
+
{{alias}}.prototype.toString()
|
|
494
|
+
Returns a string representing the object.
|
|
495
|
+
|
|
496
|
+
Returns
|
|
497
|
+
-------
|
|
498
|
+
out: string
|
|
499
|
+
String representing the object.
|
|
500
|
+
|
|
501
|
+
Examples
|
|
502
|
+
--------
|
|
503
|
+
> var o = {{alias}}.prototype.toString.call( { 'a': 1, 'b': 2 } )
|
|
504
|
+
<string>
|
|
505
|
+
|
|
506
|
+
{{alias}}.prototype.valueOf()
|
|
507
|
+
Returns the primitive value of the object.
|
|
508
|
+
|
|
509
|
+
Returns
|
|
510
|
+
-------
|
|
511
|
+
out: any
|
|
512
|
+
Primitive value of the object.
|
|
513
|
+
|
|
514
|
+
Examples
|
|
515
|
+
--------
|
|
516
|
+
> var o = {{alias}}.prototype.valueOf.call( { 'a': 1, 'b': 2 } )
|
|
517
|
+
{}
|
|
518
|
+
|
|
519
|
+
{{alias}}.prototype.hasOwnProperty( p )
|
|
520
|
+
Returns a boolean indicating whether an object has a property with the
|
|
521
|
+
specified name.
|
|
522
|
+
|
|
523
|
+
Parameters
|
|
524
|
+
----------
|
|
525
|
+
p: string
|
|
526
|
+
Property name.
|
|
527
|
+
|
|
528
|
+
Returns
|
|
529
|
+
-------
|
|
530
|
+
out: boolean
|
|
531
|
+
Boolean indicating whether an object has a property with the specified
|
|
532
|
+
name.
|
|
533
|
+
|
|
534
|
+
Examples
|
|
535
|
+
--------
|
|
536
|
+
> var o = {{alias}}.prototype.hasOwnProperty.call( { 'a': 1, 'b': 2 }, 'a' )
|
|
537
|
+
true
|
|
538
|
+
|
|
539
|
+
{{alias}}.prototype.isPrototypeOf( obj )
|
|
540
|
+
Returns a boolean indicating whether an object exists in another object's
|
|
541
|
+
prototype chain.
|
|
542
|
+
|
|
543
|
+
Parameters
|
|
544
|
+
----------
|
|
545
|
+
obj: Object
|
|
546
|
+
Object.
|
|
547
|
+
|
|
548
|
+
Returns
|
|
549
|
+
-------
|
|
550
|
+
out: boolean
|
|
551
|
+
Boolean indicating whether an object exists in another object's
|
|
552
|
+
prototype chain.
|
|
553
|
+
|
|
554
|
+
Examples
|
|
555
|
+
--------
|
|
556
|
+
> var p = { 'a': 1 };
|
|
557
|
+
> var o = { '__proto__': p };
|
|
558
|
+
> var b = o.isPrototypeOf( p );
|
|
559
|
+
true
|
|
560
|
+
|
|
561
|
+
{{alias}}.prototype.propertyIsEnumerable( p )
|
|
562
|
+
Returns a boolean indicating whether an object's property is enumerable.
|
|
563
|
+
|
|
564
|
+
Parameters
|
|
565
|
+
----------
|
|
566
|
+
p: string
|
|
567
|
+
Property name.
|
|
568
|
+
|
|
569
|
+
Returns
|
|
570
|
+
-------
|
|
571
|
+
out: boolean
|
|
572
|
+
Boolean indicating whether an object's property is enumerable.
|
|
573
|
+
|
|
574
|
+
Examples
|
|
575
|
+
--------
|
|
576
|
+
> var o = { 'a': 1, 'b': 2 };
|
|
577
|
+
> var bool = {{alias}}.prototype.propertyIsEnumerable.call( o, 'a' )
|
|
578
|
+
true
|
|
579
|
+
|
|
580
|
+
{{alias}}.prototype.constructor
|
|
581
|
+
Property whose value is a reference to the constructor function that
|
|
582
|
+
created the instance object.
|
|
583
|
+
|
|
584
|
+
Examples
|
|
585
|
+
--------
|
|
586
|
+
> var o = new Object( null );
|
|
587
|
+
> var ctr = o.constructor;
|
|
588
|
+
<Object>
|
|
589
|
+
|
|
590
|
+
See Also
|
|
591
|
+
--------
|
|
592
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
// EXPORTS //
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns an object.
|
|
25
|
+
*
|
|
26
|
+
* ## Notes
|
|
27
|
+
*
|
|
28
|
+
* - If provided `null` or `undefined`, the function returns an empty object.
|
|
29
|
+
* - If provided an existing object, the function returns the input value unchanged.
|
|
30
|
+
* - Otherwise, if provided any other value (e.g., a number, string, etc), the function will return an object of the corresponding type.
|
|
31
|
+
*
|
|
32
|
+
* @param value - input value
|
|
33
|
+
* @returns object
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var o = new Object( null );
|
|
37
|
+
* // returns {}
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* var o = new Object( 5.0 );
|
|
41
|
+
* // returns <Number>
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* var o = new Object( 'beep' );
|
|
45
|
+
* // returns <String>
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var o1 = {};
|
|
49
|
+
*
|
|
50
|
+
* var o2 = new Object( o1 );
|
|
51
|
+
* // returns {}
|
|
52
|
+
*
|
|
53
|
+
* var bool = ( o1 === o2 );
|
|
54
|
+
* // returns true
|
|
55
|
+
*/
|
|
56
|
+
export = Object;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
20
|
+
|
|
21
|
+
import Obj = require( './index' );
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// TESTS //
|
|
25
|
+
|
|
26
|
+
// The function returns an object...
|
|
27
|
+
{
|
|
28
|
+
new Obj( null ); // $ExpectType Object
|
|
29
|
+
new Obj( undefined ); // $ExpectType Object
|
|
30
|
+
new Obj( {} ); // $ExpectType Object
|
|
31
|
+
new Obj( 5 ); // $ExpectType Object
|
|
32
|
+
new Obj( 'beep' ); // $ExpectType Object
|
|
33
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Object constructor.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/object/ctor
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Object = require( '@ohos-ports/stdlib-object/ctor' );
|
|
28
|
+
*
|
|
29
|
+
* var o = new Object( null );
|
|
30
|
+
* // returns {}
|
|
31
|
+
*
|
|
32
|
+
* o = new Object( 5.0 );
|
|
33
|
+
* // returns <Number>
|
|
34
|
+
*
|
|
35
|
+
* o = new Object( 'beep' );
|
|
36
|
+
* // returns <String>
|
|
37
|
+
*
|
|
38
|
+
* var o1 = {};
|
|
39
|
+
*
|
|
40
|
+
* var o2 = new Object( o1 );
|
|
41
|
+
* // returns {}
|
|
42
|
+
*
|
|
43
|
+
* var bool = ( o1 === o2 );
|
|
44
|
+
* // returns true
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
// MODULES //
|
|
48
|
+
|
|
49
|
+
var main = require( './main.js' );
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// EXPORTS //
|
|
53
|
+
|
|
54
|
+
module.exports = main;
|