|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 var ERR_CONFLICT = "Remaining conflicting property: "; |
|
8 var ERR_REQUIRED = "Missing required property: "; |
|
9 |
|
10 exports.Data = function Data(value, enumerable, configurable, writable) { |
|
11 return ({ |
|
12 value: value, |
|
13 enumerable: enumerable !== false, |
|
14 configurable: configurable !== false, |
|
15 writable: writable !== false |
|
16 }); |
|
17 }; |
|
18 |
|
19 exports.Method = function Method(method, enumerable, configurable, writable) { |
|
20 return ({ |
|
21 value: method, |
|
22 enumerable: enumerable !== false, |
|
23 configurable: configurable !== false, |
|
24 writable: writable !== false |
|
25 }); |
|
26 }; |
|
27 |
|
28 exports.Accessor = function Accessor(get, set, enumerable, configurable) { |
|
29 return ({ |
|
30 get: get, |
|
31 set: set, |
|
32 enumerable: enumerable !== false, |
|
33 configurable: configurable !== false |
|
34 }); |
|
35 }; |
|
36 |
|
37 exports.Required = function Required(name) { |
|
38 function required() { throw new Error(ERR_REQUIRED + name) } |
|
39 |
|
40 return ({ |
|
41 get: required, |
|
42 set: required, |
|
43 required: true |
|
44 }); |
|
45 }; |
|
46 |
|
47 exports.Conflict = function Conflict(name) { |
|
48 function conflict() { throw new Error(ERR_CONFLICT + name) } |
|
49 |
|
50 return ({ |
|
51 get: conflict, |
|
52 set: conflict, |
|
53 conflict: true |
|
54 }); |
|
55 }; |
|
56 |