Sha256: a4fa54ca0343665eb199503d772a4fe4aab792e4e08bee682e70c0d4a5ada043

Contents?: true

Size: 1023 Bytes

Versions: 201

Compression:

Stored size: 1023 Bytes

Contents

'use strict';

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

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

function resolveYamlOmap(data) {
  if (data === null) 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 (_toString.call(pair) !== '[object Object]') return false;

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

    if (!pairHasKey) return false;

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

  return true;
}

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

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

Version data entries

201 entries across 185 versions & 22 rubygems

Version Path
immosquare-cleaner-0.1.62 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.61 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.60 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.59 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.58 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.57 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.56 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.55 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.54 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.53 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.52 node_modules/js-yaml/lib/type/omap.js
fattureincloud_ruby_sdk-2.1.1 scripts/node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.51 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.50 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.49 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.48 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.47 node_modules/js-yaml/lib/type/omap.js
immosquare-cleaner-0.1.46 node_modules/js-yaml/lib/type/omap.js
pcp-server-ruby-sdk-0.0.6 node_modules/js-yaml/lib/type/omap.js
pcp-server-ruby-sdk-0.1.0 node_modules/js-yaml/lib/type/omap.js