Sha256: 634b7821ceb0877b5320a17b3b0fc3fb60ac3092b86c9d069722f18e2421c1db

Contents?: true

Size: 971 Bytes

Versions: 201

Compression:

Stored size: 971 Bytes

Contents

'use strict';

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

function resolveYamlBoolean(data) {
  if (data === null) return false;

  var max = data.length;

  return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
         (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
}

function constructYamlBoolean(data) {
  return data === 'true' ||
         data === 'True' ||
         data === 'TRUE';
}

function isBoolean(object) {
  return Object.prototype.toString.call(object) === '[object Boolean]';
}

module.exports = new Type('tag:yaml.org,2002:bool', {
  kind: 'scalar',
  resolve: resolveYamlBoolean,
  construct: constructYamlBoolean,
  predicate: isBoolean,
  represent: {
    lowercase: function (object) { return object ? 'true' : 'false'; },
    uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
    camelcase: function (object) { return object ? 'True' : 'False'; }
  },
  defaultStyle: 'lowercase'
});

Version data entries

201 entries across 185 versions & 22 rubygems

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