How to use the lodash-es.isString function in lodash-es

To help you get started, we’ve selected a few lodash-es 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 openshift / console / frontend / public / module / k8s / resource.js View on Github external
export const k8sCreate = (kind, data, opts = {}) => {
  // Occassionally, a resource won't have a metadata property.
  // For example: apps.openshift.io/v1 DeploymentRequest
  // https://github.com/openshift/api/blob/master/apps/v1/types.go
  data.metadata = data.metadata || {};

  // Lowercase the resource name
  // https://github.com/kubernetes/kubernetes/blob/HEAD/docs/user-guide/identifiers.md#names
  if (data.metadata.name && _.isString(data.metadata.name) && !data.metadata.generateName) {
    data.metadata.name = data.metadata.name.toLowerCase();
  }

  return coFetchJSON.post(
    resourceURL(kind, Object.assign({ ns: data.metadata.namespace }, opts)),
    data,
  );
};
github Chimeejs / chimee / packages / chimee / src / dispatcher / index.ts View on Github external
preset?: UserConfig['preset'],
      src: string,
    },
    option: {
      box?: string,
      isLive?: boolean,
      kernels?: UserKernelsConfig,
      preset?: UserConfig['preset'],
    } = {}) {
    const src: string = isString(srcOrOption)
      ? srcOrOption
      : isPlainObject(srcOrOption) && isString(srcOrOption.src)
        ? srcOrOption.src
        // give a chance for user to clear the src
        : '';
    if (!isString(srcOrOption)) {
      delete srcOrOption.src;
      option = srcOrOption;
    }
    const oldBox = this.kernel.box;
    const videoConfig = this.videoConfig;
    const {
      isLive = videoConfig.isLive,
      box = getLegalBox({ src, box: videoConfig.box }),
      preset = videoConfig.preset,
      kernels = videoConfig.kernels,
    } = option;
    if (box !== 'native' || box !== oldBox || !isEmpty(option)) {
      const video = document.createElement('video');
      const config = { isLive, box, preset, src, kernels };
      const kernel = this.createKernel(video, config);
      this.switchKernel({ video, kernel, config, notifyChange: true });
github Chimeejs / chimee / packages / chimee / src / dispatcher / kernel.ts View on Github external
export function getLegalBox({ src, box }: { box: string, src: string }): string {
  if (isString(box) && box) { return box; }
  src = src.toLowerCase();
  for (const key in boxSuffixMap) {
    /* istanbul ignore next */
    if (boxSuffixMap.hasOwnProperty(key)) {
      const suffix = boxSuffixMap[key];
      if (src.indexOf(suffix) > -1) { return key; }
    }
  }
  return 'native';
}
github Chimeejs / chimee / packages / chimee / src / dispatcher / index.ts View on Github external
public use(rawOption: string | getLegalPluginOptionByChimeePlugin): Promise {
    // narrow down raw option type
    // the complicate just want to provide tips for user.
    let option: PluginOption | string = rawOption;
    if (isString(option)) { option = { name: option, alias: undefined }; }
    if (!isPlainObject(option) || (isPlainObject(option) && !isString(option.name))) {
      throw new TypeError('pluginConfig do not match requirement');
    }
    if (!isString(option.alias)) { option.alias = undefined; }
    const { name, alias } = option;
    option.name = alias || name;
    delete option.alias;
    const key = camelize(name);
    const id = camelize(alias || name);
    const pluginOption = option;
    const pluginConfig = Dispatcher.getPluginConfig(key);
    if (!pluginConfig) {
      throw new TypeError('You have not installed plugin ' + key);
    }
    if (isPlainObject(pluginConfig)) {
      (pluginConfig as PluginConfig).id = id;
    }
    const plugin = isFunction(pluginConfig)
      ? new (pluginConfig as IChimeePluginConstructor)(({id} as PluginConfig), this, pluginOption)
      : new ChimeePlugin((pluginConfig as PluginConfig), this, pluginOption);
github toxic-johann / toxic-decorators / src / watch.ts View on Github external
const fns = args.reduce((fns, keyOrFn, index) => {
      if (!isString(keyOrFn) && !isFunction(keyOrFn)) {
        if (!index || index !== args.length - 1) {
          throw new TypeError('You can only pass function or string as handler');
        }
        return fns;
      }
      fns.push(isString(keyOrFn)
        ? function(newVal: any, oldVal: any) {
          const target = other || obj;
          const fn = getDeepProperty(target, keyOrFn);
          if (!isFunction(fn)) {
            if (!omit) {
              // tslint:disable-next-line max-line-length
              throw new Error('You pass in a function for us to trigger, please ensure the property to be a function or set omit flag true');
            }
            return;
          }
github OfficeDev / office-js-helpers / src / helpers / storage.ts View on Github external
private _validateKey(key: string): void {
    if (!isString(key) || isEmpty(key)) {
      throw new TypeError('Key needs to be a string');
    }
  }
github Chimeejs / chimee / packages / chimee / src / index.ts View on Github external
public static registerEvents({
    name,
    target,
  }: {
    name?: string,
    target?: string,
  } = {}) {
    if (!name || !isString(name)) { throw new Error(`The event name must be a string, but not ${typeof name}`); }
    if (!target || !isString(target)) { throw new Error(`The event target must be a string, but not ${typeof target}`); }
    if (target === 'kernel') {
      kernelEvents.push(name);
    }
  }
  public readonly config: {
github Chimeejs / chimee / packages / chimee / src / index.ts View on Github external
public static registerEvents({
    name,
    target,
  }: {
    name?: string,
    target?: string,
  } = {}) {
    if (!name || !isString(name)) { throw new Error(`The event name must be a string, but not ${typeof name}`); }
    if (!target || !isString(target)) { throw new Error(`The event target must be a string, but not ${typeof target}`); }
    if (target === 'kernel') {
      kernelEvents.push(name);
    }
  }
  public readonly config: {
github Chimeejs / chimee / packages / chimee / src / config / video.ts View on Github external
function accessorVideoAttribute(attribute: string | { get: string, isBoolean?: boolean, set: string }) {
  const { set, get, isBoolean } = isString(attribute)
    ? {
      get: attribute,
      isBoolean: false,
      set: attribute,
    }
    : attribute;
  return accessor({
    get(value: string | number | boolean | void) {
      return ((this as VideoConfig).dispatcher.videoConfigReady && (this as VideoConfig).inited)
        ? ((this as VideoConfig).dom.videoElement as any)[get]
        : value;
    },
    set(value: string | number | boolean | void) {
      if (!(this as VideoConfig).dispatcher.videoConfigReady) { return value; }
      const val = isBoolean
        ? value