How to use the typical.isDefined function in typical

To help you get started, we’ve selected a few typical 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 75lb / table-layout / src / bin / cli.js View on Github external
.pipe(collectJson(function (json) {
    let clOptions = {
      maxWidth: process.stdout.columns,
      padding: {}
    }

    if (t.isDefined(options['padding-left'])) clOptions.padding.left = options['padding-left']
    if (t.isDefined(options['padding-right'])) clOptions.padding.right = options['padding-right']

    /* split input into data and options */
    if (!Array.isArray(json)) {
      if (json.options && json.data) {
        clOptions = extend(clOptions, json.options)
        json = json.data
      } else {
        throw new Error('Invalid input data')
      }
    }

    if (columns.length) clOptions.columns = columns

    const table = new tableLayout.Table(json, clOptions)
    return options.lines
      ? JSON.stringify(table.renderLines(), null, '  ') + '\n'
github 75lb / usage-stats / lib / usage-stats-core.js View on Github external
event (category, action, options) {
    if (this._disabled) return this
    if (!(category && action)) throw new Error('category and action required')
    options = options || {}
    if (options.hitParams && t.isPlainObject(options.hitParams)) {
      options.hitParams = objToMap(options.hitParams)
    }

    let hit = this._createHit(new Map([
      [ 't', 'event' ],
      [ 'ec', category ],
      [ 'ea', action ]
    ]), options)

    if (t.isDefined(options.el)) hit.set('el', options.el)
    if (t.isDefined(options.ev)) hit.set('ev', options.ev)
    this._hits.push(hit)
    return hit
  }
github lwsjs / lws / lib / server-factory / http.js View on Github external
create (options) {
    const t = require('typical')
    const serverOptions = {}
    const server = require('http').createServer()
    if (t.isDefined(options.maxConnections)) {
      server.maxConnections = serverOptions.maxConnections = options.maxConnections
    }
    if (t.isDefined(options.keepAliveTimeout)) {
      server.keepAliveTimeout = serverOptions.keepAliveTimeout = options.keepAliveTimeout
    }
    if (Object.keys(serverOptions).length) {
      this.emit('verbose', 'server.config', serverOptions)
    }
    return server
  }
}
github 75lb / table-layout / lib / column.js View on Github external
constructor (column) {
    /**
     * @type {string}
     */
    if (t.isDefined(column.name)) this.name = column.name
    /**
     * @type {number}
     */
    if (t.isDefined(column.width)) this.width = column.width
    if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
    if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
    if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
    if (t.isDefined(column.break)) this.break = column.break
    if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
    if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
    if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
    this.padding = column.padding || { left: ' ', right: ' ' }
    this.generatedWidth = null
  }
github 75lb / table-layout / lib / column.js View on Github external
constructor (column) {
    /**
     * @type {string}
     */
    if (t.isDefined(column.name)) this.name = column.name
    /**
     * @type {number}
     */
    if (t.isDefined(column.width)) this.width = column.width
    if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
    if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
    if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
    if (t.isDefined(column.break)) this.break = column.break
    if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
    if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
    if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
    this.padding = column.padding || { left: ' ', right: ' ' }
    this.generatedWidth = null
  }
github 75lb / table-layout / es5 / lib / column.js View on Github external
function Column(column) {
    _classCallCheck(this, Column);

    if (t.isDefined(column.name)) this.name = column.name;

    if (t.isDefined(column.width)) this.width = column.width;
    if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth;
    if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth;
    if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap;
    if (t.isDefined(column.break)) this.break = column.break;
    if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable;
    if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth;
    if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth;
    this.padding = column.padding || { left: ' ', right: ' ' };
    this.generatedWidth = null;
  }
github saiskee / it-works / demo / node_modules / wordwrapjs / index.js View on Github external
static isWrappable (text) {
    if (t.isDefined(text)) {
      text = String(text)
      var matches = text.match(re.chunk)
      return matches ? matches.length > 1 : false
    }
  }
github 75lb / table-layout / es5 / bin / cli.js View on Github external
function getTable(json) {
  var clOptions = {
    maxWidth: process.stdout.columns,
    padding: {}
  };

  if (t.isDefined(options['padding-left'])) clOptions.padding.left = options['padding-left'];
  if (t.isDefined(options['padding-right'])) clOptions.padding.right = options['padding-right'];

  if (!Array.isArray(json)) {
    if (json.options && json.data) {
      clOptions = extend(clOptions, json.options);
      json = json.data;
    } else {
      throw new Error('Invalid input data');
    }
  }

  if (columns.length) clOptions.columns = columns;

  var table = new Table(json, clOptions);
  return table.toString();
}
github 75lb / table-layout / lib / column.js View on Github external
constructor (column) {
    /**
     * @type {string}
     */
    if (t.isDefined(column.name)) this.name = column.name
    /**
     * @type {number}
     */
    if (t.isDefined(column.width)) this.width = column.width
    if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
    if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
    if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
    if (t.isDefined(column.break)) this.break = column.break
    if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
    if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
    if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
    this.padding = column.padding || { left: ' ', right: ' ' }
    this.generatedWidth = null
  }
github 75lb / table-layout / es5 / lib / column.js View on Github external
function Column(column) {
    _classCallCheck(this, Column);

    if (t.isDefined(column.name)) this.name = column.name;

    if (t.isDefined(column.width)) this.width = column.width;
    if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth;
    if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth;
    if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap;
    if (t.isDefined(column.break)) this.break = column.break;
    if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable;
    if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth;
    if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth;
    this.padding = column.padding || { left: ' ', right: ' ' };
    this.generatedWidth = null;
  }

typical

Isomorphic, functional type-checking for Javascript

MIT
Latest version published 2 months ago

Package Health Score

74 / 100
Full package analysis