How to use the deferred.isPromise function in deferred

To help you get started, we’ve selected a few deferred 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 medikoo / fs2 / lib / memoize-watcher.js View on Github external
"use strict";

var noop      = require("es5-ext/function/noop")
  , assign    = require("es5-ext/object/assign")
  , memoize   = require("memoizee")
  , ee        = require("event-emitter")
  , eePipe    = require("event-emitter/pipe")
  , deferred  = require("deferred")
  , isPromise = deferred.isPromise;

module.exports = function (fn/*, options*/) {
	var factory, memoized;
	if (fn.__memoized__) return fn;
	memoized = memoize(fn, assign(Object(arguments[1]), { refCounter: true }));
	factory = function () {
		var watcher, emitter, pipe, args, def;
		args = arguments;
		watcher = memoized.apply(this, arguments);
		if (isPromise(watcher)) {
			def = deferred();
			emitter = def.promise;
			def.resolve(watcher);
		} else {
			emitter = ee();
		}

deferred

Modular and fast Promises implementation

ISC
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis