Sha256: b572de328313b2a330c697685b0e1f8917b0230b3481b0c65cfb85ed2bc86c5d

Contents?: true

Size: 1.17 KB

Versions: 46

Compression:

Stored size: 1.17 KB

Contents

'use strict';


function isNothing(subject) {
  return (undefined === subject) || (null === subject);
}


function isObject(subject) {
  return ('object' === typeof subject) && (null !== subject);
}


function toArray(sequence) {
  if (Array.isArray(sequence)) {
    return sequence;
  } else if (isNothing(sequence)) {
    return [];
  } else {
    return [ sequence ];
  }
}


function extend(target, source) {
  var index, length, key, sourceKeys;

  if (source) {
    sourceKeys = Object.keys(source);

    for (index = 0, length = sourceKeys.length; index < length; index += 1) {
      key = sourceKeys[index];
      target[key] = source[key];
    }
  }

  return target;
}


function repeat(string, count) {
  var result = '', cycle;

  for (cycle = 0; cycle < count; cycle += 1) {
    result += string;
  }

  return result;
}


function isNegativeZero(number) {
  return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
}


module.exports.isNothing      = isNothing;
module.exports.isObject       = isObject;
module.exports.toArray        = toArray;
module.exports.repeat         = repeat;
module.exports.isNegativeZero = isNegativeZero;
module.exports.extend         = extend;

Version data entries

46 entries across 39 versions & 3 rubygems

Version Path
opal-0.10.6 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.6.beta stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.5 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.4 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.3 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.2 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.1 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.rc2 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.9.4 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.9.3 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.rc1 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.beta5 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.beta4 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.beta3 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.beta2 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.10.0.beta1 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.9.2 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.9.0 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js
opal-0.9.0.rc1 stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js