How to use optional - 4 common examples

To help you get started, we’ve selected a few optional 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 gajus / roarr / src / bin / commands / filter.js View on Github external
export const handler = (argv: ArgvType) => {
  const jq = optional('node-jq');

  if (!jq) {
    throw new Error('Must install `node-jq` dependency to use `roarr filter`.');
  }

  // argv
  process.stdin
    .pipe(split())
    .pipe(through((chunk, encoding, callback) => {
      const line = chunk.toString();

      filterLog(jq.run, argv, line, callback);
    }))
    .pipe(process.stdout);
};
github sebelga / gstore-node / src / dataloader.ts View on Github external
import optional from 'optional';
import arrify from 'arrify';
import datastoreAdapterFactory from 'nsql-cache-datastore';
import { Datastore } from '@google-cloud/datastore';
import DataLoader from 'dataloader'; // eslint-disable-line import/no-extraneous-dependencies

import { EntityKey, EntityData } from './types';

const OptionalDataloader = optional('dataloader');

const dsAdapter = datastoreAdapterFactory();

const { keyToString } = dsAdapter;

/**
 * Create a DataLoader instance
 * @param {Datastore} ds @google-cloud Datastore instance
 */
export const createDataLoader = (
  ds: Datastore,
  options?: { maxBatchSize: number },
): DataLoader => {
  if (!ds) {
    throw new Error('A Datastore instance has to be passed');
  }
github sebelga / gstore-node / src / schema.ts View on Github external
import is from 'is';

import { QUERIES_FORMATS } from './constants';
import VirtualType from './virtualType';
import { ValidationError, ERROR_CODES } from './errors';
import {
  FunctionType,
  FuncReturningPromise,
  CustomEntityFunction,
  GenericObject,
  EntityFormatType,
  JSONFormatType,
} from './types';
import { QueryListOptions } from './query';

const Joi = optional('@hapi/joi') || optional('joi');

const IS_QUERY_METHOD: { [key: string]: boolean } = {
  update: true,
  delete: true,
  findOne: true,
};

const DEFAULT_OPTIONS = {
  validateBeforeSave: true,
  explicitOnly: true,
  excludeLargeProperties: false,
  queries: {
    readAll: false,
    format: QUERIES_FORMATS.JSON,
  },
};
github phingofficial / phing / docs / docbook5 / en / output / webhelp / search / index-2.js View on Github external
w["opaqu"]="402*7";
w["open"]="138*1,160*1,280*1,282*1,328*1,445*1,504*1,520*43";
w["open-sourc"]="160*1";
w["openbsd"]="302*1";
w["openoffic"]="138*1";
w["openssh"]="440*2,504*2";
w["oper"]="15*1,28*1,42*7,82*1,85*1,108*1,109*1,133*1,154*1,159*1,174*1,190*1,243*5,278*2,295*1,302*41,318*3,323*1,388*1,389*2,397*1,400*1,402*1,404*1,406*3,439*1,458*1,465*1,478*1,494*1,502*1,518*2";
w["operation."]="133*1,159*1,295*1";
w["opportun"]="282*1";
w["opt"]="2*9,15*2,42*1,439*2";
w["optim"]="18*1,204*2,238*2,318*1,365*4,460*3";
w["option"]="23*1,27*2,42*5,53*14,73*1,78*1,103*1,129*1,135*2,154*1,158*1,159*2,166*1,201*1,204*6,221*4,222*1,229*1,234*2,236*1,238*3,239*1,250*2,258*1,270*1,272*16,275*8,295*1,307*2,310*1,320*1,328*1,347*1,358*1,365*3,377*10,386*8,389*1,392*1,402*3,413*1,422*1,441*1,445*3,446*52,464*1,484*3,501*2,509*1,521*1,528*6";
w["option."]="234*1";
w["option:"]="441*1";
w["option_nam"]="377*1,528*1";
w["optional."]="58*1,167*2,414*2";
w["optional:"]="42*1";
w["optionaltask"]="354*1";
w["optionaltasks.xml"]="354*1";
w["options."]="167*1,230*1,236*1,386*1,414*1";
w["options:"]="377*1";
w["optionschoic"]="441*1";
w["optmask"]="460*1";
w["orag"]="42*1";
w["order"]="15*1,39*2,42*3,58*2,87*1,124*1,131*1,155*2,167*2,207*1,234*2,280*1,300*3,307*1,354*3,375*1,380*1,381*1,392*1,397*1,402*1,414*2,458*1,465*1,470*1,471*1,501*1";
w["order."]="354*1";
w["orderdescend"]="124*1,127*1";
w["ordinari"]="42*11";
w["ore"]="402*1";
w["org"]="21*1,27*1,42*1,53*4,86*1,138*4,148*1,189*1,194*1,236*2,259*1,272*1,275*1,282*1,402*2,416*1,421*2,470*1,520*12";
w["org:"]="229*1,305*2";
w["org:3128"]="21*1,86*1";

optional

Allows you to optionally include modules without surrounding everything with 'try/catch'

MIT
Latest version published 7 years ago

Package Health Score

50 / 100
Full package analysis

Popular optional functions