How to use the lie.reject function in lie

To help you get started, we’ve selected a few lie 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 hoodiehq / hoodie-store-client / lib / pull.js View on Github external
return new Promise(function (resolve, reject) {
      if (Array.isArray(docsOrIds)) {
        docsOrIds = docsOrIds.map(toId)
      } else {
        docsOrIds = docsOrIds && [toId(docsOrIds)]
      }

      if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
        return Promise.reject(errors.NOT_AN_OBJECT)
      }

      var replication = state.db.replicate.from(remote, {
        doc_ids: docsOrIds
      })

      /* istanbul ignore next */
      replication.catch(function () {
        // handled trough 'error' event
      })

      replication.on('complete', function () {
        resolve(pulledObjects)
      })
      replication.on('error', reject)
github hoodiehq / hoodie-store-client / lib / push.js View on Github external
return new Promise(function (resolve, reject) {
      if (Array.isArray(docsOrIds)) {
        docsOrIds = docsOrIds.map(toId)
      } else {
        docsOrIds = docsOrIds && [toId(docsOrIds)]
      }

      if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
        return Promise.reject(errors.NOT_AN_OBJECT)
      }

      var replication = state.db.replicate.to(remote, {
        create_target: true,
        doc_ids: docsOrIds,
        include_docs: true
      })

      /* istanbul ignore next */
      replication.catch(function () {
        // handled trough 'error' event
      })

      replication.on('complete', function () {
        resolve(pushedObjects)
      })
github minznerjosh / vast-player / lib / players / HTMLVideo.js View on Github external
HTMLVideo.prototype.resumeAd = method(function resumeAd() {
    var self = this;
    var video = this.video;

    if (!this.__private__.hasPlayed) {
        return LiePromise.reject(new Error('The ad has not been started yet.'));
    }

    if (!this.video.paused) {
        return LiePromise.resolve(this);
    }

    return new LiePromise(function callPlay(resolve) {
        once(video, HTML_MEDIA_EVENTS.PLAY, function onplay() {
            resolve(self);
            self.emit(VPAID_EVENTS.AdPlaying);
        });

        return video.play();
    });
}, true);
github minznerjosh / vast-player / lib / players / HTMLVideo.js View on Github external
HTMLVideo.prototype.startAd = method(function startAd() {
    var self = this;
    var video = this.video;

    if (this.__private__.hasPlayed) {
        return LiePromise.reject(new Error('The ad has already been started.'));
    }

    return new LiePromise(function callPlay(resolve) {
        once(video, HTML_MEDIA_EVENTS.PLAYING, function onplaying() {
            resolve(self);
            self.emit(VPAID_EVENTS.AdStarted);
        });

        return video.play();
    });
}, true);
github minznerjosh / vast-player / lib / players / HTMLVideo.js View on Github external
return function callImplementation(/*...args*/) {
        if (!this.video) {
            if (promiseify) { return LiePromise.reject(getError()); } else { throw getError(); }
        }

        return implementation.apply(this, arguments);
    };
}
github hoodiehq / hoodie-store-client / lib / helpers / update-one.js View on Github external
module.exports = function updateOne (state, idOrDoc, change, prefix) {
  var doc

  if (typeof idOrDoc === 'string' && !change) {
    return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
  }

  return findOne(state, idOrDoc, prefix)

  .then(function (doc) {
    if (!change) {
      return assign(doc, idOrDoc, {_id: doc._id, _rev: doc._rev, hoodie: doc.hoodie})
    }

    return changeObject(state, change, doc)
  })

  .then(function (_doc) {
    doc = _doc
    return put(state, addTimestamps(doc))
  })
github hoodiehq / hoodie-store-client / lib / update.js View on Github external
function update (state, prefix, objectsOrIds, change) {
  if (typeof objectsOrIds !== 'object' && !change) {
    return Promise.reject(
      new Error('Must provide change')
    )
  }

  return Array.isArray(objectsOrIds)
    ? updateMany(state, objectsOrIds, change, prefix)
    : updateOne(state, objectsOrIds, change, prefix)
}
github hoodiehq / hoodie-store-client / lib / update-all.js View on Github external
function updateAll (state, prefix, changedProperties) {
  var type = typeof changedProperties
  var docs

  if (type !== 'object' && type !== 'function') {
    return Promise.reject(new Error('Must provide object or function'))
  }

  var options = {
    include_docs: true
  }

  if (prefix) {
    options.startkey = prefix
    options.endkey = prefix + '\uffff'
  }

  return state.db.allDocs(options)

  .then(function (res) {
    docs = res.rows
      .filter(isntDesignDoc)
github hoodiehq / hoodie-store-client / lib / helpers / add-one.js View on Github external
function addOne (state, doc, prefix) {
  if (typeof doc !== 'object') {
    return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
  }

  doc = clone(doc)

  if (!doc._id) {
    doc._id = uuid()
  }

  if (prefix) {
    doc._id = prefix + doc._id
  }

  delete doc.hoodie

  return validate(state, doc)
github minznerjosh / vast-player / lib / VASTPlayer.js View on Github external
return function callMethod() {
        var self = this;
        var player = this.__private__.player;

        if (!this.ready) {
            return LiePromise.reject(getNotReadyError());
        }

        return player[method].apply(player, arguments).then(function() {
            return self;
        });
    };
}

lie

A basic but performant promise implementation

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis