X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=node_modules%2Fgrunt%2Fnode_modules%2Fjs-yaml%2Flib%2Fjs-yaml%2Ftype%2Fpairs.js;fp=node_modules%2Fgrunt%2Fnode_modules%2Fjs-yaml%2Flib%2Fjs-yaml%2Ftype%2Fpairs.js;h=74b52403fc125d00198726b80e73689173041348;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/pairs.js b/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/pairs.js new file mode 100644 index 000000000..74b52403f --- /dev/null +++ b/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/pairs.js @@ -0,0 +1,53 @@ +'use strict'; + +var Type = require('../type'); + +var _toString = Object.prototype.toString; + +function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; +} + +function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; +} + +module.exports = new Type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +});