objectmodel 4.3.0 → 4.4.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 (59) hide show
  1. package/.eslintignore +8 -8
  2. package/.eslintrc.json +25 -25
  3. package/.travis.yml +2 -2
  4. package/LICENSE +22 -22
  5. package/README.md +67 -67
  6. package/build/{add-banner.cjs → add-banner.js} +13 -13
  7. package/build/bundle-entry.dev.js +2 -2
  8. package/build/bundle-entry.js +11 -11
  9. package/build/{update-docs.cjs → update-docs.js} +7 -5
  10. package/dist/object-model.cjs +466 -472
  11. package/dist/object-model.js +466 -472
  12. package/dist/object-model.js.map +1 -1
  13. package/dist/object-model.min.js +2 -2
  14. package/dist/object-model.min.js.map +1 -1
  15. package/index.html +1603 -1603
  16. package/package.json +20 -10
  17. package/rollup.config.js +13 -13
  18. package/src/array-model.d.ts +16 -0
  19. package/src/array-model.js +68 -68
  20. package/src/devtool-formatter.js +198 -198
  21. package/src/function-model.d.ts +24 -0
  22. package/src/function-model.js +58 -65
  23. package/src/helpers.js +43 -43
  24. package/src/index.js +4 -4
  25. package/src/list-model.js +43 -43
  26. package/src/map-model.d.ts +18 -0
  27. package/src/map-model.js +48 -48
  28. package/src/object-model.d.ts +74 -0
  29. package/src/object-model.js +4 -3
  30. package/src/set-model.d.ts +16 -0
  31. package/src/set-model.js +41 -41
  32. package/test/array-model.spec.cjs +291 -291
  33. package/test/array-model.test-d.ts +24 -0
  34. package/test/basic-model.spec.cjs +263 -263
  35. package/test/basic-model.test-d.ts +30 -0
  36. package/test/bench/array.html +51 -51
  37. package/test/bench/bench-lib.js +49 -49
  38. package/test/bench/map-no-cast.html +53 -53
  39. package/test/bench/map-set.html +52 -52
  40. package/test/bench/map.html +51 -51
  41. package/test/bench/object-models.html +87 -87
  42. package/test/function-model.spec.cjs +161 -162
  43. package/test/function-model.test-d.ts +18 -0
  44. package/test/index.cjs +13 -13
  45. package/test/index.html +27 -27
  46. package/test/map-model.spec.cjs +224 -224
  47. package/test/map-model.test-d.ts +21 -0
  48. package/test/model.spec.cjs +30 -30
  49. package/test/object-model.spec.cjs +1345 -1327
  50. package/test/object-model.test-d.ts +53 -0
  51. package/test/set-model.spec.cjs +213 -213
  52. package/test/set-model.test-d.ts +17 -0
  53. package/test/umd.html +25 -25
  54. package/types/definitions.d.ts +43 -0
  55. package/types/helpers.d.ts +4 -0
  56. package/types/index.d.ts +6 -128
  57. package/test/lib/qunit.css +0 -436
  58. package/test/lib/qunit.js +0 -6582
  59. package/tsconfig.json +0 -10
package/types/index.d.ts CHANGED
@@ -1,132 +1,10 @@
1
1
  // TypeScript definition file for ObjectModel
2
2
 
3
- export interface Model {
4
- (value?: any): any;
5
-
6
- definition: any;
7
- assertions: Assertion[];
8
- default: any;
9
- name: string;
10
-
11
- conventionForConstant(variableName: string): boolean;
12
- conventionForPrivate(variableName: string): boolean;
13
-
14
- toString(stack?: any[]): string;
15
-
16
- as(name: string): this;
17
-
18
- defaultTo(defaultValue: any): this;
19
-
20
- test(value: any, errorCollector?: (errors: ModelError[]) => void): boolean;
21
-
22
- errorCollector(errors: ModelError[]): void;
23
-
24
- assert(assertion: Assertion, description?: string | Function): this;
25
-
26
- }
27
-
28
- export interface ModelConstructor {
29
- (definition: any): ObjectModel;
30
- new(definition: any): ObjectModel;
31
- CHECK_ONCE: symbol;
32
- }
33
-
34
- export interface BasicModel extends Model {
35
- (): any;
36
- new(): any;
37
- (value: any): any
38
- new(value: any): any
39
-
40
- extend(...otherDefinitions: Array<any>): this;
41
- }
42
-
43
- export interface BasicModelConstructor {
44
- (definition: any): BasicModel
45
- new(definition: any): BasicModel;
46
- }
47
-
48
- export interface ObjectModel extends Model {
49
- (): Object;
50
- new(): Object;
51
- (object: object): Object;
52
- new(object: object): Object;
53
-
54
- extend(...otherDefinitions: Array<Object | ObjectModel>): this;
55
- }
56
-
57
- export interface ObjectModelConstructor {
58
- (definition: Object): ObjectModel;
59
- new(definition: Object): ObjectModel;
60
- }
61
-
62
- export interface ArrayModel extends Model {
63
- <T>(): Array<T>;
64
- new <T>(): Array<T>;
65
- <T>(array: Array<T>): Array<T>;
66
- new <T>(array: Array<T>): Array<T>;
67
-
68
- extend(...otherElementDefinitions: Array<any>): this;
69
- }
70
-
71
- export interface ArrayModelConstructor {
72
- (itemDefinition: any): ArrayModel;
73
- new(itemDefinition: any): ArrayModel;
74
- }
75
-
76
- export interface FunctionModel extends Model {
77
- (): Function;
78
- new(): Function;
79
- (fn: Function): Function;
80
- new(fn: Function): Function;
81
-
82
- definition: { arguments: any[], return: any };
83
-
84
- return(returnValueDefinition: any): FunctionModel;
85
-
86
- extend(otherArgsDefinitions: Array<any>, otherReturnValuesDefinitions: Array<any>): this;
87
- }
88
-
89
- export interface FunctionModelConstructor {
90
- (...argumentsDefinitions: any[]): FunctionModel;
91
- new(...argumentsDefinitions: any[]): FunctionModel;
92
- }
93
-
94
- export interface MapModel extends Model {
95
- (): Map<any, any>;
96
- new(): Map<any, any>;
97
- (iterable: Map<any, any> | Array<[any, any]>): Map<any, any>;
98
- new(iterable: Map<any, any> | Array<[any, any]>): Map<any, any>;
99
-
100
- extend(otherKeyDefinitions: Array<any>, otherValueDefinitions: Array<any>): this;
101
- }
102
-
103
- export interface MapModelConstructor {
104
- (keyDefinition: any, valueDefinition: any): MapModel;
105
- new(keyDefinition: any, valueDefinition: any): MapModel;
106
- }
107
-
108
- export interface SetModel extends Model {
109
- (): Set<any>;
110
- new(): Set<any>;
111
- (set: Set<any> | Array<any>): Set<any>;
112
- new(set: Set<any> | Array<any>): Set<any>;
113
-
114
- extend(...otherElementDefinitions: Array<any>): this;
115
- }
116
-
117
- export interface SetModelConstructor {
118
- (itemDefinition: any): SetModel;
119
- new(itemDefinition: any): SetModel;
120
- }
121
-
122
- export type Assertion = (variable: any) => boolean
123
-
124
- export interface ModelError {
125
- message: string;
126
- expected: any;
127
- received: any;
128
- path: string;
129
- }
3
+ import { ArrayModelConstructor } from "../src/array-model";
4
+ import { FunctionModelConstructor } from "../src/function-model";
5
+ import { MapModelConstructor } from "../src/map-model";
6
+ import { ModelConstructor, BasicModelConstructor, ObjectModelConstructor } from "../src/object-model";
7
+ import { SetModelConstructor } from "../src/set-model";
130
8
 
131
9
  export const Any: any;
132
10
  export const Model: ModelConstructor;
@@ -135,4 +13,4 @@ export const ObjectModel: ObjectModelConstructor;
135
13
  export const ArrayModel: ArrayModelConstructor;
136
14
  export const FunctionModel: FunctionModelConstructor;
137
15
  export const MapModel: MapModelConstructor;
138
- export const SetModel: SetModelConstructor;
16
+ export const SetModel: SetModelConstructor;
@@ -1,436 +0,0 @@
1
- /*!
2
- * QUnit 2.9.1
3
- * https://qunitjs.com/
4
- *
5
- * Copyright jQuery Foundation and other contributors
6
- * Released under the MIT license
7
- * https://jquery.org/license
8
- *
9
- * Date: 2019-01-07T16:37Z
10
- */
11
-
12
- /** Font Family and Sizes */
13
-
14
- #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
15
- font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
16
- }
17
-
18
- #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
19
- #qunit-tests { font-size: smaller; }
20
-
21
-
22
- /** Resets */
23
-
24
- #qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
25
- margin: 0;
26
- padding: 0;
27
- }
28
-
29
-
30
- /** Header (excluding toolbar) */
31
-
32
- #qunit-header {
33
- padding: 0.5em 0 0.5em 1em;
34
-
35
- color: #8699A4;
36
- background-color: #0D3349;
37
-
38
- font-size: 1.5em;
39
- line-height: 1em;
40
- font-weight: 400;
41
-
42
- border-radius: 5px 5px 0 0;
43
- }
44
-
45
- #qunit-header a {
46
- text-decoration: none;
47
- color: #C2CCD1;
48
- }
49
-
50
- #qunit-header a:hover,
51
- #qunit-header a:focus {
52
- color: #FFF;
53
- }
54
-
55
- #qunit-banner {
56
- height: 5px;
57
- }
58
-
59
- #qunit-filteredTest {
60
- padding: 0.5em 1em 0.5em 1em;
61
- color: #366097;
62
- background-color: #F4FF77;
63
- }
64
-
65
- #qunit-userAgent {
66
- padding: 0.5em 1em 0.5em 1em;
67
- color: #FFF;
68
- background-color: #2B81AF;
69
- text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
70
- }
71
-
72
-
73
- /** Toolbar */
74
-
75
- #qunit-testrunner-toolbar {
76
- padding: 0.5em 1em 0.5em 1em;
77
- color: #5E740B;
78
- background-color: #EEE;
79
- }
80
-
81
- #qunit-testrunner-toolbar .clearfix {
82
- height: 0;
83
- clear: both;
84
- }
85
-
86
- #qunit-testrunner-toolbar label {
87
- display: inline-block;
88
- }
89
-
90
- #qunit-testrunner-toolbar input[type=checkbox],
91
- #qunit-testrunner-toolbar input[type=radio] {
92
- margin: 3px;
93
- vertical-align: -2px;
94
- }
95
-
96
- #qunit-testrunner-toolbar input[type=text] {
97
- box-sizing: border-box;
98
- height: 1.6em;
99
- }
100
-
101
- .qunit-url-config,
102
- .qunit-filter,
103
- #qunit-modulefilter {
104
- display: inline-block;
105
- line-height: 2.1em;
106
- }
107
-
108
- .qunit-filter,
109
- #qunit-modulefilter {
110
- float: right;
111
- position: relative;
112
- margin-left: 1em;
113
- }
114
-
115
- .qunit-url-config label {
116
- margin-right: 0.5em;
117
- }
118
-
119
- #qunit-modulefilter-search {
120
- box-sizing: border-box;
121
- width: 400px;
122
- }
123
-
124
- #qunit-modulefilter-search-container:after {
125
- position: absolute;
126
- right: 0.3em;
127
- content: "\25bc";
128
- color: black;
129
- }
130
-
131
- #qunit-modulefilter-dropdown {
132
- /* align with #qunit-modulefilter-search */
133
- box-sizing: border-box;
134
- width: 400px;
135
- position: absolute;
136
- right: 0;
137
- top: 50%;
138
- margin-top: 0.8em;
139
-
140
- border: 1px solid #D3D3D3;
141
- border-top: none;
142
- border-radius: 0 0 .25em .25em;
143
- color: #000;
144
- background-color: #F5F5F5;
145
- z-index: 99;
146
- }
147
-
148
- #qunit-modulefilter-dropdown a {
149
- color: inherit;
150
- text-decoration: none;
151
- }
152
-
153
- #qunit-modulefilter-dropdown .clickable.checked {
154
- font-weight: bold;
155
- color: #000;
156
- background-color: #D2E0E6;
157
- }
158
-
159
- #qunit-modulefilter-dropdown .clickable:hover {
160
- color: #FFF;
161
- background-color: #0D3349;
162
- }
163
-
164
- #qunit-modulefilter-actions {
165
- display: block;
166
- overflow: auto;
167
-
168
- /* align with #qunit-modulefilter-dropdown-list */
169
- font: smaller/1.5em sans-serif;
170
- }
171
-
172
- #qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {
173
- box-sizing: border-box;
174
- max-height: 2.8em;
175
- display: block;
176
- padding: 0.4em;
177
- }
178
-
179
- #qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {
180
- float: right;
181
- font: inherit;
182
- }
183
-
184
- #qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child {
185
- /* insert padding to align with checkbox margins */
186
- padding-left: 3px;
187
- }
188
-
189
- #qunit-modulefilter-dropdown-list {
190
- max-height: 200px;
191
- overflow-y: auto;
192
- margin: 0;
193
- border-top: 2px groove threedhighlight;
194
- padding: 0.4em 0 0;
195
- font: smaller/1.5em sans-serif;
196
- }
197
-
198
- #qunit-modulefilter-dropdown-list li {
199
- white-space: nowrap;
200
- overflow: hidden;
201
- text-overflow: ellipsis;
202
- }
203
-
204
- #qunit-modulefilter-dropdown-list .clickable {
205
- display: block;
206
- padding-left: 0.15em;
207
- }
208
-
209
-
210
- /** Tests: Pass/Fail */
211
-
212
- #qunit-tests {
213
- list-style-position: inside;
214
- }
215
-
216
- #qunit-tests li {
217
- padding: 0.4em 1em 0.4em 1em;
218
- border-bottom: 1px solid #FFF;
219
- list-style-position: inside;
220
- }
221
-
222
- #qunit-tests > li {
223
- display: none;
224
- }
225
-
226
- #qunit-tests li.running,
227
- #qunit-tests li.pass,
228
- #qunit-tests li.fail,
229
- #qunit-tests li.skipped,
230
- #qunit-tests li.aborted {
231
- display: list-item;
232
- }
233
-
234
- #qunit-tests.hidepass {
235
- position: relative;
236
- }
237
-
238
- #qunit-tests.hidepass li.running,
239
- #qunit-tests.hidepass li.pass:not(.todo) {
240
- visibility: hidden;
241
- position: absolute;
242
- width: 0;
243
- height: 0;
244
- padding: 0;
245
- border: 0;
246
- margin: 0;
247
- }
248
-
249
- #qunit-tests li strong {
250
- cursor: pointer;
251
- }
252
-
253
- #qunit-tests li.skipped strong {
254
- cursor: default;
255
- }
256
-
257
- #qunit-tests li a {
258
- padding: 0.5em;
259
- color: #C2CCD1;
260
- text-decoration: none;
261
- }
262
-
263
- #qunit-tests li p a {
264
- padding: 0.25em;
265
- color: #6B6464;
266
- }
267
- #qunit-tests li a:hover,
268
- #qunit-tests li a:focus {
269
- color: #000;
270
- }
271
-
272
- #qunit-tests li .runtime {
273
- float: right;
274
- font-size: smaller;
275
- }
276
-
277
- .qunit-assert-list {
278
- margin-top: 0.5em;
279
- padding: 0.5em;
280
-
281
- background-color: #FFF;
282
-
283
- border-radius: 5px;
284
- }
285
-
286
- .qunit-source {
287
- margin: 0.6em 0 0.3em;
288
- }
289
-
290
- .qunit-collapsed {
291
- display: none;
292
- }
293
-
294
- #qunit-tests table {
295
- border-collapse: collapse;
296
- margin-top: 0.2em;
297
- }
298
-
299
- #qunit-tests th {
300
- text-align: right;
301
- vertical-align: top;
302
- padding: 0 0.5em 0 0;
303
- }
304
-
305
- #qunit-tests td {
306
- vertical-align: top;
307
- }
308
-
309
- #qunit-tests pre {
310
- margin: 0;
311
- white-space: pre-wrap;
312
- word-wrap: break-word;
313
- }
314
-
315
- #qunit-tests del {
316
- color: #374E0C;
317
- background-color: #E0F2BE;
318
- text-decoration: none;
319
- }
320
-
321
- #qunit-tests ins {
322
- color: #500;
323
- background-color: #FFCACA;
324
- text-decoration: none;
325
- }
326
-
327
- /*** Test Counts */
328
-
329
- #qunit-tests b.counts { color: #000; }
330
- #qunit-tests b.passed { color: #5E740B; }
331
- #qunit-tests b.failed { color: #710909; }
332
-
333
- #qunit-tests li li {
334
- padding: 5px;
335
- background-color: #FFF;
336
- border-bottom: none;
337
- list-style-position: inside;
338
- }
339
-
340
- /*** Passing Styles */
341
-
342
- #qunit-tests li li.pass {
343
- color: #3C510C;
344
- background-color: #FFF;
345
- border-left: 10px solid #C6E746;
346
- }
347
-
348
- #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
349
- #qunit-tests .pass .test-name { color: #366097; }
350
-
351
- #qunit-tests .pass .test-actual,
352
- #qunit-tests .pass .test-expected { color: #999; }
353
-
354
- #qunit-banner.qunit-pass { background-color: #C6E746; }
355
-
356
- /*** Failing Styles */
357
-
358
- #qunit-tests li li.fail {
359
- color: #710909;
360
- background-color: #FFF;
361
- border-left: 10px solid #EE5757;
362
- white-space: pre;
363
- }
364
-
365
- #qunit-tests > li:last-child {
366
- border-radius: 0 0 5px 5px;
367
- }
368
-
369
- #qunit-tests .fail { color: #000; background-color: #EE5757; }
370
- #qunit-tests .fail .test-name,
371
- #qunit-tests .fail .module-name { color: #000; }
372
-
373
- #qunit-tests .fail .test-actual { color: #EE5757; }
374
- #qunit-tests .fail .test-expected { color: #008000; }
375
-
376
- #qunit-banner.qunit-fail { background-color: #EE5757; }
377
-
378
-
379
- /*** Aborted tests */
380
- #qunit-tests .aborted { color: #000; background-color: orange; }
381
- /*** Skipped tests */
382
-
383
- #qunit-tests .skipped {
384
- background-color: #EBECE9;
385
- }
386
-
387
- #qunit-tests .qunit-todo-label,
388
- #qunit-tests .qunit-skipped-label {
389
- background-color: #F4FF77;
390
- display: inline-block;
391
- font-style: normal;
392
- color: #366097;
393
- line-height: 1.8em;
394
- padding: 0 0.5em;
395
- margin: -0.4em 0.4em -0.4em 0;
396
- }
397
-
398
- #qunit-tests .qunit-todo-label {
399
- background-color: #EEE;
400
- }
401
-
402
- /** Result */
403
-
404
- #qunit-testresult {
405
- color: #2B81AF;
406
- background-color: #D2E0E6;
407
-
408
- border-bottom: 1px solid #FFF;
409
- }
410
- #qunit-testresult .clearfix {
411
- height: 0;
412
- clear: both;
413
- }
414
- #qunit-testresult .module-name {
415
- font-weight: 700;
416
- }
417
- #qunit-testresult-display {
418
- padding: 0.5em 1em 0.5em 1em;
419
- width: 85%;
420
- float:left;
421
- }
422
- #qunit-testresult-controls {
423
- padding: 0.5em 1em 0.5em 1em;
424
- width: 10%;
425
- float:left;
426
- }
427
-
428
- /** Fixture */
429
-
430
- #qunit-fixture {
431
- position: absolute;
432
- top: -10000px;
433
- left: -10000px;
434
- width: 1000px;
435
- height: 1000px;
436
- }