How to use the typical.isFunction 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 lwsjs / local-web-server / lib / middleware.js View on Github external
let target = targets.find(target => {
        return testValue(target, {
          request: {
            method: [ ctx.method, undefined ],
            accepts: type => ctx.accepts(type)
          }
        })
      })

      /* else take the first target without a request (no request means 'all requests') */
      if (!target) {
        target = targets.find(target => !target.request)
      }

      if (target) {
        if (t.isFunction(target.response)) {
          const pathMatches = ctx.path.match(pathRe).slice(1)
          return target.response.apply(null, [ctx].concat(pathMatches))
        } else if (t.isPlainObject(target.response)) {
          Object.assign(ctx.response, target.response)
        } else {
          throw new Error(`Invalid response: ${JSON.stringify(target.response)}`)
        }
      }
    } else {
      return next()
    }
  }
}
github 75lb / table-layout / es5 / lib / cell.js View on Github external
get: function get() {
      var cellValue = _value.get(this);
      if (t.isFunction(cellValue)) cellValue = cellValue.call(_column.get(this));
      if (cellValue === undefined) {
        cellValue = '';
      } else {
        cellValue = String(cellValue);
      }
      return cellValue;
    }
  }]);
github 75lb / command-line-args / lib / option-definition.js View on Github external
isBoolean () {
    return this.type === Boolean || (t.isFunction(this.type) && this.type.name === 'Boolean')
  }
  isMultiple () {
github 75lb / command-line-args / es5 / lib / definition.js View on Github external
value: function isBoolean() {
      if (this.type) {
        return this.type === Boolean || t.isFunction(this.type) && this.type.name === 'Boolean';
      } else {
        return false;
      }
    }
  }]);

typical

Isomorphic, functional type-checking for Javascript

MIT
Latest version published 2 months ago

Package Health Score

74 / 100
Full package analysis