Tabnine Logo For Javascript
LoDashStatic.castArray
Code IndexAdd Tabnine to your IDE (free)

How to use
castArray
function
in
LoDashStatic

Best JavaScript code snippets using lodash.LoDashStatic.castArray(Showing top 7 results out of 315)

origin: Flood-UI/flood

addNotification(notifications) {
  notifications = _.castArray(notifications);

  this.count.total = this.count.total + notifications.length;
  this.count.unread = this.count.unread + notifications.length;

  const timestamp = Date.now();
  const notificationsToInsert = notifications.map(notification => ({
   ts: timestamp,
   data: notification.data,
   id: notification.id,
   read: false,
  }));

  this.db.insert(notificationsToInsert, () => this.emitUpdate());
 }
origin: an-sh/chat-service

// for transport plugins integration
 onConnect (id) {
  if (this.hooks.onConnect) {
   return Promise.try(() => execHook(this.hooks.onConnect, this, id))
    .then(loginData => _.castArray(loginData))
    .catch(logError)
  } else {
   return Promise.resolve([])
  }
 }
origin: an-sh/chat-service

setAdapterOptions () {
  // adapter options compatibility
  this.adapterConstructor = this.transportOptions.adapter ||
   this.options.adapter || 'memory'
  this.adapterOptions = _.castArray(
   this.transportOptions.adapterOptions || this.options.adapterOptions)
  const opts = {
   adapterConstructor: this.adapterConstructor,
   adapterOptions: this.adapterOptions
  }
  this.transportOptions = _.assign(opts, this.transportOptions)
 }
origin: LindenHolt-Whittaker/styleguidist-bug-reproduction

const getSectionComponents = (section, config) => {
  let ignore = config.ignore ? _.castArray(config.ignore) : [];
  if (section.ignore) {
    ignore = ignore.concat(_.castArray(section.ignore));
  }

  return getComponents(getComponentFiles(section.components, config.configDir, ignore), config);
}
origin: an-sh/chat-service

setEvents () {
  if (this.middleware) {
   const middleware = _.castArray(this.middleware)
   for (const fn of middleware) {
    this.nsp.use(fn)
   }
  }
  this.nsp.on('connection', socket => {
   return run(this, function * () {
    const id = socket.id
    const [userName, authData = {}] = yield this.server.onConnect(id)
    if (!userName) {
     return Promise.reject(new ChatServiceError('noLogin'))
    }
    yield this.server.registerClient(userName, id)
    this.confirmLogin(socket, userName, authData)
   }).catch(error => this.rejectLogin(socket, error))
  })
 }
origin: an-sh/chat-service

constructor (server, options) {
  this.server = server
  this.options = options
  this.closed = false
  if (this.options.useCluster) {
   this.redis = new Redis.Cluster(...this.options.redisOptions)
  } else {
   const redisOptions = _.castArray(this.options.redisOptions)
   this.redis = new Redis(...redisOptions)
  }
  this.RoomState = RoomStateRedis
  this.UserState = UserStateRedis
  this.DirectMessagingState = DirectMessagingStateRedis
  this.lockTTL = this.options.lockTTL || 10000
  this.instanceUID = this.server.instanceUID
  this.server.redis = this.redis
  for (const [cmd, def] of _.toPairs(luaCommands)) {
   this.redis.defineCommand(cmd, {
    numberOfKeys: def.numberOfKeys,
    lua: def.lua
   })
  }
 }
origin: an-sh/chat-service

function cleanup (services, sockets, done) {
 services = _.castArray(services)
 sockets = _.castArray(sockets)
 return Promise.try(() => {
  for (let i = 0; i < sockets.length; i++) {
   const socket = sockets[i]
   socket && socket.disconnect()
  }
  if (customCleanup) {
   return Promise.fromCallback(customCleanup)
  } else {
   return Promise.map(services, closeInstance)
  }
 }).timeout(3000).catch(Promise.TimeoutError, e => {
  console.log('Service closing timeout: ', e)
 }).finally(() => {
  customCleanup = null
  return cleanDB()
 }).asCallback(done)
}
lodash(npm)LoDashStaticcastArray

JSDoc

Casts value as an array if it’s not one.

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • http
  • lodash
    Lodash modular utilities.
  • colors
    get colors in your node.js console
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • express
    Fast, unopinionated, minimalist web framework
  • body-parser
    Node.js body parsing middleware
  • ms
    Tiny millisecond conversion utility
  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • async
    Higher-order functions and common patterns for asynchronous code
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now