@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
package/ctor/README.md
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
# Object
|
|
22
|
+
|
|
23
|
+
> [Object][mdn-object] constructor.
|
|
24
|
+
|
|
25
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
26
|
+
|
|
27
|
+
<section class="intro">
|
|
28
|
+
|
|
29
|
+
</section>
|
|
30
|
+
|
|
31
|
+
<!-- /.intro -->
|
|
32
|
+
|
|
33
|
+
<!-- Package usage documentation. -->
|
|
34
|
+
|
|
35
|
+
<section class="usage">
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
var Object = require( '@stdlib/object/ctor' );
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Object( value )
|
|
44
|
+
|
|
45
|
+
Returns a new [object][mdn-object].
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
var o = new Object( null );
|
|
49
|
+
// returns {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
* * *
|
|
53
|
+
|
|
54
|
+
### Properties
|
|
55
|
+
|
|
56
|
+
<a name="prop-constructor"></a>
|
|
57
|
+
|
|
58
|
+
#### Object.prototype.constructor
|
|
59
|
+
|
|
60
|
+
Property whose value is a reference to the constructor function that created the instance object.
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
var o = new Object( null );
|
|
64
|
+
var ctr = o.constructor;
|
|
65
|
+
// returns Object
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
* * *
|
|
69
|
+
|
|
70
|
+
### Methods
|
|
71
|
+
|
|
72
|
+
<a name="static-method-assign"></a>
|
|
73
|
+
|
|
74
|
+
#### Object.assign( target, ...sources )
|
|
75
|
+
|
|
76
|
+
Assigns enumerable properties of one or more source objects to a target object.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
var o = Object.assign( {}, { 'a': 1, 'b': 2 } );
|
|
80
|
+
// returns { 'a': 1, 'b': 2 }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
<a name="static-method-create"></a>
|
|
84
|
+
|
|
85
|
+
#### Object.create( prototype, properties )
|
|
86
|
+
|
|
87
|
+
Returns a new object with the given prototype and properties.
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
var o = Object.create( null, {
|
|
91
|
+
'a': {
|
|
92
|
+
'value': 1
|
|
93
|
+
},
|
|
94
|
+
'b': {
|
|
95
|
+
'value': 2
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// returns { 'a': 1, 'b': 2 }
|
|
99
|
+
|
|
100
|
+
function Person( first, last ) {
|
|
101
|
+
this.first = first;
|
|
102
|
+
this.last = last;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var p = Object.create( Person.prototype, {
|
|
106
|
+
'first': {
|
|
107
|
+
'value': 'Jane'
|
|
108
|
+
},
|
|
109
|
+
'last': {
|
|
110
|
+
'value': 'Doe'
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
// returns Person { 'first': 'Jane', 'last': 'Doe' }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<a name="static-method-define-properties"></a>
|
|
117
|
+
|
|
118
|
+
#### Object.defineProperties( target, properties )
|
|
119
|
+
|
|
120
|
+
Defines new or modifies existing properties directly on an object, returning the object.
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
var o = Object.defineProperties( {}, {
|
|
124
|
+
'a': {
|
|
125
|
+
'value': 1
|
|
126
|
+
},
|
|
127
|
+
'b': {
|
|
128
|
+
'value': 2
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// returns { 'a': 1, 'b': 2 }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<a name="static-method-define-property"></a>
|
|
135
|
+
|
|
136
|
+
#### Object.defineProperty( target, property, descriptor )
|
|
137
|
+
|
|
138
|
+
Defines a new property directly on an object, or modifies an existing property on an object, and returns the object.
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
var o = Object.defineProperty( {}, 'a', {
|
|
142
|
+
'value': 1,
|
|
143
|
+
'writable': true,
|
|
144
|
+
'enumerable': true,
|
|
145
|
+
'configurable': true
|
|
146
|
+
});
|
|
147
|
+
// returns { 'a': 1 }
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
<a name="static-method-entries"></a>
|
|
151
|
+
|
|
152
|
+
#### Object.entries( obj )
|
|
153
|
+
|
|
154
|
+
Returns an array of a given object's own enumerable string-keyed property entries, i.e. `[key, value]` pairs.
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
var o = { 'a': 1, 'b': 2 };
|
|
158
|
+
var arr = Object.entries( o );
|
|
159
|
+
// e.g., returns [ [ 'a', 1 ], [ 'b', 2 ] ]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
<a name="static-method-freeze"></a>
|
|
163
|
+
|
|
164
|
+
#### Object.freeze( o )
|
|
165
|
+
|
|
166
|
+
Freezes an object. A frozen object can no longer be changed; freezing an object prevents new properties from being added to it, existing properties from being removed, and existing properties from being changed.
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
var o = { 'a': 1 };
|
|
170
|
+
Object.freeze( o );
|
|
171
|
+
// returns { 'a': 1 }
|
|
172
|
+
|
|
173
|
+
o.b = 1;
|
|
174
|
+
var v = o.b;
|
|
175
|
+
// returns undefined
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
<a name="static-method-get-own-property-descriptor"></a>
|
|
179
|
+
|
|
180
|
+
#### Object.getOwnPropertyDescriptor( o, p )
|
|
181
|
+
|
|
182
|
+
Returns an object that contains the properties of the given object.
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
var o = { 'a': 1 };
|
|
186
|
+
var d = Object.getOwnPropertyDescriptor( o, 'a' );
|
|
187
|
+
// returns { 'value': 1, 'writable': true, 'enumerable': true, 'configurable': true }
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
<a name="static-method-get-own-property-descriptors"></a>
|
|
191
|
+
|
|
192
|
+
#### Object.getOwnPropertyDescriptors( o )
|
|
193
|
+
|
|
194
|
+
Returns an object whose properties are the result of calling `Object.getOwnPropertyDescriptor()` on every property of the given object.
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
var o = { 'a': 1, 'b': 2 };
|
|
198
|
+
var d = Object.getOwnPropertyDescriptors( o );
|
|
199
|
+
// returns { 'a': { 'value': 1, 'writable': true, 'enumerable': true, 'configurable': true }, 'b': { 'value': 2, 'writable': true, 'enumerable': true, 'configurable': true } }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
<a name="static-method-get-own-property-names"></a>
|
|
203
|
+
|
|
204
|
+
#### Object.getOwnPropertyNames( o )
|
|
205
|
+
|
|
206
|
+
Returns an array of a given object's own property names.
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
var o = { 'a': 1, 'b': 2 };
|
|
210
|
+
var arr = Object.getOwnPropertyNames( o );
|
|
211
|
+
// e.g., returns [ 'a', 'b' ]
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
<a name="static-method-get-own-property-symbols"></a>
|
|
215
|
+
|
|
216
|
+
#### Object.getOwnPropertySymbols( o )
|
|
217
|
+
|
|
218
|
+
Returns an array of a given object's own property symbols.
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
var o = { 'a': 1 };
|
|
222
|
+
o[ Symbol( 'b' ) ] = 2;
|
|
223
|
+
var arr = Object.getOwnPropertySymbols( o );
|
|
224
|
+
// returns [ Symbol(b) ]
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
<a name="static-method-get-prototype-of"></a>
|
|
228
|
+
|
|
229
|
+
#### Object.getPrototypeOf( o )
|
|
230
|
+
|
|
231
|
+
Returns the prototype of an object.
|
|
232
|
+
|
|
233
|
+
```javascript
|
|
234
|
+
var o = { 'a': 1 };
|
|
235
|
+
var p = Object.getPrototypeOf( o );
|
|
236
|
+
// returns {}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
<a name="static-method-has-own"></a>
|
|
240
|
+
|
|
241
|
+
#### Object.hasOwn( o, p )
|
|
242
|
+
|
|
243
|
+
Returns a boolean indicating whether an object has a property with the specified name.
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
var o = { 'a': 1 };
|
|
247
|
+
var b = Object.hasOwn( o, 'b' );
|
|
248
|
+
// returns false
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
<a name="method-proto-has-own-prop"></a>
|
|
252
|
+
|
|
253
|
+
#### Object.prototype.hasOwnProperty( p )
|
|
254
|
+
|
|
255
|
+
Returns a boolean indicating whether an object has a property with the specified name.
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
var o = { 'a': 1 };
|
|
259
|
+
var b = o.hasOwnProperty( 'a' );
|
|
260
|
+
// returns true
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
<a name="static-method-is"></a>
|
|
264
|
+
|
|
265
|
+
#### Object.is( value1, value2 )
|
|
266
|
+
|
|
267
|
+
Returns a boolean indicating whether two values are the same value.
|
|
268
|
+
|
|
269
|
+
```javascript
|
|
270
|
+
var b = Object.is( 1, 1 );
|
|
271
|
+
// returns true
|
|
272
|
+
|
|
273
|
+
b = Object.is( 1, '1' );
|
|
274
|
+
// returns false
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
<a name="static-method-is-extensible"></a>
|
|
278
|
+
|
|
279
|
+
#### Object.isExtensible( o )
|
|
280
|
+
|
|
281
|
+
Returns a boolean indicating whether an object is extensible (whether new properties can be added to it).
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
var o = { 'a': 1 };
|
|
285
|
+
var b = Object.isExtensible( o );
|
|
286
|
+
// returns true
|
|
287
|
+
|
|
288
|
+
Object.preventExtensions( o );
|
|
289
|
+
b = Object.isExtensible( o );
|
|
290
|
+
// returns false
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
<a name="static-method-is-frozen"></a>
|
|
294
|
+
|
|
295
|
+
#### Object.isFrozen( o )
|
|
296
|
+
|
|
297
|
+
Returns a boolean indicating whether an object is frozen. Frozen objects can no longer be changed; freezing an object prevents new properties from being added to it, existing properties from being removed, and existing properties from being changed.
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
var o = { 'a': 1 };
|
|
301
|
+
var b = Object.isFrozen( o );
|
|
302
|
+
// returns false
|
|
303
|
+
|
|
304
|
+
Object.freeze( o );
|
|
305
|
+
b = Object.isFrozen( o );
|
|
306
|
+
// returns true
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
<a name="method-is-prototype-of"></a>
|
|
310
|
+
|
|
311
|
+
#### Object.prototype.isPrototypeOf( o )
|
|
312
|
+
|
|
313
|
+
Returns a boolean indicating whether an object is in the prototype chain of another object.
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
var o = { 'a': 1 };
|
|
317
|
+
var p = { '__proto__': o };
|
|
318
|
+
var b = o.isPrototypeOf( p );
|
|
319
|
+
// returns true
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
<a name="static-method-is-sealed"></a>
|
|
323
|
+
|
|
324
|
+
#### Object.isSealed( o )
|
|
325
|
+
|
|
326
|
+
Returns a boolean indicating whether an object is sealed. An object is sealed if it is not extensible and all of its properties are non-configurable.
|
|
327
|
+
|
|
328
|
+
```javascript
|
|
329
|
+
var o = { 'a': 1 };
|
|
330
|
+
var b = Object.isSealed( o );
|
|
331
|
+
// returns false
|
|
332
|
+
|
|
333
|
+
Object.seal( o );
|
|
334
|
+
b = Object.isSealed( o );
|
|
335
|
+
// returns true
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
<a name="static-method-keys"></a>
|
|
339
|
+
|
|
340
|
+
#### Object.keys( o )
|
|
341
|
+
|
|
342
|
+
Returns an array of a given object's own enumerable property names.
|
|
343
|
+
|
|
344
|
+
```javascript
|
|
345
|
+
var o = { 'a': 1, 'b': 2 };
|
|
346
|
+
var arr = Object.keys( o );
|
|
347
|
+
// e.g., returns [ 'a', 'b' ]
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
<a name="static-method-prevent-extensions"></a>
|
|
351
|
+
|
|
352
|
+
#### Object.preventExtensions( o )
|
|
353
|
+
|
|
354
|
+
Prevents new properties from being added to an object.
|
|
355
|
+
|
|
356
|
+
```javascript
|
|
357
|
+
var o = { 'a': 1 };
|
|
358
|
+
Object.preventExtensions( o );
|
|
359
|
+
o.b = 2;
|
|
360
|
+
var b = ( o.b === void 0 );
|
|
361
|
+
// returns true
|
|
362
|
+
|
|
363
|
+
o.a = 3;
|
|
364
|
+
b = ( o.a === 3 );
|
|
365
|
+
// returns true
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
<a name="method-prop-is-enumerable"></a>
|
|
369
|
+
|
|
370
|
+
#### Object.prototype.propertyIsEnumerable( p )
|
|
371
|
+
|
|
372
|
+
Returns a boolean indicating whether a property is enumerable.
|
|
373
|
+
|
|
374
|
+
```javascript
|
|
375
|
+
var o = { 'a': 1 };
|
|
376
|
+
var b = o.propertyIsEnumerable( 'a' );
|
|
377
|
+
// returns true
|
|
378
|
+
|
|
379
|
+
var arr = [ 1, 2, 3 ];
|
|
380
|
+
b = arr.propertyIsEnumerable( 'length' );
|
|
381
|
+
// returns false
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
<a name="static-method-seal"></a>
|
|
385
|
+
|
|
386
|
+
#### Object.seal( o )
|
|
387
|
+
|
|
388
|
+
Seals an object, preventing new properties from being added to it (i.e., making it non extensible) and marking all existing properties as non-configurable.
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
var o = { 'a': 1 };
|
|
392
|
+
Object.seal( o );
|
|
393
|
+
|
|
394
|
+
o.b = 2;
|
|
395
|
+
var b = ( o.b === void 0 );
|
|
396
|
+
// returns true
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
<a name="static-method-set-prototype-of"></a>
|
|
400
|
+
|
|
401
|
+
#### Object.setPrototypeOf( o, proto )
|
|
402
|
+
|
|
403
|
+
Sets the prototype of an object.
|
|
404
|
+
|
|
405
|
+
```javascript
|
|
406
|
+
var o = { 'a': 1 };
|
|
407
|
+
var p = { 'b': 2 };
|
|
408
|
+
Object.setPrototypeOf( o, p );
|
|
409
|
+
|
|
410
|
+
var b = ( o.b === 2 );
|
|
411
|
+
// returns true
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
<a name="method-to-locale-string"></a>
|
|
415
|
+
|
|
416
|
+
#### Object.prototype.toLocaleString()
|
|
417
|
+
|
|
418
|
+
Returns a string representing the object.
|
|
419
|
+
|
|
420
|
+
```javascript
|
|
421
|
+
var o = { 'a': 1 };
|
|
422
|
+
var str = o.toLocaleString();
|
|
423
|
+
// returns <string>
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
<a name="method-to-string"></a>
|
|
427
|
+
|
|
428
|
+
#### Object.prototype.toString()
|
|
429
|
+
|
|
430
|
+
Returns a string representing the object.
|
|
431
|
+
|
|
432
|
+
```javascript
|
|
433
|
+
var o = { 'a': 1 };
|
|
434
|
+
var str = o.toString();
|
|
435
|
+
// returns <string>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
<a name="method-to-value-of"></a>
|
|
439
|
+
|
|
440
|
+
#### Object.prototype.valueOf()
|
|
441
|
+
|
|
442
|
+
Returns the primitive value of the object.
|
|
443
|
+
|
|
444
|
+
```javascript
|
|
445
|
+
var o = {};
|
|
446
|
+
var v = o.valueOf();
|
|
447
|
+
// returns {}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
<a name="static-method-values"></a>
|
|
451
|
+
|
|
452
|
+
#### Object.values( o )
|
|
453
|
+
|
|
454
|
+
Returns an array of a given object's own enumerable property values.
|
|
455
|
+
|
|
456
|
+
```javascript
|
|
457
|
+
var o = { 'a': 1, 'b': 2 };
|
|
458
|
+
var arr = Object.values( o );
|
|
459
|
+
// e.g., returns [ 1, 2 ]
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
</section>
|
|
463
|
+
|
|
464
|
+
<!-- /.usage -->
|
|
465
|
+
|
|
466
|
+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
467
|
+
|
|
468
|
+
<section class="notes">
|
|
469
|
+
|
|
470
|
+
## Notes
|
|
471
|
+
|
|
472
|
+
- If provided `null` or `undefined`, the function returns an empty object.
|
|
473
|
+
- If provided an existing object, the function returns the input value unchanged.
|
|
474
|
+
- Otherwise, if provided any other value (e.g., a number, string, etc), the function will return an object of the corresponding type.
|
|
475
|
+
|
|
476
|
+
</section>
|
|
477
|
+
|
|
478
|
+
<!-- /.notes -->
|
|
479
|
+
|
|
480
|
+
<!-- Package usage examples. -->
|
|
481
|
+
|
|
482
|
+
<section class="examples">
|
|
483
|
+
|
|
484
|
+
## Examples
|
|
485
|
+
|
|
486
|
+
<!-- eslint no-undef: "error" -->
|
|
487
|
+
|
|
488
|
+
```javascript
|
|
489
|
+
var Object = require( '@stdlib/object/ctor' );
|
|
490
|
+
|
|
491
|
+
var values = [
|
|
492
|
+
'5',
|
|
493
|
+
5,
|
|
494
|
+
true,
|
|
495
|
+
false,
|
|
496
|
+
null,
|
|
497
|
+
void 0,
|
|
498
|
+
[],
|
|
499
|
+
{}
|
|
500
|
+
];
|
|
501
|
+
|
|
502
|
+
var i;
|
|
503
|
+
for ( i = 0; i < values.length; i++ ) {
|
|
504
|
+
console.log( new Object( values[ i ] ) );
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
</section>
|
|
509
|
+
|
|
510
|
+
<!-- /.examples -->
|
|
511
|
+
|
|
512
|
+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
513
|
+
|
|
514
|
+
<section class="references">
|
|
515
|
+
|
|
516
|
+
</section>
|
|
517
|
+
|
|
518
|
+
<!-- /.references -->
|
|
519
|
+
|
|
520
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
521
|
+
|
|
522
|
+
<section class="related">
|
|
523
|
+
|
|
524
|
+
</section>
|
|
525
|
+
|
|
526
|
+
<!-- /.related -->
|
|
527
|
+
|
|
528
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
529
|
+
|
|
530
|
+
<section class="links">
|
|
531
|
+
|
|
532
|
+
[mdn-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
533
|
+
|
|
534
|
+
</section>
|
|
535
|
+
|
|
536
|
+
<!-- /.links -->
|