How to use the is.array function in is

To help you get started, we’ve selected a few is examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dreamerslab / node.extend / lib / extend.js View on Github external
}
      // Extend the base object
      for (name in options) {
        src = getProperty(target, name);
        copy = getProperty(options, name);

        // Prevent never-ending loop
        if (target === copy) {
          continue;
        }

        // Recurse if we're merging plain objects or arrays
        if (deep && copy && (is.hash(copy) || (copyIsArray = is.array(copy)))) {
          if (copyIsArray) {
            copyIsArray = false;
            clone = src && is.array(src) ? src : [];
          } else {
            clone = src && is.hash(src) ? src : {};
          }

          // Never move original objects, clone them
          setProperty(target, name, extend(deep, clone, copy));

        // Don't bring in undefined values
        } else if (typeof copy !== 'undefined') {
          setProperty(target, name, copy);
        }
      }
    }
  }

  // Return the modified object
github googleapis / nodejs-spanner / src / codec.ts View on Github external
function preEncode(value) {
    const numberShouldBeStringified =
        (!(value instanceof Float) && is.integer(value)) ||
        value instanceof Int || is.infinite(value) || Number.isNaN(value);

    if (is.date(value)) {
      value = value.toJSON();
    } else if (
        value instanceof SpannerDate || value instanceof Float ||
        value instanceof Int) {
      value = value.value;
    } else if (Buffer.isBuffer(value)) {
      value = value.toString('base64');
    } else if (Struct.isStruct(value)) {
      value = value.map(field => preEncode(field.value));
    } else if (is.array(value)) {
      value = value.map(preEncode);
    } else if (is.object(value) && is.fn(value.hasOwnProperty)) {
      for (const prop in value) {
        if (value.hasOwnProperty(prop)) {
          value[prop] = preEncode(value[prop]);
        }
      }
    }

    if (numberShouldBeStringified) {
      value = value.toString();
    }

    return value;
  }
  // tslint:disable-next-line no-any
github googleapis / google-cloud-node / packages / compute / system-test / compute.js View on Github external
}, function(err, status) {
        assert.ifError(err);
        assert.strictEqual(is.array(status), true);
        done();
      });
    });
github caolan / forms / lib / tag.js View on Github external
var tag = function tag(tagName, attrsMap, content, contentIsEscaped) {
    var safeTagName = htmlEscape(tagName);
    var attrsHTML = !is.array(attrsMap) ? attrs(attrsMap) : reduce(attrsMap, function (html, map) {
        return html + attrs(map);
    }, '');
    var safeContent = contentIsEscaped ? content : htmlEscape(content);
    return '<' + safeTagName + attrsHTML + (isSelfClosing(safeTagName) ? ' />' : '>' + safeContent + '');
};
github pedromsilvapt / unicast / src / Server / Providers / Local / VideoStream.js View on Github external
extractParams ( destinations, onProgress, options ) {
		if ( destinations && !is.string( destinations ) && !is.array( destinations ) && !( destinations instanceof Stream ) ) {
			options = onProgress;
			onProgress = destinations;
			destinations = [];
		}

		if ( is.object( onProgress ) ) {
			options = onProgress;
			onProgress = null;
		}

		if ( destinations && !is.array( destinations ) ) {
			destinations = [ destinations ];
		} else if ( !destinations ) {
			destinations = [];
		}

		destinations = destinations.map( destination => {
			if ( is.string( destination ) ) {
				destination = fs.createWriteStream( destination );
			}

			return destination;
		} );

		return [ destinations, onProgress, options ];
	}
github GitbookIO / markup-it / lib / models / rules.js View on Github external
function RulesList(rules) {
    if (rules instanceof Rule) {
        return new Immutable.List([rules]);
    }

    if (is.array(rules)) {
        return new Immutable.List(rules);
    }

    if (rules instanceof RulesSet) {
        return rules.getRules();
    }

    return rules || new Immutable.List();
}
github pedromsilvapt / unicast / src / Receivers / Chromecast / MediaFactory.js View on Github external
contentId: sender.url( 'video', urlParams ),
			contentType: 'video/mp4',
			tracks: null,
			metadata: {
				type: 0,
				metadataType: 0,
				itemId: media.id,
				title: media.title,
				images: [
					{ url: media.cover }
				]
			}
		};

		if ( media.subtitles ) {
			if ( !is.array( media.subtitles ) ) {
				media.subtitles = [ media.subtitles ];
			}

			let tracks = [];
			for ( let [ index, subtitles ] of media.subtitles.entries() ) {
				if ( is.string( subtitles ) ) {
					subtitles = {
						source: subtitles
					};
				}

				tracks.push( {
					trackId: subtitles.id || index,
					type: 'TEXT',
					trackContentId: sender.url( 'subtitles', urlParams ),
					trackContentType: subtitles.type || 'text/vtt',
github sebelga / gstore-node / lib / entity.js View on Github external
*/
    if (hasAncestors) {
        ancestors = ancestors.slice();
    }

    let path;
    if (id) {
        path = hasAncestors ? ancestors.concat([self.entityKind, id]) : [self.entityKind, id];
    } else {
        if (hasAncestors) {
            ancestors.push(self.entityKind);
        }
        path = hasAncestors ? ancestors : self.entityKind;
    }

    if (namespace && !is.array(path)) {
        path = [path];
    }
    return namespace ? self.gstore.ds.key({ namespace, path }) : self.gstore.ds.key(path);
}
github sebelga / gstore-node / lib / model.js View on Github external
function getScopeForDeleteHooks() {
            const id = is.object(args[0]) && {}.hasOwnProperty.call(args[0], '__override')
                ? arrify(args[0].__override)[0]
                : args[0];

            if (is.array(id)) {
                return null;
            }

            let ancestors;
            let namespace;
            let key;

            if (hookType === 'post') {
                ({ key } = args);
                if (is.array(key)) {
                    return null;
                }
            } else {
                ({
                    1: ancestors,
                    2: namespace,

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis