How to use the @redux-saga/is.array function in @redux-saga/is

To help you get started, we’ve selected a few @redux-saga/is 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 redux-saga / redux-saga / packages / core / src / internal / effectRunnerMap.js View on Github external
function runCancelEffect(env, taskOrTasks, cb, { task }) {
  if (taskOrTasks === SELF_CANCELLATION) {
    cancelSingleTask(task)
  } else if (is.array(taskOrTasks)) {
    taskOrTasks.forEach(cancelSingleTask)
  } else {
    cancelSingleTask(taskOrTasks)
  }
  cb()
  // cancel effects are non cancellables
}
github redux-saga / redux-saga / packages / core / src / internal / matcher.js View on Github external
export default function matcher(pattern) {
  // prettier-ignore
  const matcherCreator = (
      pattern === '*'            ? wildcard
    : is.string(pattern)         ? string
    : is.array(pattern)          ? array
    : is.stringableFunc(pattern) ? string
    : is.func(pattern)           ? predicate
    : is.symbol(pattern)         ? symbol
    : null
  )

  if (matcherCreator === null) {
    throw new Error(`invalid pattern: ${pattern}`)
  }

  return matcherCreator(pattern)
}
github redux-saga / redux-saga / packages / core / src / internal / io.js View on Github external
function getFnCallDescriptor(fnDescriptor, args) {
  let context = null
  let fn

  if (is.func(fnDescriptor)) {
    fn = fnDescriptor
  } else {
    if (is.array(fnDescriptor)) {
      ;[context, fn] = fnDescriptor
    } else {
      ;({ context, fn } = fnDescriptor)
    }

    if (context && is.string(fn) && is.func(context[fn])) {
      fn = context[fn]
    }
  }

  return { context, fn, args }
}
github redux-saga / redux-saga / packages / simple-saga-monitor / src / modules / DescriptorFormatter.js View on Github external
addDescResult(descriptor, ignoreResult) {
    const { status, result, error, duration } = descriptor
    if (status === RESOLVED && !ignoreResult) {
      if (is.array(result)) {
        this.addValue(' 🡲 ')
        this.addValue(result)
      } else {
        this.appendData('🡲', result)
      }
    } else if (status === REJECTED) {
      this.appendData('🡲 ⚠', error)
    } else if (status === PENDING) {
      this.appendData('⌛')
    } else if (status === CANCELLED) {
      this.appendData('🡲 Cancelled!')
    }
    if (status !== PENDING) {
      this.appendData(`(${duration.toFixed(2)}ms)`)
    }
github redux-saga / redux-saga / packages / core / src / internal / effectRunnerMap.js View on Github external
function runAllEffect(env, effects, cb, { digestEffect }) {
  const effectId = currentEffectId
  const keys = Object.keys(effects)
  if (keys.length === 0) {
    cb(is.array(effects) ? [] : {})
    return
  }

  const childCallbacks = createAllStyleChildCallbacks(effects, cb)
  keys.forEach(key => {
    digestEffect(effects[key], effectId, childCallbacks[key], key)
  })
}
github redux-saga / redux-saga / packages / core / src / internal / io.js View on Github external
export function join(taskOrTasks) {
  if (process.env.NODE_ENV !== 'production') {
    if (arguments.length > 1) {
      throw new Error('join(...tasks) is not supported any more. Please use join([...tasks]) to join multiple tasks.')
    }
    if (is.array(taskOrTasks)) {
      taskOrTasks.forEach(t => {
        check(t, is.task, `join([...tasks]): argument ${t} is not a valid Task object ${TEST_HINT}`)
      })
    } else {
      check(taskOrTasks, is.task, `join(task): argument ${taskOrTasks} is not a valid Task object ${TEST_HINT}`)
    }
  }

  return makeEffect(effectTypes.JOIN, taskOrTasks)
}
github redux-saga / redux-saga / packages / core / src / internal / effectRunnerMap.js View on Github external
if (taskToJoin.isRunning()) {
      const joiner = { task, cb }
      cb.cancel = () => {
        if (taskToJoin.isRunning()) remove(taskToJoin.joiners, joiner)
      }
      taskToJoin.joiners.push(joiner)
    } else {
      if (taskToJoin.isAborted()) {
        cb(taskToJoin.error(), true)
      } else {
        cb(taskToJoin.result())
      }
    }
  }

  if (is.array(taskOrTasks)) {
    if (taskOrTasks.length === 0) {
      cb([])
      return
    }

    const childCallbacks = createAllStyleChildCallbacks(taskOrTasks, cb)
    taskOrTasks.forEach((t, i) => {
      joinSingleTask(t, childCallbacks[i])
    })
  } else {
    joinSingleTask(taskOrTasks, cb)
  }
}