Sha256: 5d0cea8b6845a331799318962c2df7cdcc854f6a18dbd217b54000494a3223ed

Contents?: true

Size: 884 Bytes

Versions: 30

Compression:

Stored size: 884 Bytes

Contents

"use strict";

var isPrototype = require("../prototype/is");

// In theory we could rely on Symbol.toStringTag directly,
// still early native implementation (e.g. in FF) predated symbols
var objectToString = Object.prototype.toString
  , objectTaggedString = objectToString.call(Promise.resolve());

module.exports = function (value) {
	if (!value) return false;

	// Sanity check (reject objects which do not expose common Promise interface)
	try {
		if (typeof value.then !== "function") return false;
		if (typeof value["catch"] !== "function") return false;
	} catch (error) {
		return false;
	}

	// Ensure its native Promise object (has [[PromiseState]] slot)
	// Note: it's not 100% precise as string tag may be overriden
	// and other objects could be hacked to expose it
	if (objectToString.call(value) !== objectTaggedString) return false;

	return !isPrototype(value);
};

Version data entries

30 entries across 29 versions & 2 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/ext/node_modules/type/promise/is.js
optimacms-0.1.61 spec/dummy/node_modules/type/promise/is.js
govuk_publishing_components-18.0.0 node_modules/type/promise/is.js
govuk_publishing_components-17.21.0 node_modules/type/promise/is.js
govuk_publishing_components-17.20.0 node_modules/type/promise/is.js
govuk_publishing_components-17.19.1 node_modules/type/promise/is.js
govuk_publishing_components-17.19.0 node_modules/type/promise/is.js
govuk_publishing_components-17.18.0 node_modules/type/promise/is.js
govuk_publishing_components-17.17.0 node_modules/type/promise/is.js
govuk_publishing_components-17.16.0 node_modules/type/promise/is.js
govuk_publishing_components-17.15.0 node_modules/type/promise/is.js
govuk_publishing_components-17.14.0 node_modules/type/promise/is.js
govuk_publishing_components-17.13.0 node_modules/type/promise/is.js
govuk_publishing_components-17.12.2 node_modules/type/promise/is.js
govuk_publishing_components-17.12.1 node_modules/type/promise/is.js
govuk_publishing_components-17.12.0 node_modules/type/promise/is.js
govuk_publishing_components-17.11.0 node_modules/type/promise/is.js
govuk_publishing_components-17.10.0 node_modules/type/promise/is.js
govuk_publishing_components-17.9.0 node_modules/type/promise/is.js
govuk_publishing_components-17.8.0 node_modules/type/promise/is.js