How to use the is.instanceof 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 googleapis / nodejs-firestore / src / index.js View on Github external
.then(() => {
          let promise = updateFunction(transaction);
          result = is.instanceof(promise, Promise) ?
              promise :
              Promise.reject(new Error(
                  'You must return a Promise in your transaction()-callback.'));
          return result.catch(err => {
            logger(
                'Firestore.runTransaction', requestTag,
                'Rolling back transaction after callback error:', err);
            // Rollback the transaction and return the failed result.
            return transaction.rollback().then(() => {
              return result;
            });
          });
        })
        .then(() => {
github googleapis / nodejs-firestore / test / query.js View on Github external
results.forEach(doc => {
          assert.ok(is.instanceof(doc, DocumentSnapshot));
          assert.ok(doc.createTime.isEqual(new Firestore.Timestamp(1, 2)));
          assert.ok(doc.updateTime.isEqual(new Firestore.Timestamp(3, 4)));
          assert.ok(doc.readTime.isEqual(new Firestore.Timestamp(5, 6)));
          ++count;
        });
github googleapis / nodejs-firestore / src / path.js View on Github external
static validateFieldPath(fieldPath) {
    if (!is.instanceof(fieldPath, FieldPath)) {
      if (!is.string(fieldPath)) {
        throw validate.customObjectError(fieldPath);
      }

      if (fieldPath.indexOf('..') >= 0) {
        throw new Error(`Paths must not contain '..' in them.`);
      }

      if (fieldPath.startsWith('.') || fieldPath.endsWith('.')) {
        throw new Error(`Paths must not start or end with '.'.`);
      }

      if (!FIELD_PATH_RE.test(fieldPath)) {
        throw new Error(`Paths can't be empty and must not contain '*~/[]'.`);
      }
    }
github googleapis / nodejs-firestore / src / path.js View on Github external
append(relativePath) {
    if (is.instanceof(relativePath, Path)) {
      return this.construct(this.segments.concat(relativePath.segments));
    }
    return this.construct(this.segments.concat(this.split(relativePath)));
  }
github firebase / firebase-tools / src / firestore / encodeFirestoreValue.js View on Github external
if (enc) {
          encodedElements.push(enc);
        }
      }
      return {
        arrayValue: {
          values: encodedElements,
        },
      };
    }
    if (is.nil(val)) {
      return {
        nullValue: "NULL_VALUE",
      };
    }
    if (is.instanceof(val, Buffer) || is.instanceof(val, Uint8Array)) {
      return {
        bytesValue: val,
      };
    }
    if (isPlainObject(val)) {
      return {
        mapValue: {
          fields: encodeFirestoreValue(val),
        },
      };
    }
    throw new Error(
      "Cannot encode " +
        val +
        "to a Firestore Value." +
        " The emulator does not yet support Firestore document reference values or geo points."
github googleapis / nodejs-firestore / src / path.js View on Github external
isEqual(other) {
    return (
      this === other ||
      (is.instanceof(other, this.constructor) && this.compareTo(other) === 0)
    );
  }
}