Sha256: 7bddac0aad313f0e4475e5df6e8904a5452286402df2bc99a4ad3c3c0e563310

Contents?: true

Size: 1.09 KB

Versions: 112

Compression:

Stored size: 1.09 KB

Contents

'use strict';

var Type = require('../type');

var _hasOwnProperty = Object.prototype.hasOwnProperty;
var _toString       = Object.prototype.toString;

function resolveYamlOmap(data) {
  if (null === data) {
    return true;
  }

  var objectKeys = [], index, length, pair, pairKey, pairHasKey,
      object = data;

  for (index = 0, length = object.length; index < length; index += 1) {
    pair = object[index];
    pairHasKey = false;

    if ('[object Object]' !== _toString.call(pair)) {
      return false;
    }

    for (pairKey in pair) {
      if (_hasOwnProperty.call(pair, pairKey)) {
        if (!pairHasKey) {
          pairHasKey = true;
        } else {
          return false;
        }
      }
    }

    if (!pairHasKey) {
      return false;
    }

    if (-1 === objectKeys.indexOf(pairKey)) {
      objectKeys.push(pairKey);
    } else {
      return false;
    }
  }

  return true;
}

function constructYamlOmap(data) {
  return null !== data ? data : [];
}

module.exports = new Type('tag:yaml.org,2002:omap', {
  kind: 'sequence',
  resolve: resolveYamlOmap,
  construct: constructYamlOmap
});

Version data entries

112 entries across 105 versions & 6 rubygems

Version Path
opal-0.10.6 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js
opal-0.10.6.beta stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js
opal-0.10.5 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js
opal-0.10.4 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
opal-0.10.3 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/omap.js
opal-0.10.2 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js