Comparing version 3.3.0 to 3.3.1
@@ -0,1 +1,8 @@ | ||
3.3.1 / 2015-05-13 | ||
------------------ | ||
- Added `.sortKeys` dumper option, thanks to @rjmunro. | ||
- Fixed astral characters support, #191. | ||
3.3.0 / 2015-04-26 | ||
@@ -2,0 +9,0 @@ ------------------ |
@@ -82,19 +82,19 @@ 'use strict'; | ||
// do not execute the following if file is required (http://stackoverflow.com/a/6398335) | ||
if (require.main === module) { | ||
// And read a document using that schema. | ||
// And read a document using that schema. | ||
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) { | ||
var loaded; | ||
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) { | ||
var loaded; | ||
if (!error) { | ||
loaded = yaml.load(data, { schema: SPACE_SCHEMA }); | ||
console.log(util.inspect(loaded, false, 20, true)); | ||
} else { | ||
console.error(error.stack || error.message || String(error)); | ||
} | ||
}); | ||
} | ||
if (!error) { | ||
loaded = yaml.load(data, { schema: SPACE_SCHEMA }); | ||
console.log(util.inspect(loaded, false, 20, true)); | ||
} else { | ||
console.error(error.stack || error.message || String(error)); | ||
} | ||
}); | ||
// There are some exports to play with this example interactively. | ||
module.exports.Point = Point; | ||
@@ -101,0 +101,0 @@ module.exports.Space = Space; |
@@ -117,2 +117,3 @@ 'use strict'; | ||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null); | ||
this.sortKeys = options['sortKeys'] || false; | ||
@@ -603,2 +604,14 @@ this.implicitTypes = this.schema.compiledImplicit; | ||
// Allow sorting keys so that the output file is deterministic | ||
if (state.sortKeys === true) { | ||
// Default sorting | ||
objectKeyList.sort(); | ||
} else if (typeof state.sortKeys === 'function') { | ||
// Custom sort function | ||
objectKeyList.sort(state.sortKeys); | ||
} else if (state.sortKeys) { | ||
// Something is wrong | ||
throw new YAMLException('sortKeys must be a boolean or a function'); | ||
} | ||
for (index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
@@ -605,0 +618,0 @@ pairBuffer = ''; |
@@ -26,3 +26,3 @@ 'use strict'; | ||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/; | ||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; | ||
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; | ||
@@ -29,0 +29,0 @@ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; |
{ | ||
"name": "js-yaml", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "YAML 1.2 parser and serializer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -178,2 +178,4 @@ JS-YAML - YAML 1.2 parser and serializer for JavaScript | ||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use. | ||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a | ||
function, use the function to sort the keys. | ||
@@ -180,0 +182,0 @@ styles: |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231507
6427
291