poe-code 12.0.11 → 13.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 (138) hide show
  1. package/dist/index.js +6 -3
  2. package/dist/index.js.map +2 -2
  3. package/dist/metafile.json +1 -1
  4. package/node_modules/esprima/LICENSE.BSD +21 -0
  5. package/node_modules/esprima/README.md +46 -0
  6. package/node_modules/esprima/bin/esparse.js +139 -0
  7. package/node_modules/esprima/bin/esvalidate.js +236 -0
  8. package/node_modules/esprima/dist/esprima.js +6709 -0
  9. package/node_modules/esprima/package.json +112 -0
  10. package/node_modules/extend-shallow/LICENSE +21 -0
  11. package/node_modules/extend-shallow/README.md +61 -0
  12. package/node_modules/extend-shallow/index.js +33 -0
  13. package/node_modules/extend-shallow/package.json +56 -0
  14. package/node_modules/gray-matter/LICENSE +21 -0
  15. package/node_modules/gray-matter/README.md +565 -0
  16. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  17. package/node_modules/gray-matter/index.js +228 -0
  18. package/node_modules/gray-matter/lib/defaults.js +18 -0
  19. package/node_modules/gray-matter/lib/engine.js +30 -0
  20. package/node_modules/gray-matter/lib/engines.js +54 -0
  21. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  22. package/node_modules/gray-matter/lib/parse.js +13 -0
  23. package/node_modules/gray-matter/lib/stringify.js +56 -0
  24. package/node_modules/gray-matter/lib/to-file.js +43 -0
  25. package/node_modules/gray-matter/lib/utils.js +66 -0
  26. package/node_modules/gray-matter/node_modules/argparse/LICENSE +21 -0
  27. package/node_modules/gray-matter/node_modules/argparse/README.md +257 -0
  28. package/node_modules/gray-matter/node_modules/argparse/index.js +3 -0
  29. package/node_modules/gray-matter/node_modules/argparse/lib/action/append/constant.js +47 -0
  30. package/node_modules/gray-matter/node_modules/argparse/lib/action/append.js +53 -0
  31. package/node_modules/gray-matter/node_modules/argparse/lib/action/count.js +40 -0
  32. package/node_modules/gray-matter/node_modules/argparse/lib/action/help.js +47 -0
  33. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/constant.js +43 -0
  34. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/false.js +27 -0
  35. package/node_modules/gray-matter/node_modules/argparse/lib/action/store/true.js +26 -0
  36. package/node_modules/gray-matter/node_modules/argparse/lib/action/store.js +50 -0
  37. package/node_modules/gray-matter/node_modules/argparse/lib/action/subparsers.js +149 -0
  38. package/node_modules/gray-matter/node_modules/argparse/lib/action/version.js +47 -0
  39. package/node_modules/gray-matter/node_modules/argparse/lib/action.js +146 -0
  40. package/node_modules/gray-matter/node_modules/argparse/lib/action_container.js +482 -0
  41. package/node_modules/gray-matter/node_modules/argparse/lib/argparse.js +14 -0
  42. package/node_modules/gray-matter/node_modules/argparse/lib/argument/error.js +50 -0
  43. package/node_modules/gray-matter/node_modules/argparse/lib/argument/exclusive.js +54 -0
  44. package/node_modules/gray-matter/node_modules/argparse/lib/argument/group.js +75 -0
  45. package/node_modules/gray-matter/node_modules/argparse/lib/argument_parser.js +1161 -0
  46. package/node_modules/gray-matter/node_modules/argparse/lib/const.js +21 -0
  47. package/node_modules/gray-matter/node_modules/argparse/lib/help/added_formatters.js +87 -0
  48. package/node_modules/gray-matter/node_modules/argparse/lib/help/formatter.js +795 -0
  49. package/node_modules/gray-matter/node_modules/argparse/lib/namespace.js +76 -0
  50. package/node_modules/gray-matter/node_modules/argparse/lib/utils.js +57 -0
  51. package/node_modules/gray-matter/node_modules/argparse/package.json +34 -0
  52. package/node_modules/gray-matter/node_modules/js-yaml/LICENSE +21 -0
  53. package/node_modules/gray-matter/node_modules/js-yaml/README.md +302 -0
  54. package/node_modules/gray-matter/node_modules/js-yaml/bin/js-yaml.js +132 -0
  55. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.js +4011 -0
  56. package/node_modules/gray-matter/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  57. package/node_modules/gray-matter/node_modules/js-yaml/index.js +7 -0
  58. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  59. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  60. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  61. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js +1666 -0
  62. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  63. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  64. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  65. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  66. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  67. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  68. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  69. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  70. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  71. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  72. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  73. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  74. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  75. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  76. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  77. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  78. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  79. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  80. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  81. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  82. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  83. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  84. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  85. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  86. package/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml.js +39 -0
  87. package/node_modules/gray-matter/node_modules/js-yaml/package.json +52 -0
  88. package/node_modules/gray-matter/package.json +127 -0
  89. package/node_modules/is-extendable/LICENSE +21 -0
  90. package/node_modules/is-extendable/README.md +72 -0
  91. package/node_modules/is-extendable/index.js +13 -0
  92. package/node_modules/is-extendable/package.json +51 -0
  93. package/node_modules/kind-of/LICENSE +21 -0
  94. package/node_modules/kind-of/README.md +367 -0
  95. package/node_modules/kind-of/index.js +129 -0
  96. package/node_modules/kind-of/package.json +88 -0
  97. package/node_modules/section-matter/LICENSE +21 -0
  98. package/node_modules/section-matter/README.md +236 -0
  99. package/node_modules/section-matter/index.js +136 -0
  100. package/node_modules/section-matter/package.json +55 -0
  101. package/node_modules/sprintf-js/.npmignore +1 -0
  102. package/node_modules/sprintf-js/LICENSE +24 -0
  103. package/node_modules/sprintf-js/README.md +88 -0
  104. package/node_modules/sprintf-js/bower.json +14 -0
  105. package/node_modules/sprintf-js/demo/angular.html +20 -0
  106. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  107. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  108. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  109. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  110. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  111. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  112. package/node_modules/sprintf-js/gruntfile.js +36 -0
  113. package/node_modules/sprintf-js/package.json +22 -0
  114. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  115. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  116. package/node_modules/sprintf-js/test/test.js +82 -0
  117. package/node_modules/strip-bom-string/LICENSE +21 -0
  118. package/node_modules/strip-bom-string/README.md +66 -0
  119. package/node_modules/strip-bom-string/index.js +15 -0
  120. package/node_modules/strip-bom-string/package.json +60 -0
  121. package/package.json +6 -3
  122. package/packages/safe-fs/dist/fs/webdav/webdav.d.ts +2 -0
  123. package/packages/safe-js/dist/browser/chunks/{chunk-MUKMA7ZY.js → chunk-GJWMQ42Z.js} +35 -2
  124. package/packages/safe-js/dist/browser/chunks/{chunk-MUKMA7ZY.js.map → chunk-GJWMQ42Z.js.map} +2 -2
  125. package/packages/safe-js/dist/browser/safe-fs-core.js +1 -1
  126. package/packages/safe-js/dist/browser/safe-fs.js +1 -1
  127. package/packages/safe-js/dist/chunks/{chunk-HCODJUGF.js → chunk-EL23VF23.js} +3 -3
  128. package/packages/safe-js/dist/chunks/{chunk-YBQUQPZV.js → chunk-WVN5MMDR.js} +35 -2
  129. package/packages/safe-js/dist/chunks/chunk-WVN5MMDR.js.map +7 -0
  130. package/packages/safe-js/dist/chunks/{chunk-F7NY24BF.js → chunk-ZRX5HT5L.js} +2 -2
  131. package/packages/safe-js/dist/cli.js +3 -3
  132. package/packages/safe-js/dist/index.js +3 -3
  133. package/packages/safe-js/dist/safe-fs-core.js +1 -1
  134. package/packages/safe-js/dist/safe-fs-node.js +2 -2
  135. package/packages/safe-js/dist/safe-fs.js +2 -2
  136. package/packages/safe-js/dist/chunks/chunk-YBQUQPZV.js.map +0 -7
  137. /package/packages/safe-js/dist/chunks/{chunk-HCODJUGF.js.map → chunk-EL23VF23.js.map} +0 -0
  138. /package/packages/safe-js/dist/chunks/{chunk-F7NY24BF.js.map → chunk-ZRX5HT5L.js.map} +0 -0
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+
4
+ var common = require('./common');
5
+
6
+
7
+ function Mark(name, buffer, position, line, column) {
8
+ this.name = name;
9
+ this.buffer = buffer;
10
+ this.position = position;
11
+ this.line = line;
12
+ this.column = column;
13
+ }
14
+
15
+
16
+ Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
17
+ var head, start, tail, end, snippet;
18
+
19
+ if (!this.buffer) return null;
20
+
21
+ indent = indent || 4;
22
+ maxLength = maxLength || 75;
23
+
24
+ head = '';
25
+ start = this.position;
26
+
27
+ while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
28
+ start -= 1;
29
+ if (this.position - start > (maxLength / 2 - 1)) {
30
+ head = ' ... ';
31
+ start += 5;
32
+ break;
33
+ }
34
+ }
35
+
36
+ tail = '';
37
+ end = this.position;
38
+
39
+ while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
40
+ end += 1;
41
+ if (end - this.position > (maxLength / 2 - 1)) {
42
+ tail = ' ... ';
43
+ end -= 5;
44
+ break;
45
+ }
46
+ }
47
+
48
+ snippet = this.buffer.slice(start, end);
49
+
50
+ return common.repeat(' ', indent) + head + snippet + tail + '\n' +
51
+ common.repeat(' ', indent + this.position - start + head.length) + '^';
52
+ };
53
+
54
+
55
+ Mark.prototype.toString = function toString(compact) {
56
+ var snippet, where = '';
57
+
58
+ if (this.name) {
59
+ where += 'in "' + this.name + '" ';
60
+ }
61
+
62
+ where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
63
+
64
+ if (!compact) {
65
+ snippet = this.getSnippet();
66
+
67
+ if (snippet) {
68
+ where += ':\n' + snippet;
69
+ }
70
+ }
71
+
72
+ return where;
73
+ };
74
+
75
+
76
+ module.exports = Mark;
@@ -0,0 +1,18 @@
1
+ // Standard YAML's Core schema.
2
+ // http://www.yaml.org/spec/1.2/spec.html#id2804923
3
+ //
4
+ // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
5
+ // So, Core schema has no distinctions from JSON schema is JS-YAML.
6
+
7
+
8
+ 'use strict';
9
+
10
+
11
+ var Schema = require('../schema');
12
+
13
+
14
+ module.exports = new Schema({
15
+ include: [
16
+ require('./json')
17
+ ]
18
+ });
@@ -0,0 +1,25 @@
1
+ // JS-YAML's default schema for `load` function.
2
+ // It is not described in the YAML specification.
3
+ //
4
+ // This schema is based on JS-YAML's default safe schema and includes
5
+ // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
6
+ //
7
+ // Also this schema is used as default base schema at `Schema.create` function.
8
+
9
+
10
+ 'use strict';
11
+
12
+
13
+ var Schema = require('../schema');
14
+
15
+
16
+ module.exports = Schema.DEFAULT = new Schema({
17
+ include: [
18
+ require('./default_safe')
19
+ ],
20
+ explicit: [
21
+ require('../type/js/undefined'),
22
+ require('../type/js/regexp'),
23
+ require('../type/js/function')
24
+ ]
25
+ });
@@ -0,0 +1,28 @@
1
+ // JS-YAML's default schema for `safeLoad` function.
2
+ // It is not described in the YAML specification.
3
+ //
4
+ // This schema is based on standard YAML's Core schema and includes most of
5
+ // extra types described at YAML tag repository. (http://yaml.org/type/)
6
+
7
+
8
+ 'use strict';
9
+
10
+
11
+ var Schema = require('../schema');
12
+
13
+
14
+ module.exports = new Schema({
15
+ include: [
16
+ require('./core')
17
+ ],
18
+ implicit: [
19
+ require('../type/timestamp'),
20
+ require('../type/merge')
21
+ ],
22
+ explicit: [
23
+ require('../type/binary'),
24
+ require('../type/omap'),
25
+ require('../type/pairs'),
26
+ require('../type/set')
27
+ ]
28
+ });
@@ -0,0 +1,17 @@
1
+ // Standard YAML's Failsafe schema.
2
+ // http://www.yaml.org/spec/1.2/spec.html#id2802346
3
+
4
+
5
+ 'use strict';
6
+
7
+
8
+ var Schema = require('../schema');
9
+
10
+
11
+ module.exports = new Schema({
12
+ explicit: [
13
+ require('../type/str'),
14
+ require('../type/seq'),
15
+ require('../type/map')
16
+ ]
17
+ });
@@ -0,0 +1,25 @@
1
+ // Standard YAML's JSON schema.
2
+ // http://www.yaml.org/spec/1.2/spec.html#id2803231
3
+ //
4
+ // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
5
+ // So, this schema is not such strict as defined in the YAML specification.
6
+ // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
7
+
8
+
9
+ 'use strict';
10
+
11
+
12
+ var Schema = require('../schema');
13
+
14
+
15
+ module.exports = new Schema({
16
+ include: [
17
+ require('./failsafe')
18
+ ],
19
+ implicit: [
20
+ require('../type/null'),
21
+ require('../type/bool'),
22
+ require('../type/int'),
23
+ require('../type/float')
24
+ ]
25
+ });
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ /*eslint-disable max-len*/
4
+
5
+ var common = require('./common');
6
+ var YAMLException = require('./exception');
7
+ var Type = require('./type');
8
+
9
+
10
+ function compileList(schema, name, result) {
11
+ var exclude = [];
12
+
13
+ schema.include.forEach(function (includedSchema) {
14
+ result = compileList(includedSchema, name, result);
15
+ });
16
+
17
+ schema[name].forEach(function (currentType) {
18
+ result.forEach(function (previousType, previousIndex) {
19
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
20
+ exclude.push(previousIndex);
21
+ }
22
+ });
23
+
24
+ result.push(currentType);
25
+ });
26
+
27
+ return result.filter(function (type, index) {
28
+ return exclude.indexOf(index) === -1;
29
+ });
30
+ }
31
+
32
+
33
+ function compileMap(/* lists... */) {
34
+ var result = {
35
+ scalar: {},
36
+ sequence: {},
37
+ mapping: {},
38
+ fallback: {}
39
+ }, index, length;
40
+
41
+ function collectType(type) {
42
+ result[type.kind][type.tag] = result['fallback'][type.tag] = type;
43
+ }
44
+
45
+ for (index = 0, length = arguments.length; index < length; index += 1) {
46
+ arguments[index].forEach(collectType);
47
+ }
48
+ return result;
49
+ }
50
+
51
+
52
+ function Schema(definition) {
53
+ this.include = definition.include || [];
54
+ this.implicit = definition.implicit || [];
55
+ this.explicit = definition.explicit || [];
56
+
57
+ this.implicit.forEach(function (type) {
58
+ if (type.loadKind && type.loadKind !== 'scalar') {
59
+ throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
60
+ }
61
+ });
62
+
63
+ this.compiledImplicit = compileList(this, 'implicit', []);
64
+ this.compiledExplicit = compileList(this, 'explicit', []);
65
+ this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
66
+ }
67
+
68
+
69
+ Schema.DEFAULT = null;
70
+
71
+
72
+ Schema.create = function createSchema() {
73
+ var schemas, types;
74
+
75
+ switch (arguments.length) {
76
+ case 1:
77
+ schemas = Schema.DEFAULT;
78
+ types = arguments[0];
79
+ break;
80
+
81
+ case 2:
82
+ schemas = arguments[0];
83
+ types = arguments[1];
84
+ break;
85
+
86
+ default:
87
+ throw new YAMLException('Wrong number of arguments for Schema.create function');
88
+ }
89
+
90
+ schemas = common.toArray(schemas);
91
+ types = common.toArray(types);
92
+
93
+ if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
94
+ throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
95
+ }
96
+
97
+ if (!types.every(function (type) { return type instanceof Type; })) {
98
+ throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
99
+ }
100
+
101
+ return new Schema({
102
+ include: schemas,
103
+ explicit: types
104
+ });
105
+ };
106
+
107
+
108
+ module.exports = Schema;
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ /*eslint-disable no-bitwise*/
4
+
5
+ var NodeBuffer;
6
+
7
+ try {
8
+ // A trick for browserified version, to not include `Buffer` shim
9
+ var _require = require;
10
+ NodeBuffer = _require('buffer').Buffer;
11
+ } catch (__) {}
12
+
13
+ var Type = require('../type');
14
+
15
+
16
+ // [ 64, 65, 66 ] -> [ padding, CR, LF ]
17
+ var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
18
+
19
+
20
+ function resolveYamlBinary(data) {
21
+ if (data === null) return false;
22
+
23
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
24
+
25
+ // Convert one by one.
26
+ for (idx = 0; idx < max; idx++) {
27
+ code = map.indexOf(data.charAt(idx));
28
+
29
+ // Skip CR/LF
30
+ if (code > 64) continue;
31
+
32
+ // Fail on illegal characters
33
+ if (code < 0) return false;
34
+
35
+ bitlen += 6;
36
+ }
37
+
38
+ // If there are any bits left, source was corrupted
39
+ return (bitlen % 8) === 0;
40
+ }
41
+
42
+ function constructYamlBinary(data) {
43
+ var idx, tailbits,
44
+ input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
45
+ max = input.length,
46
+ map = BASE64_MAP,
47
+ bits = 0,
48
+ result = [];
49
+
50
+ // Collect by 6*4 bits (3 bytes)
51
+
52
+ for (idx = 0; idx < max; idx++) {
53
+ if ((idx % 4 === 0) && idx) {
54
+ result.push((bits >> 16) & 0xFF);
55
+ result.push((bits >> 8) & 0xFF);
56
+ result.push(bits & 0xFF);
57
+ }
58
+
59
+ bits = (bits << 6) | map.indexOf(input.charAt(idx));
60
+ }
61
+
62
+ // Dump tail
63
+
64
+ tailbits = (max % 4) * 6;
65
+
66
+ if (tailbits === 0) {
67
+ result.push((bits >> 16) & 0xFF);
68
+ result.push((bits >> 8) & 0xFF);
69
+ result.push(bits & 0xFF);
70
+ } else if (tailbits === 18) {
71
+ result.push((bits >> 10) & 0xFF);
72
+ result.push((bits >> 2) & 0xFF);
73
+ } else if (tailbits === 12) {
74
+ result.push((bits >> 4) & 0xFF);
75
+ }
76
+
77
+ // Wrap into Buffer for NodeJS and leave Array for browser
78
+ if (NodeBuffer) {
79
+ // Support node 6.+ Buffer API when available
80
+ return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
81
+ }
82
+
83
+ return result;
84
+ }
85
+
86
+ function representYamlBinary(object /*, style*/) {
87
+ var result = '', bits = 0, idx, tail,
88
+ max = object.length,
89
+ map = BASE64_MAP;
90
+
91
+ // Convert every three bytes to 4 ASCII characters.
92
+
93
+ for (idx = 0; idx < max; idx++) {
94
+ if ((idx % 3 === 0) && idx) {
95
+ result += map[(bits >> 18) & 0x3F];
96
+ result += map[(bits >> 12) & 0x3F];
97
+ result += map[(bits >> 6) & 0x3F];
98
+ result += map[bits & 0x3F];
99
+ }
100
+
101
+ bits = (bits << 8) + object[idx];
102
+ }
103
+
104
+ // Dump tail
105
+
106
+ tail = max % 3;
107
+
108
+ if (tail === 0) {
109
+ result += map[(bits >> 18) & 0x3F];
110
+ result += map[(bits >> 12) & 0x3F];
111
+ result += map[(bits >> 6) & 0x3F];
112
+ result += map[bits & 0x3F];
113
+ } else if (tail === 2) {
114
+ result += map[(bits >> 10) & 0x3F];
115
+ result += map[(bits >> 4) & 0x3F];
116
+ result += map[(bits << 2) & 0x3F];
117
+ result += map[64];
118
+ } else if (tail === 1) {
119
+ result += map[(bits >> 2) & 0x3F];
120
+ result += map[(bits << 4) & 0x3F];
121
+ result += map[64];
122
+ result += map[64];
123
+ }
124
+
125
+ return result;
126
+ }
127
+
128
+ function isBinary(object) {
129
+ return NodeBuffer && NodeBuffer.isBuffer(object);
130
+ }
131
+
132
+ module.exports = new Type('tag:yaml.org,2002:binary', {
133
+ kind: 'scalar',
134
+ resolve: resolveYamlBinary,
135
+ construct: constructYamlBinary,
136
+ predicate: isBinary,
137
+ represent: representYamlBinary
138
+ });
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var Type = require('../type');
4
+
5
+ function resolveYamlBoolean(data) {
6
+ if (data === null) return false;
7
+
8
+ var max = data.length;
9
+
10
+ return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
11
+ (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
12
+ }
13
+
14
+ function constructYamlBoolean(data) {
15
+ return data === 'true' ||
16
+ data === 'True' ||
17
+ data === 'TRUE';
18
+ }
19
+
20
+ function isBoolean(object) {
21
+ return Object.prototype.toString.call(object) === '[object Boolean]';
22
+ }
23
+
24
+ module.exports = new Type('tag:yaml.org,2002:bool', {
25
+ kind: 'scalar',
26
+ resolve: resolveYamlBoolean,
27
+ construct: constructYamlBoolean,
28
+ predicate: isBoolean,
29
+ represent: {
30
+ lowercase: function (object) { return object ? 'true' : 'false'; },
31
+ uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
32
+ camelcase: function (object) { return object ? 'True' : 'False'; }
33
+ },
34
+ defaultStyle: 'lowercase'
35
+ });
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ var common = require('../common');
4
+ var Type = require('../type');
5
+
6
+ var YAML_FLOAT_PATTERN = new RegExp(
7
+ // 2.5e4, 2.5 and integers
8
+ '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
9
+ // .2e4, .2
10
+ // special case, seems not from spec
11
+ '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
12
+ // 20:59
13
+ '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
14
+ // .inf
15
+ '|[-+]?\\.(?:inf|Inf|INF)' +
16
+ // .nan
17
+ '|\\.(?:nan|NaN|NAN))$');
18
+
19
+ function resolveYamlFloat(data) {
20
+ if (data === null) return false;
21
+
22
+ if (!YAML_FLOAT_PATTERN.test(data) ||
23
+ // Quick hack to not allow integers end with `_`
24
+ // Probably should update regexp & check speed
25
+ data[data.length - 1] === '_') {
26
+ return false;
27
+ }
28
+
29
+ return true;
30
+ }
31
+
32
+ function constructYamlFloat(data) {
33
+ var value, sign, base, digits;
34
+
35
+ value = data.replace(/_/g, '').toLowerCase();
36
+ sign = value[0] === '-' ? -1 : 1;
37
+ digits = [];
38
+
39
+ if ('+-'.indexOf(value[0]) >= 0) {
40
+ value = value.slice(1);
41
+ }
42
+
43
+ if (value === '.inf') {
44
+ return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
45
+
46
+ } else if (value === '.nan') {
47
+ return NaN;
48
+
49
+ } else if (value.indexOf(':') >= 0) {
50
+ value.split(':').forEach(function (v) {
51
+ digits.unshift(parseFloat(v, 10));
52
+ });
53
+
54
+ value = 0.0;
55
+ base = 1;
56
+
57
+ digits.forEach(function (d) {
58
+ value += d * base;
59
+ base *= 60;
60
+ });
61
+
62
+ return sign * value;
63
+
64
+ }
65
+ return sign * parseFloat(value, 10);
66
+ }
67
+
68
+
69
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
70
+
71
+ function representYamlFloat(object, style) {
72
+ var res;
73
+
74
+ if (isNaN(object)) {
75
+ switch (style) {
76
+ case 'lowercase': return '.nan';
77
+ case 'uppercase': return '.NAN';
78
+ case 'camelcase': return '.NaN';
79
+ }
80
+ } else if (Number.POSITIVE_INFINITY === object) {
81
+ switch (style) {
82
+ case 'lowercase': return '.inf';
83
+ case 'uppercase': return '.INF';
84
+ case 'camelcase': return '.Inf';
85
+ }
86
+ } else if (Number.NEGATIVE_INFINITY === object) {
87
+ switch (style) {
88
+ case 'lowercase': return '-.inf';
89
+ case 'uppercase': return '-.INF';
90
+ case 'camelcase': return '-.Inf';
91
+ }
92
+ } else if (common.isNegativeZero(object)) {
93
+ return '-0.0';
94
+ }
95
+
96
+ res = object.toString(10);
97
+
98
+ // JS stringifier can build scientific format without dots: 5e-100,
99
+ // while YAML requres dot: 5.e-100. Fix it with simple hack
100
+
101
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
102
+ }
103
+
104
+ function isFloat(object) {
105
+ return (Object.prototype.toString.call(object) === '[object Number]') &&
106
+ (object % 1 !== 0 || common.isNegativeZero(object));
107
+ }
108
+
109
+ module.exports = new Type('tag:yaml.org,2002:float', {
110
+ kind: 'scalar',
111
+ resolve: resolveYamlFloat,
112
+ construct: constructYamlFloat,
113
+ predicate: isFloat,
114
+ represent: representYamlFloat,
115
+ defaultStyle: 'lowercase'
116
+ });