How to use the ow.function function in ow

To help you get started, we’ve selected a few ow 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 vadimdemedes / reconciled / index.js View on Github external
module.exports = config => {
	ow(config, ow.object.exactShape({
		render: ow.optional.function,
		createNode: ow.function,
		createTextNode: ow.function,
		setTextNodeValue: ow.function,
		appendNode: ow.function,
		insertBeforeNode: ow.optional.function,
		updateNode: ow.optional.function,
		removeNode: ow.optional.function
	}));

	const fullConfig = {
		schedulePassiveEffects: unstable_scheduleCallback, // eslint-disable-line camelcase
		cancelPassiveEffects: unstable_cancelCallback, // eslint-disable-line camelcase
		now: Date.now,
		getRootHostContext: () => NO_CONTEXT,
		prepareForCommit: noop,
		resetAfterCommit: () => {
			if (typeof config.render === 'function') {
github vadimdemedes / reconciled / index.js View on Github external
module.exports = config => {
	ow(config, ow.object.exactShape({
		render: ow.optional.function,
		createNode: ow.function,
		createTextNode: ow.function,
		setTextNodeValue: ow.function,
		appendNode: ow.function,
		insertBeforeNode: ow.optional.function,
		updateNode: ow.optional.function,
		removeNode: ow.optional.function
	}));

	const fullConfig = {
		schedulePassiveEffects: unstable_scheduleCallback, // eslint-disable-line camelcase
		cancelPassiveEffects: unstable_cancelCallback, // eslint-disable-line camelcase
		now: Date.now,
		getRootHostContext: () => NO_CONTEXT,
		prepareForCommit: noop,
		resetAfterCommit: () => {
			if (typeof config.render === 'function') {
				config.render();
			}
		},
github vadimdemedes / reconciled / index.js View on Github external
module.exports = config => {
	ow(config, ow.object.exactShape({
		render: ow.optional.function,
		createNode: ow.function,
		createTextNode: ow.function,
		setTextNodeValue: ow.function,
		appendNode: ow.function,
		insertBeforeNode: ow.optional.function,
		updateNode: ow.optional.function,
		removeNode: ow.optional.function
	}));

	const fullConfig = {
		schedulePassiveEffects: unstable_scheduleCallback, // eslint-disable-line camelcase
		cancelPassiveEffects: unstable_cancelCallback, // eslint-disable-line camelcase
		now: Date.now,
		getRootHostContext: () => NO_CONTEXT,
		prepareForCommit: noop,
		resetAfterCommit: () => {
			if (typeof config.render === 'function') {
				config.render();
			}
github vadimdemedes / reconciled / index.js View on Github external
module.exports = config => {
	ow(config, ow.object.exactShape({
		render: ow.optional.function,
		createNode: ow.function,
		createTextNode: ow.function,
		setTextNodeValue: ow.function,
		appendNode: ow.function,
		insertBeforeNode: ow.optional.function,
		updateNode: ow.optional.function,
		removeNode: ow.optional.function
	}));

	const fullConfig = {
		schedulePassiveEffects: unstable_scheduleCallback, // eslint-disable-line camelcase
		cancelPassiveEffects: unstable_cancelCallback, // eslint-disable-line camelcase
		now: Date.now,
		getRootHostContext: () => NO_CONTEXT,
		prepareForCommit: noop,
		resetAfterCommit: () => {
			if (typeof config.render === 'function') {
				config.render();
github thetutlage / japa / src / Runner / index.ts View on Github external
public reporter (fn: (emitter: EventEmitter) => void): this {
    ow(fn, 'callback', ow.function)
    this._reporterFn = fn
    return this
  }
github hegemonic / jsdoc-baseline / lib / db.js View on Github external
exports.db = ({ config, mixins = exports.mixins, values }) => {
    ow(config, ow.optional.object);
    if (config) {
        ow(config.opts, ow.object);
        ow(config.opts.access, ow.optional.array.ofType(ow.string));
    }
    ow(mixins, ow.object.valuesOfType(ow.function));
    ow(values, ow.array);

    const _ = lodash.runInContext();
    const boundMixins = {};

    Object.keys(mixins).forEach(key => {
        boundMixins[key] = (...args) => mixins[key](_, config, ...args);
    });

    _.mixin(boundMixins);

    return _.chain(values.slice(0));
};
github liaisonjs / liaison / packages / with-roles / src / with-roles.js View on Github external
static $setRole(name, resolver, options = {}) {
      ow(name, ow.string.nonEmpty);
      ow(resolver, ow.function);
      ow(options, ow.object);

      const roles = this.__getRoles();
      const role = new Role(this, name, resolver, options);
      roles[name] = role;

      return role;
    }
github liaisonjs / liaison / packages / layer / src / layer.js View on Github external
$setAfterInvokeReceivedQuery(afterInvokeReceivedQuery) {
    ow(afterInvokeReceivedQuery, ow.function);

    this._afterInvokeReceivedQuery = afterInvokeReceivedQuery;
  }
github KishanBagaria / padding-oracle-attacker / src / padding-oracle.ts View on Github external
const PaddingOracle = (options: PaddingOracleOptions) => {
  const { networkStats, callOracle } = OracleCaller(options)
  const {
    ciphertext, plaintext, origBytes, foundBytes, interBytes, foundOffsets,
    url: _url, blockSize, blockCount, startFromFirstBlock,
    transformPayload, concurrency = 128, isDecryptionSuccess,
    logMode = 'full', isCacheEnabled = true, initFirstPayloadBlockWithOrigBytes = false
  } = options
  ow(_url, 'url', ow.string)
  ow(blockSize, ow.number)
  ow(concurrency, ow.number)
  ow(isDecryptionSuccess, ow.function)
  if (transformPayload) ow(transformPayload, ow.function)
  ow(logMode, ow.string)

  let stopLoggingProgress = false

  function constructPayload({ byteI, blockI, byte, currentPadding }: { byteI: number, blockI: number, byte: number, currentPadding: number }) {
    const firstBlock = Buffer.alloc(blockSize)
    if (initFirstPayloadBlockWithOrigBytes) ciphertext.copy(firstBlock, 0, blockI * blockSize)
    firstBlock[byteI] = byte
    for (const i of range(byteI + 1, blockSize)) {
      const offset = (blockSize * blockI) + i
      const interByte = interBytes[offset]
      firstBlock[i] = interByte ^ currentPadding
    }
    const start = (blockI + 1) * blockSize
    const secondBlock = ciphertext.slice(start, start + blockSize)
    const twoBlocks = Buffer.concat([firstBlock, secondBlock])
github KishanBagaria / padding-oracle-attacker / src / padding-oracle.ts View on Github external
const PaddingOracle = (options: PaddingOracleOptions) => {
  const { networkStats, callOracle } = OracleCaller(options)
  const {
    ciphertext, plaintext, origBytes, foundBytes, interBytes, foundOffsets,
    url: _url, blockSize, blockCount, startFromFirstBlock,
    transformPayload, concurrency = 128, isDecryptionSuccess,
    logMode = 'full', isCacheEnabled = true, initFirstPayloadBlockWithOrigBytes = false
  } = options
  ow(_url, 'url', ow.string)
  ow(blockSize, ow.number)
  ow(concurrency, ow.number)
  ow(isDecryptionSuccess, ow.function)
  if (transformPayload) ow(transformPayload, ow.function)
  ow(logMode, ow.string)

  let stopLoggingProgress = false

  function constructPayload({ byteI, blockI, byte, currentPadding }: { byteI: number, blockI: number, byte: number, currentPadding: number }) {
    const firstBlock = Buffer.alloc(blockSize)
    if (initFirstPayloadBlockWithOrigBytes) ciphertext.copy(firstBlock, 0, blockI * blockSize)
    firstBlock[byteI] = byte
    for (const i of range(byteI + 1, blockSize)) {
      const offset = (blockSize * blockI) + i
      const interByte = interBytes[offset]
      firstBlock[i] = interByte ^ currentPadding
    }
    const start = (blockI + 1) * blockSize
    const secondBlock = ciphertext.slice(start, start + blockSize)

ow

Function argument validation for humans

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis