yaml 1.8.2 → 1.8.3

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.
@@ -99,7 +99,7 @@ export var expObj = {
99
99
  default: true,
100
100
  tag: 'tag:yaml.org,2002:float',
101
101
  format: 'EXP',
102
- test: /^[-+]?(?:0|[1-9][0-9]*)(\.[0-9]*)?[eE][-+]?[0-9]+$/,
102
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
103
103
  resolve: function resolve(str) {
104
104
  return parseFloat(str);
105
105
  },
@@ -114,8 +114,9 @@ export var floatObj = {
114
114
  },
115
115
  default: true,
116
116
  tag: 'tag:yaml.org,2002:float',
117
- test: /^[-+]?(?:0|[1-9][0-9]*)\.([0-9]*)$/,
118
- resolve: function resolve(str, frac) {
117
+ test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
118
+ resolve: function resolve(str, frac1, frac2) {
119
+ var frac = frac1 || frac2;
119
120
  var node = new Scalar(parseFloat(str));
120
121
  if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
121
122
  return node;
@@ -21,21 +21,23 @@ export default {
21
21
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
22
22
  */
23
23
  resolve: function resolve(doc, node) {
24
+ var src = resolveString(doc, node);
25
+
24
26
  if (typeof Buffer === 'function') {
25
- var src = resolveString(doc, node);
26
27
  return Buffer.from(src, 'base64');
27
28
  } else if (typeof atob === 'function') {
28
- var _src = atob(resolveString(doc, node));
29
-
30
- var buffer = new Uint8Array(_src.length);
29
+ // On IE 11, atob() can't handle newlines
30
+ var str = atob(src.replace(/[\n\r]/g, ''));
31
+ var buffer = new Uint8Array(str.length);
31
32
 
32
- for (var i = 0; i < _src.length; ++i) {
33
- buffer[i] = _src.charCodeAt(i);
33
+ for (var i = 0; i < str.length; ++i) {
34
+ buffer[i] = str.charCodeAt(i);
34
35
  }
35
36
 
36
37
  return buffer;
37
38
  } else {
38
- doc.errors.push(new YAMLReferenceError(node, 'This environment does not support reading binary tags; either Buffer or atob is required'));
39
+ var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
40
+ doc.errors.push(new YAMLReferenceError(node, msg));
39
41
  return null;
40
42
  }
41
43
  },
package/dist/tags/core.js CHANGED
@@ -85,7 +85,7 @@ const expObj = {
85
85
  default: true,
86
86
  tag: 'tag:yaml.org,2002:float',
87
87
  format: 'EXP',
88
- test: /^[-+]?(?:0|[1-9][0-9]*)(\.[0-9]*)?[eE][-+]?[0-9]+$/,
88
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
89
89
  resolve: str => parseFloat(str),
90
90
  stringify: ({
91
91
  value
@@ -96,9 +96,10 @@ const floatObj = {
96
96
  identify: value => typeof value === 'number',
97
97
  default: true,
98
98
  tag: 'tag:yaml.org,2002:float',
99
- test: /^[-+]?(?:0|[1-9][0-9]*)\.([0-9]*)$/,
99
+ test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
100
100
 
101
- resolve(str, frac) {
101
+ resolve(str, frac1, frac2) {
102
+ const frac = frac1 || frac2;
102
103
  const node = new _Scalar.default(parseFloat(str));
103
104
  if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
104
105
  return node;
@@ -31,18 +31,21 @@ var _default = {
31
31
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
32
32
  */
33
33
  resolve: (doc, node) => {
34
+ const src = (0, _string.resolveString)(doc, node);
35
+
34
36
  if (typeof Buffer === 'function') {
35
- const src = (0, _string.resolveString)(doc, node);
36
37
  return Buffer.from(src, 'base64');
37
38
  } else if (typeof atob === 'function') {
38
- const src = atob((0, _string.resolveString)(doc, node));
39
- const buffer = new Uint8Array(src.length);
39
+ // On IE 11, atob() can't handle newlines
40
+ const str = atob(src.replace(/[\n\r]/g, ''));
41
+ const buffer = new Uint8Array(str.length);
40
42
 
41
- for (let i = 0; i < src.length; ++i) buffer[i] = src.charCodeAt(i);
43
+ for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
42
44
 
43
45
  return buffer;
44
46
  } else {
45
- doc.errors.push(new _errors.YAMLReferenceError(node, 'This environment does not support reading binary tags; either Buffer or atob is required'));
47
+ const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
48
+ doc.errors.push(new _errors.YAMLReferenceError(node, msg));
46
49
  return null;
47
50
  }
48
51
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",
@@ -30,12 +30,14 @@
30
30
  "./schema.js": "./browser/schema.js",
31
31
  "./seq.js": "./browser/seq.js",
32
32
  "./types.js": "./browser/types.js",
33
+ "./types.mjs": "./browser/types.js",
33
34
  "./types/binary.js": "./browser/types/binary.js",
34
35
  "./types/omap.js": "./browser/types/omap.js",
35
36
  "./types/pairs.js": "./browser/types/pairs.js",
36
37
  "./types/set.js": "./browser/types/set.js",
37
38
  "./types/timestamp.js": "./browser/types/timestamp.js",
38
- "./util.js": "./browser/util.js"
39
+ "./util.js": "./browser/util.js",
40
+ "./util.mjs": "./browser/util.js"
39
41
  },
40
42
  "exports": {
41
43
  ".": "./index.js",