How to use the is-what.isString function in is-what

To help you get started, we’ve selected a few is-what 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 mesqueeb / vuex-easy-firestore / test / helpers / index.cjs.js View on Github external
function errorCheck (config) {
    var errors = [];
    var reqProps = ['firestorePath', 'moduleName'];
    reqProps.forEach(function (prop) {
        if (!config[prop]) {
            errors.push("Missing `" + prop + "` in your module!");
        }
    });
    if (config.statePropName !== null && !isWhat.isString(config.statePropName)) {
        errors.push('statePropName must be null or a string');
    }
    if (isWhat.isString(config.statePropName) && /(\.|\/)/.test(config.statePropName)) {
        errors.push("statePropName must be null or a string without special characters");
    }
    if (/\./.test(config.moduleName)) {
        errors.push("moduleName must only include letters from [a-z] and forward slashes '/'");
    }
    var syncProps = ['where', 'orderBy', 'fillables', 'guard', 'defaultValues', 'insertHook', 'patchHook', 'deleteHook', 'insertBatchHook', 'patchBatchHook', 'deleteBatchHook'];
    syncProps.forEach(function (prop) {
        if (config[prop]) {
            errors.push("We found `" + prop + "` on your module, are you sure this shouldn't be inside a prop called `sync`?");
        }
    });
    var serverChangeProps = ['modifiedHook', 'defaultValues', 'addedHook', 'removedHook'];
    serverChangeProps.forEach(function (prop) {
        if (config[prop]) {
            errors.push("We found `" + prop + "` on your module, are you sure this shouldn't be inside a prop called `serverChange`?");
        }
github mesqueeb / vuex-easy-access / test / helpers / pathUtils.cjs.js View on Github external
function getId(payloadPiece, conf, path, fullPayload) {
    if (isWhat.isObject(payloadPiece)) {
        if ('id' in payloadPiece)
            return payloadPiece.id;
        if (Object.keys(payloadPiece).length === 1)
            return Object.keys(payloadPiece)[0];
    }
    if (isWhat.isString(payloadPiece))
        return payloadPiece;
    error('wildcardFormatWrong', conf, path);
    return '';
}
/**
github mesqueeb / vuex-easy-access / dist / index.cjs.js View on Github external
function getId(payloadPiece, conf, path, fullPayload) {
    if (isWhat.isObject(payloadPiece)) {
        if ('id' in payloadPiece)
            return payloadPiece.id;
        if (Object.keys(payloadPiece).length === 1)
            return Object.keys(payloadPiece)[0];
    }
    if (isWhat.isString(payloadPiece))
        return payloadPiece;
    error('wildcardFormatWrong', conf, path);
    return '';
}
/**
github mesqueeb / vuex-easy-access / dist / index.esm.js View on Github external
function getId(payloadPiece, conf, path, fullPayload) {
    if (isObject(payloadPiece)) {
        if ('id' in payloadPiece)
            return payloadPiece.id;
        if (Object.keys(payloadPiece).length === 1)
            return Object.keys(payloadPiece)[0];
    }
    if (isString(payloadPiece))
        return payloadPiece;
    error('wildcardFormatWrong', conf, path);
    return '';
}
/**
github mesqueeb / vuex-easy-access / src / pathUtils.ts View on Github external
function getId (
  payloadPiece: object | ({ id: string } & object) | string,
  conf?: object,
  path?: string,
  fullPayload?: any[] | object | string
): string {
  if (isObject(payloadPiece)) {
    if ('id' in payloadPiece) return payloadPiece.id
    if (Object.keys(payloadPiece).length === 1) return Object.keys(payloadPiece)[0]
  }
  if (isString(payloadPiece)) return payloadPiece
  error('wildcardFormatWrong', conf, path)
  return ''
}
github mesqueeb / vuex-easy-firestore / dist / index.cjs.js View on Github external
stringProps.forEach(function (prop) {
        var _prop = config[prop];
        if (!isWhat.isString(_prop))
            errors.push("`" + prop + "` should be a String, but is not.");
    });
    var arrayProps = ['where', 'orderBy', 'fillables', 'guard'];
github mesqueeb / vuex-easy-firestore / dist / index.es.js View on Github external
function getId(payloadPiece, conf, path, fullPayload) {
  if (isObject(payloadPiece)) {
    if (payloadPiece.id) return payloadPiece.id;
    if (Object.keys(payloadPiece).length === 1) return Object.keys(payloadPiece)[0];
  }

  if (isString(payloadPiece)) return payloadPiece;
  return false;
}
/**

is-what

JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis