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
fattureincloud_ruby_sdk-2.0.6 scripts/node_modules/js-yaml/lib/type/omap.js
fattureincloud_ruby_sdk-2.0.5 scripts/node_modules/js-yaml/lib/type/omap.js
appmap-0.72.2 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
fattureincloud_ruby_sdk-2.0.4 scripts/node_modules/js-yaml/lib/type/omap.js
appmap-0.72.1 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
fattureincloud_ruby_sdk-2.0.3 scripts/node_modules/js-yaml/lib/type/omap.js
appmap-0.72.0 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.71.0 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
disco_app-0.16.1 test/dummy/node_modules/js-yaml/lib/js-yaml/type/omap.js
disco_app-0.16.1 test/dummy/node_modules/@rails/webpacker/node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.70.2 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
fattureincloud_ruby_sdk-2.0.2 scripts/node_modules/js-yaml/lib/type/omap.js
fattureincloud_ruby_sdk-2.0.1 scripts/node_modules/js-yaml/lib/type/omap.js
appmap-0.70.1 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.70.0 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.69.0 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.68.2 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
appmap-0.68.1 ./node_modules/js-yaml/lib/js-yaml/type/omap.js
disco_app-0.15.2 test/dummy/node_modules/@rails/webpacker/node_modules/js-yaml/lib/js-yaml/type/omap.js
disco_app-0.15.2 test/dummy/node_modules/js-yaml/lib/js-yaml/type/omap.js