How to use the @boost/common.toArray function in @boost/common

To help you get started, we’ve selected a few @boost/common 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 milesj / boost / packages / debug / src / createDebugger.ts View on Github external
export default function createDebugger(namespace: string | string[]): Debugger {
  const globalNamespace = env('DEBUG_GLOBAL_NAMESPACE');
  const namespaces = toArray(namespace);

  if (globalNamespace) {
    namespaces.unshift(globalNamespace);
  }

  const mainNamespace = namespaces.join(':');

  debug(
    'New debugger created: %s %s',
    mainNamespace,
    env('DEBUG_VERBOSE') ? '(verbose enabled)' : '',
  );

  const logger = coreDebug(mainNamespace) as Debugger;

  // `debug` doesn't support this on an individual namespace basis,
github milesj / boost / packages / translate / src / createTranslator.ts View on Github external
export default function createTranslator(
  namespace: string | string[],
  resourcePath: PortablePath | PortablePath[],
  {
    autoDetect = true,
    debug: debugOpt = false,
    fallbackLocale = 'en',
    locale,
    lookupType,
    resourceFormat = 'yaml',
  }: TranslatorOptions = {},
): Translator {
  const namespaces = toArray(namespace);
  const resourcePaths = toArray(resourcePath).map(Path.create);

  if (namespaces.length === 0) {
    throw new RuntimeError('translate', 'TL_REQ_NAMESPACE');
  } else if (resourcePaths.length === 0) {
    throw new RuntimeError('translate', 'TL_REQ_RES_PATHS');
  } else if (!autoDetect && !locale) {
    throw new RuntimeError('translate', 'TL_REQ_MANUAL_LOCALE');
  }

  debug('New translator created: %s namespace(s)', namespaces.join(', '));

  const translator = i18next.createInstance().use(new FileBackend());

  if (autoDetect) {
    translator.use(new LocaleDetector());
github milesj / boost / packages / debug / src / CrashReporter.ts View on Github external
reportPackageVersions(patterns: string | string[], title: string = 'Packages'): this {
    this.addSection(title);

    glob
      .sync(
        toArray(patterns).map(pattern => path.join('node_modules', pattern)),
        {
          absolute: true,
          deep: 1,
          onlyDirectories: true,
          onlyFiles: false,
        },
      )
      .forEach(pkgPath => {
        const pkg: { name: string; version: string } = requireModule(
          path.join(pkgPath, 'package.json'),
        );

        this.add(pkg.name, pkg.version);
      });

    return this;
github milesj / boost / packages / translate / src / createTranslator.ts View on Github external
export default function createTranslator(
  namespace: string | string[],
  resourcePath: PortablePath | PortablePath[],
  {
    autoDetect = true,
    debug: debugOpt = false,
    fallbackLocale = 'en',
    locale,
    lookupType,
    resourceFormat = 'yaml',
  }: TranslatorOptions = {},
): Translator {
  const namespaces = toArray(namespace);
  const resourcePaths = toArray(resourcePath).map(Path.create);

  if (namespaces.length === 0) {
    throw new RuntimeError('translate', 'TL_REQ_NAMESPACE');
  } else if (resourcePaths.length === 0) {
    throw new RuntimeError('translate', 'TL_REQ_RES_PATHS');
  } else if (!autoDetect && !locale) {
    throw new RuntimeError('translate', 'TL_REQ_MANUAL_LOCALE');
  }

  debug('New translator created: %s namespace(s)', namespaces.join(', '));

  const translator = i18next.createInstance().use(new FileBackend());

  if (autoDetect) {
    translator.use(new LocaleDetector());
  }