decoders 2.0.0-beta8 → 2.0.1

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 (146) hide show
  1. package/CHANGELOG.md +67 -20
  2. package/Decoder.d.ts +94 -0
  3. package/Decoder.js +115 -0
  4. package/Decoder.js.flow +286 -0
  5. package/Decoder.mjs +108 -0
  6. package/README.md +122 -1345
  7. package/_utils.d.ts +0 -1
  8. package/_utils.js +51 -68
  9. package/_utils.js.flow +30 -20
  10. package/_utils.mjs +39 -54
  11. package/annotate.js +79 -72
  12. package/annotate.mjs +62 -58
  13. package/format.d.ts +4 -2
  14. package/format.js +64 -74
  15. package/format.js.flow +14 -12
  16. package/format.mjs +58 -68
  17. package/index.d.ts +38 -41
  18. package/index.js +66 -98
  19. package/index.js.flow +39 -58
  20. package/index.mjs +11 -37
  21. package/{core → lib}/_helpers.d.ts +0 -0
  22. package/lib/arrays.d.ts +59 -0
  23. package/lib/arrays.js +97 -0
  24. package/lib/arrays.js.flow +138 -0
  25. package/lib/arrays.mjs +84 -0
  26. package/lib/basics.d.ts +93 -0
  27. package/lib/basics.js +94 -0
  28. package/lib/basics.js.flow +124 -0
  29. package/lib/basics.mjs +75 -0
  30. package/lib/booleans.d.ts +16 -0
  31. package/lib/booleans.js +25 -0
  32. package/lib/booleans.js.flow +22 -0
  33. package/lib/booleans.mjs +15 -0
  34. package/lib/dates.d.ts +15 -0
  35. package/lib/dates.js +28 -0
  36. package/lib/dates.js.flow +40 -0
  37. package/lib/dates.mjs +19 -0
  38. package/lib/json.d.ts +35 -0
  39. package/lib/json.js +33 -0
  40. package/lib/json.js.flow +50 -0
  41. package/lib/json.mjs +18 -0
  42. package/lib/numbers.d.ts +31 -0
  43. package/lib/numbers.js +31 -0
  44. package/lib/numbers.js.flow +48 -0
  45. package/lib/numbers.mjs +21 -0
  46. package/lib/objects.d.ts +76 -0
  47. package/lib/objects.js +161 -0
  48. package/lib/objects.js.flow +238 -0
  49. package/lib/objects.mjs +147 -0
  50. package/lib/strings.d.ts +56 -0
  51. package/lib/strings.js +58 -0
  52. package/lib/strings.js.flow +90 -0
  53. package/lib/strings.mjs +40 -0
  54. package/lib/unions.d.ts +55 -0
  55. package/lib/unions.js +96 -0
  56. package/lib/unions.js.flow +155 -0
  57. package/lib/unions.mjs +83 -0
  58. package/lib/utilities.d.ts +40 -0
  59. package/lib/utilities.js +48 -0
  60. package/lib/utilities.js.flow +65 -0
  61. package/lib/utilities.mjs +37 -0
  62. package/package.json +64 -17
  63. package/result.d.ts +2 -25
  64. package/result.js +9 -90
  65. package/result.js.flow +4 -76
  66. package/result.mjs +5 -71
  67. package/_guard.d.ts +0 -7
  68. package/_guard.js +0 -22
  69. package/_guard.js.flow +0 -20
  70. package/_guard.mjs +0 -15
  71. package/_types.d.ts +0 -13
  72. package/_types.js +0 -1
  73. package/_types.js.flow +0 -20
  74. package/_types.mjs +0 -0
  75. package/core/array.d.ts +0 -5
  76. package/core/array.js +0 -104
  77. package/core/array.js.flow +0 -100
  78. package/core/array.mjs +0 -91
  79. package/core/boolean.d.ts +0 -5
  80. package/core/boolean.js +0 -40
  81. package/core/boolean.js.flow +0 -27
  82. package/core/boolean.mjs +0 -28
  83. package/core/composition.d.ts +0 -14
  84. package/core/composition.js +0 -54
  85. package/core/composition.js.flow +0 -48
  86. package/core/composition.mjs +0 -44
  87. package/core/constants.d.ts +0 -11
  88. package/core/constants.js +0 -65
  89. package/core/constants.js.flow +0 -44
  90. package/core/constants.mjs +0 -46
  91. package/core/date.d.ts +0 -4
  92. package/core/date.js +0 -42
  93. package/core/date.js.flow +0 -38
  94. package/core/date.mjs +0 -28
  95. package/core/describe.d.ts +0 -3
  96. package/core/describe.js +0 -22
  97. package/core/describe.js.flow +0 -17
  98. package/core/describe.mjs +0 -16
  99. package/core/dispatch.d.ts +0 -8
  100. package/core/dispatch.js +0 -58
  101. package/core/dispatch.js.flow +0 -58
  102. package/core/dispatch.mjs +0 -51
  103. package/core/either.d.ts +0 -61
  104. package/core/either.js +0 -113
  105. package/core/either.js.flow +0 -151
  106. package/core/either.mjs +0 -90
  107. package/core/fail.d.ts +0 -3
  108. package/core/fail.js +0 -17
  109. package/core/fail.js.flow +0 -12
  110. package/core/fail.mjs +0 -11
  111. package/core/instanceOf.d.ts +0 -3
  112. package/core/instanceOf.js +0 -15
  113. package/core/instanceOf.js.flow +0 -20
  114. package/core/instanceOf.mjs +0 -8
  115. package/core/json.d.ts +0 -11
  116. package/core/json.js +0 -31
  117. package/core/json.js.flow +0 -28
  118. package/core/json.mjs +0 -15
  119. package/core/lazy.d.ts +0 -3
  120. package/core/lazy.js +0 -16
  121. package/core/lazy.js.flow +0 -15
  122. package/core/lazy.mjs +0 -11
  123. package/core/mapping.d.ts +0 -6
  124. package/core/mapping.js +0 -67
  125. package/core/mapping.js.flow +0 -62
  126. package/core/mapping.mjs +0 -58
  127. package/core/number.d.ts +0 -6
  128. package/core/number.js +0 -36
  129. package/core/number.js.flow +0 -40
  130. package/core/number.mjs +0 -25
  131. package/core/object.d.ts +0 -33
  132. package/core/object.js +0 -190
  133. package/core/object.js.flow +0 -203
  134. package/core/object.mjs +0 -175
  135. package/core/optional.d.ts +0 -5
  136. package/core/optional.js +0 -50
  137. package/core/optional.js.flow +0 -41
  138. package/core/optional.mjs +0 -38
  139. package/core/string.d.ts +0 -10
  140. package/core/string.js +0 -68
  141. package/core/string.js.flow +0 -59
  142. package/core/string.mjs +0 -49
  143. package/core/tuple.d.ts +0 -30
  144. package/core/tuple.js +0 -177
  145. package/core/tuple.js.flow +0 -211
  146. package/core/tuple.mjs +0 -159
package/_utils.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Annotation } from './annotate';
2
2
 
3
- export function isDate(value: unknown): boolean;
4
3
  export function asDate(value: unknown): Date | null;
5
4
  export function isMultiline(s: string): boolean;
6
5
  export function indent(s: string, prefix?: string): string;
package/_utils.js CHANGED
@@ -1,108 +1,91 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.INDENT = void 0;
5
- exports.asDate = asDate;
6
- exports.indent = indent;
7
- exports.isDate = isDate;
8
- exports.isMultiline = isMultiline;
9
- exports.summarize = summarize;
10
- // $FlowFixMe[unclear-type] - deliberate casting
11
- // Two spaces of indentation
12
- var INDENT = ' ';
13
- /**
14
- * `x instanceof Date` checks are unreliable across stack frames (that information
15
- * might get lost by the JS runtime), so we'll have to reside to more runtime
16
- * inspection checks.
17
- *
18
- * Taken from https://stackoverflow.com/a/44198641
19
- */
20
-
21
- exports.INDENT = INDENT;
22
-
23
- function isDate(value) {
24
- return !!value && // $FlowFixMe[method-unbinding]
25
- Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value);
1
+ 'use strict'
2
+
3
+ exports.__esModule = true
4
+ exports.INDENT = void 0
5
+ exports.asDate = asDate
6
+ exports.indent = indent
7
+ exports.isMultiline = isMultiline
8
+ exports.subtract = subtract
9
+ exports.summarize = summarize
10
+ var INDENT = ' '
11
+
12
+ exports.INDENT = INDENT
13
+
14
+ function subtract(xs, ys) {
15
+ var result = new Set()
16
+ xs.forEach(function (x) {
17
+ if (!ys.has(x)) {
18
+ result.add(x)
19
+ }
20
+ })
21
+ return result
26
22
  }
27
- /**
28
- * Is value is a valid Date instance, then return that. If not, then return
29
- * null.
30
- */
31
-
32
23
 
33
24
  function asDate(value) {
34
- return isDate(value) ? value : null;
25
+ return !!value && Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value) ? value : null
35
26
  }
36
27
 
37
28
  function isMultiline(s) {
38
- return s.indexOf('\n') >= 0;
29
+ return s.indexOf('\n') >= 0
39
30
  }
40
31
 
41
32
  function indent(s, prefix) {
42
33
  if (prefix === void 0) {
43
- prefix = INDENT;
34
+ prefix = INDENT
44
35
  }
45
36
 
46
37
  if (isMultiline(s)) {
47
- return s.split('\n').map(function (line) {
48
- return prefix + line;
49
- }).join('\n');
38
+ return s
39
+ .split('\n')
40
+ .map(function (line) {
41
+ return '' + prefix + line
42
+ })
43
+ .join('\n')
50
44
  } else {
51
- return prefix + s;
45
+ return '' + prefix + s
52
46
  }
53
47
  }
54
- /**
55
- * Walks the annotation tree and emits the annotation's key path within the
56
- * object tree, and the message as a series of messages (array of strings).
57
- */
58
-
59
48
 
60
49
  function summarize(ann, keypath) {
61
50
  if (keypath === void 0) {
62
- keypath = [];
51
+ keypath = []
63
52
  }
64
53
 
65
- var result = [];
54
+ var result = []
66
55
 
67
56
  if (ann.type === 'array') {
68
- var items = ann.items;
69
- var index = 0;
57
+ var items = ann.items
58
+ var index = 0
70
59
  items.forEach(function (ann) {
71
60
  summarize(ann, [].concat(keypath, [index++])).forEach(function (item) {
72
- return (// Collect to results
73
- result.push(item)
74
- );
75
- });
76
- });
61
+ return result.push(item)
62
+ })
63
+ })
77
64
  } else if (ann.type === 'object') {
78
- var fields = ann.fields;
65
+ var fields = ann.fields
79
66
  Object.keys(fields).forEach(function (key) {
80
- var value = fields[key];
67
+ var value = fields[key]
81
68
  summarize(value, [].concat(keypath, [key])).forEach(function (item) {
82
- return (// Collect to results
83
- result.push(item)
84
- );
85
- });
86
- });
69
+ return result.push(item)
70
+ })
71
+ })
87
72
  }
88
73
 
89
- var text = ann.text;
74
+ var text = ann.text
90
75
 
91
76
  if (!text) {
92
- return result;
77
+ return result
93
78
  }
94
79
 
95
- var prefix;
80
+ var prefix
96
81
 
97
82
  if (keypath.length === 0) {
98
- prefix = '';
83
+ prefix = ''
99
84
  } else if (keypath.length === 1) {
100
- prefix = typeof keypath[0] === 'number' ? "Value at index " + keypath[0] + ": " : "Value at key " + JSON.stringify(keypath[0]) + ": ";
85
+ prefix = typeof keypath[0] === 'number' ? 'Value at index ' + keypath[0] + ': ' : 'Value at key ' + JSON.stringify(keypath[0]) + ': '
101
86
  } else {
102
- prefix = "Value at keypath " + keypath.map(function (x) {
103
- return x.toString();
104
- }).join('.') + ": ";
87
+ prefix = 'Value at keypath ' + keypath.map(String).join('.') + ': '
105
88
  }
106
89
 
107
- return [].concat(result, [prefix + text]);
108
- }
90
+ return [].concat(result, ['' + prefix + text])
91
+ }
package/_utils.js.flow CHANGED
@@ -1,35 +1,45 @@
1
1
  // @flow strict
2
2
 
3
3
  import type { Annotation } from './annotate';
4
+ import type { Scalar } from './Decoder';
4
5
 
5
- // $FlowFixMe[unclear-type] - deliberate casting
6
- type cast = any;
6
+ // $FlowFixMe[unclear-type] - deliberate use of `any`
7
+ export type _Any = any;
7
8
 
8
9
  // Two spaces of indentation
9
10
  export const INDENT = ' ';
10
11
 
11
12
  /**
12
- * `x instanceof Date` checks are unreliable across stack frames (that information
13
- * might get lost by the JS runtime), so we'll have to reside to more runtime
14
- * inspection checks.
15
- *
16
- * Taken from https://stackoverflow.com/a/44198641
13
+ * Subtract two sets. Why isn't this a standard method on Sets?
17
14
  */
18
- export function isDate(value: mixed): boolean {
19
- return (
20
- !!value &&
21
- // $FlowFixMe[method-unbinding]
22
- Object.prototype.toString.call(value) === '[object Date]' &&
23
- !isNaN(value)
24
- );
15
+ export function subtract<T: Scalar>(xs: Set<T>, ys: Set<T>): Set<T> {
16
+ const result = new Set();
17
+ xs.forEach((x) => {
18
+ if (!ys.has(x)) {
19
+ result.add(x);
20
+ }
21
+ });
22
+ return result;
25
23
  }
26
24
 
27
25
  /**
28
- * Is value is a valid Date instance, then return that. If not, then return
26
+ * Is value is a valid Date instance, then return that. If not, then return
29
27
  * null.
30
28
  */
31
29
  export function asDate(value: mixed): Date | null {
32
- return isDate(value) ? ((value: cast): Date) : null;
30
+ //
31
+ // `x instanceof Date` checks are unreliable across stack frames (that
32
+ // information might get lost by the JS runtime), so we'll have to reside
33
+ // to more runtime inspection checks.
34
+ //
35
+ // Taken from https://stackoverflow.com/a/44198641
36
+ //
37
+ return !!value &&
38
+ // $FlowFixMe[method-unbinding]
39
+ Object.prototype.toString.call(value) === '[object Date]' &&
40
+ !isNaN(value)
41
+ ? ((value: _Any): Date)
42
+ : null;
33
43
  }
34
44
 
35
45
  export function isMultiline(s: string): boolean {
@@ -40,10 +50,10 @@ export function indent(s: string, prefix: string = INDENT): string {
40
50
  if (isMultiline(s)) {
41
51
  return s
42
52
  .split('\n')
43
- .map((line) => prefix + line)
53
+ .map((line) => `${prefix}${line}`)
44
54
  .join('\n');
45
55
  } else {
46
- return prefix + s;
56
+ return `${prefix}${s}`;
47
57
  }
48
58
  }
49
59
 
@@ -91,7 +101,7 @@ export function summarize(
91
101
  ? `Value at index ${keypath[0]}: `
92
102
  : `Value at key ${JSON.stringify(keypath[0])}: `;
93
103
  } else {
94
- prefix = `Value at keypath ${keypath.map((x) => x.toString()).join('.')}: `;
104
+ prefix = `Value at keypath ${keypath.map(String).join('.')}: `;
95
105
  }
96
- return [...result, prefix + text];
106
+ return [...result, `${prefix}${text}`];
97
107
  }
package/_utils.mjs CHANGED
@@ -1,93 +1,78 @@
1
- // $FlowFixMe[unclear-type] - deliberate casting
2
- // Two spaces of indentation
3
- export var INDENT = ' ';
4
- /**
5
- * `x instanceof Date` checks are unreliable across stack frames (that information
6
- * might get lost by the JS runtime), so we'll have to reside to more runtime
7
- * inspection checks.
8
- *
9
- * Taken from https://stackoverflow.com/a/44198641
10
- */
1
+ export var INDENT = ' '
11
2
 
12
- export function isDate(value) {
13
- return !!value && // $FlowFixMe[method-unbinding]
14
- Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value);
3
+ export function subtract(xs, ys) {
4
+ var result = new Set()
5
+ xs.forEach(function (x) {
6
+ if (!ys.has(x)) {
7
+ result.add(x)
8
+ }
9
+ })
10
+ return result
15
11
  }
16
- /**
17
- * Is value is a valid Date instance, then return that. If not, then return
18
- * null.
19
- */
20
12
 
21
13
  export function asDate(value) {
22
- return isDate(value) ? value : null;
14
+ return !!value && Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value) ? value : null
23
15
  }
24
16
  export function isMultiline(s) {
25
- return s.indexOf('\n') >= 0;
17
+ return s.indexOf('\n') >= 0
26
18
  }
27
19
  export function indent(s, prefix) {
28
20
  if (prefix === void 0) {
29
- prefix = INDENT;
21
+ prefix = INDENT
30
22
  }
31
23
 
32
24
  if (isMultiline(s)) {
33
- return s.split('\n').map(function (line) {
34
- return prefix + line;
35
- }).join('\n');
25
+ return s
26
+ .split('\n')
27
+ .map(function (line) {
28
+ return '' + prefix + line
29
+ })
30
+ .join('\n')
36
31
  } else {
37
- return prefix + s;
32
+ return '' + prefix + s
38
33
  }
39
34
  }
40
- /**
41
- * Walks the annotation tree and emits the annotation's key path within the
42
- * object tree, and the message as a series of messages (array of strings).
43
- */
44
35
 
45
36
  export function summarize(ann, keypath) {
46
37
  if (keypath === void 0) {
47
- keypath = [];
38
+ keypath = []
48
39
  }
49
40
 
50
- var result = [];
41
+ var result = []
51
42
 
52
43
  if (ann.type === 'array') {
53
- var items = ann.items;
54
- var index = 0;
44
+ var items = ann.items
45
+ var index = 0
55
46
  items.forEach(function (ann) {
56
47
  summarize(ann, [].concat(keypath, [index++])).forEach(function (item) {
57
- return (// Collect to results
58
- result.push(item)
59
- );
60
- });
61
- });
48
+ return result.push(item)
49
+ })
50
+ })
62
51
  } else if (ann.type === 'object') {
63
- var fields = ann.fields;
52
+ var fields = ann.fields
64
53
  Object.keys(fields).forEach(function (key) {
65
- var value = fields[key];
54
+ var value = fields[key]
66
55
  summarize(value, [].concat(keypath, [key])).forEach(function (item) {
67
- return (// Collect to results
68
- result.push(item)
69
- );
70
- });
71
- });
56
+ return result.push(item)
57
+ })
58
+ })
72
59
  }
73
60
 
74
- var text = ann.text;
61
+ var text = ann.text
75
62
 
76
63
  if (!text) {
77
- return result;
64
+ return result
78
65
  }
79
66
 
80
- var prefix;
67
+ var prefix
81
68
 
82
69
  if (keypath.length === 0) {
83
- prefix = '';
70
+ prefix = ''
84
71
  } else if (keypath.length === 1) {
85
- prefix = typeof keypath[0] === 'number' ? "Value at index " + keypath[0] + ": " : "Value at key " + JSON.stringify(keypath[0]) + ": ";
72
+ prefix = typeof keypath[0] === 'number' ? 'Value at index ' + keypath[0] + ': ' : 'Value at key ' + JSON.stringify(keypath[0]) + ': '
86
73
  } else {
87
- prefix = "Value at keypath " + keypath.map(function (x) {
88
- return x.toString();
89
- }).join('.') + ": ";
74
+ prefix = 'Value at keypath ' + keypath.map(String).join('.') + ': '
90
75
  }
91
76
 
92
- return [].concat(result, [prefix + text]);
93
- }
77
+ return [].concat(result, ['' + prefix + text])
78
+ }
package/annotate.js CHANGED
@@ -1,161 +1,168 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.__private_annotate = annotate;
5
- exports.annotate = public_annotate;
6
- exports.annotateObject = public_annotateObject;
7
- exports.array = array;
8
- exports.asAnnotation = asAnnotation;
9
- exports.circularRef = circularRef;
10
- exports.func = func;
11
- exports.merge = merge;
12
- exports.object = object;
13
- exports.scalar = scalar;
14
- exports.unknown = unknown;
15
- exports.updateText = updateText;
16
-
17
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
-
19
- var _register = new WeakSet();
1
+ 'use strict'
2
+
3
+ exports.__esModule = true
4
+ exports.__private_annotate = annotate
5
+ exports.annotate = public_annotate
6
+ exports.annotateObject = public_annotateObject
7
+ exports.array = array
8
+ exports.asAnnotation = asAnnotation
9
+ exports.circularRef = circularRef
10
+ exports.func = func
11
+ exports.merge = merge
12
+ exports.object = object
13
+ exports.scalar = scalar
14
+ exports.unknown = unknown
15
+ exports.updateText = updateText
16
+
17
+ function _extends() {
18
+ _extends = Object.assign
19
+ ? Object.assign.bind()
20
+ : function (target) {
21
+ for (var i = 1; i < arguments.length; i++) {
22
+ var source = arguments[i]
23
+ for (var key in source) {
24
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
25
+ target[key] = source[key]
26
+ }
27
+ }
28
+ }
29
+ return target
30
+ }
31
+ return _extends.apply(this, arguments)
32
+ }
33
+
34
+ var _register = new WeakSet()
20
35
 
21
36
  function brand(ann) {
22
- _register.add(ann);
37
+ _register.add(ann)
23
38
 
24
- return ann;
39
+ return ann
25
40
  }
26
41
 
27
42
  function object(fields, text) {
28
43
  return brand({
29
44
  type: 'object',
30
45
  fields: fields,
31
- text: text
32
- });
46
+ text: text,
47
+ })
33
48
  }
34
49
 
35
50
  function array(items, text) {
36
51
  return brand({
37
52
  type: 'array',
38
53
  items: items,
39
- text: text
40
- });
54
+ text: text,
55
+ })
41
56
  }
42
57
 
43
58
  function func(text) {
44
59
  return brand({
45
60
  type: 'function',
46
- text: text
47
- });
61
+ text: text,
62
+ })
48
63
  }
49
64
 
50
65
  function unknown(value, text) {
51
66
  return brand({
52
67
  type: 'unknown',
53
68
  value: value,
54
- text: text
55
- });
69
+ text: text,
70
+ })
56
71
  }
57
72
 
58
73
  function scalar(value, text) {
59
74
  return brand({
60
75
  type: 'scalar',
61
76
  value: value,
62
- text: text
63
- });
77
+ text: text,
78
+ })
64
79
  }
65
80
 
66
81
  function circularRef(text) {
67
82
  return brand({
68
83
  type: 'circular-ref',
69
- text: text
70
- });
84
+ text: text,
85
+ })
71
86
  }
72
- /**
73
- * Given an existing Annotation, set the annotation's text to a new value.
74
- */
75
-
76
87
 
77
88
  function updateText(annotation, text) {
78
89
  if (text !== undefined) {
79
- return brand(_extends({}, annotation, {
80
- text: text
81
- }));
90
+ return brand(
91
+ _extends({}, annotation, {
92
+ text: text,
93
+ })
94
+ )
82
95
  } else {
83
- return annotation;
96
+ return annotation
84
97
  }
85
98
  }
86
- /**
87
- * Given an existing ObjectAnnotation, merges new Annotations in there.
88
- */
89
-
90
99
 
91
100
  function merge(objAnnotation, fields) {
92
- var newFields = _extends({}, objAnnotation.fields, fields);
101
+ var newFields = _extends({}, objAnnotation.fields, fields)
93
102
 
94
- return object(newFields, objAnnotation.text);
103
+ return object(newFields, objAnnotation.text)
95
104
  }
96
105
 
97
106
  function asAnnotation(thing) {
98
- return typeof thing === 'object' && thing !== null && _register.has(thing) ? thing : undefined;
107
+ return typeof thing === 'object' && thing !== null && _register.has(thing) ? thing : undefined
99
108
  }
100
109
 
101
110
  function annotateArray(value, text, seen) {
102
- seen.add(value);
111
+ seen.add(value)
103
112
  var items = value.map(function (v) {
104
- return annotate(v, undefined, seen);
105
- });
106
- return array(items, text);
113
+ return annotate(v, undefined, seen)
114
+ })
115
+ return array(items, text)
107
116
  }
108
117
 
109
118
  function annotateObject(obj, text, seen) {
110
- seen.add(obj);
111
- var fields = {};
119
+ seen.add(obj)
120
+ var fields = {}
112
121
  Object.keys(obj).forEach(function (key) {
113
- var value = obj[key];
114
- fields[key] = annotate(value, undefined, seen);
115
- });
116
- return object(fields, text);
122
+ var value = obj[key]
123
+ fields[key] = annotate(value, undefined, seen)
124
+ })
125
+ return object(fields, text)
117
126
  }
118
127
 
119
128
  function annotate(value, text, seen) {
120
129
  if (value === null || value === undefined || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || typeof value === 'symbol' || typeof value.getMonth === 'function') {
121
- return scalar(value, text);
130
+ return scalar(value, text)
122
131
  }
123
132
 
124
- var ann = asAnnotation(value);
133
+ var ann = asAnnotation(value)
125
134
 
126
135
  if (ann) {
127
- return updateText(ann, text);
136
+ return updateText(ann, text)
128
137
  }
129
138
 
130
139
  if (Array.isArray(value)) {
131
- // "Circular references" can only exist in objects or arrays
132
140
  if (seen.has(value)) {
133
- return circularRef(text);
141
+ return circularRef(text)
134
142
  } else {
135
- return annotateArray(value, text, seen);
143
+ return annotateArray(value, text, seen)
136
144
  }
137
145
  }
138
146
 
139
147
  if (typeof value === 'object') {
140
- // "Circular references" can only exist in objects or arrays
141
148
  if (seen.has(value)) {
142
- return circularRef(text);
149
+ return circularRef(text)
143
150
  } else {
144
- return annotateObject(value, text, seen);
151
+ return annotateObject(value, text, seen)
145
152
  }
146
153
  }
147
154
 
148
155
  if (typeof value === 'function') {
149
- return func(text);
156
+ return func(text)
150
157
  }
151
158
 
152
- return unknown(value, text);
159
+ return unknown(value, text)
153
160
  }
154
161
 
155
162
  function public_annotate(value, text) {
156
- return annotate(value, text, new WeakSet());
163
+ return annotate(value, text, new WeakSet())
157
164
  }
158
165
 
159
166
  function public_annotateObject(obj, text) {
160
- return annotateObject(obj, text, new WeakSet());
161
- }
167
+ return annotateObject(obj, text, new WeakSet())
168
+ }