Tabnine Logo For Javascript
uniqBy
Code IndexAdd Tabnine to your IDE (free)

How to use
uniqBy
function
in
lodash

Best JavaScript code snippets using lodash.uniqBy(Showing top 13 results out of 315)

origin: kitze/JSUI

get currentDependencies() {
   let allDependencies = self.filteredProjects.reduce((accum, project) => {
    let dependencies =
     project.packageJson && project.packageJson.dependencies
      ? Object.entries({
        ...project.packageJson.dependencies
       }).map(([a]) => a)
      : [];
    accum = [...accum, ...dependencies];
    return accum;
   }, []);

   const grouped = Object.entries(countBy(allDependencies)).map(([name, count]) => ({ name, count }));
   const unique = uniqBy(grouped, a => a.name);
   const sorted = orderBy(unique, ['count', 'name'], ['desc', 'asc']);
   return sorted;
  }
origin: webpack/webpack.js.org

getAllOrders()
 .then(orders => {
  let supporters = orders.map(nodeToSupporter).sort((a, b) => b.totalDonations - a.totalDonations);

  // Deduplicating supporters with multiple orders
  supporters = uniqBy(supporters, 'slug');

  if (!Array.isArray(supporters)) {
   throw new Error('Supporters data is not an array.');
  }

  for (const item of supporters) {
   for (const key of REQUIRED_KEYS) {
    if (!item || typeof item !== 'object') {
     throw new Error(`Supporters: ${JSON.stringify(item)} is not an object.`);
    }
    if (!(key in item)) {
     throw new Error(`Supporters: ${JSON.stringify(item)} doesn't include ${key}.`);
    }
   }
  }

  // Write the file
  return asyncWriteFile(absoluteFilename, JSON.stringify(supporters, null, 2)).then(() =>
   console.log(`Fetched 1 file: ${filename}`)
  );
 })
 .catch(error => {
  console.error('utilities/fetch-supporters:', error);
 });
origin: yTakkar/React-Instagram-Clone-2.0

const addTag = (tags, t) => {
 tags.unshift(t)
 return uniqBy(tags, 'tag')
}
origin: yTakkar/React-Instagram-Clone-2.0

// LOGS USER OUT
app.get('/logout', mw.LoggedIn, async (req, res) => {
 try {
  let { id, username } = req.session,
   user = { id, username },
   oldUsers = req.cookies.users ? JSON.parse(req.cookies.users) : [],
   users = []

  oldUsers.map(o => users.push(o))
  let final = uniqBy([user, ...users], 'id')
  res.cookie('users', `${JSON.stringify(final)}`)

  let u = {
   isOnline: 'no',
   lastOnline: new Date().getTime(),
  }
  await db.query('UPDATE users SET ? WHERE id=?', [u, id])

  let url = req.session.reset() ? '/login' : '/'
  res.redirect(url)
 } catch (error) {
  console.log(error)
 }
})
origin: DimiMikadze/create-social-network

  prev,
  dataKey,
  uniqBy([...previousData, ...fetchMoreData], 'id')
 );
},
origin: mariobermudezjr/ecommerce-react-graphql-stripe

componentWillReceiveProps(nextProps) {
  if (this.props.errors !== nextProps.errors) {
   this.setState({ errors: uniqBy(union(this.state.errors, nextProps.errors), 'id') });
  }
 }
origin: mariobermudezjr/ecommerce-react-graphql-stripe

componentWillReceiveProps(nextProps) {
  if (!this.isSame(nextProps)) {
   const errors = isEmpty(nextProps.errors) ? [] : uniqBy(union(this.state.errors, nextProps.errors), 'id');

   // if (isEmpty(nextProps.errors)) remove(errors, (error) => error.id === 'settings-manager.request.error.database.exist');
   this.setState({ errors });
  }
  if (isEmpty(nextProps.errors)) {
   this.setState({ errors: [] });
  }
 }
origin: MikeBild/graphql-subscriptions-sse-presence-list

componentDidMount () {
  this.props.data.subscribeToMore({
   document: PresenceSubscription,
   variables: {},
   updateQuery: (prev, {subscriptionData}) => {
    const result = { users: prev.users }
    if(subscriptionData.data.onPresence.presence.status === 'LEFT') {
     result.users = differenceBy(prev.users, [subscriptionData.data.onPresence], x => x.id)
     if(subscriptionData.data.onPresence.id === this.state.id) this.setState({id: undefined, alias: undefined})
     return result
    }

    result.users = uniqBy(prev.users.concat([subscriptionData.data.onPresence]), x => x.id)
    return result
   }
  })
 }
origin: motion/repo-man

async statusPackages(options: Object) {
  const table = new this.helpers.Table({ head: ['project', 'changes', 'branch', 'path', 'npm'] })
  let packages = await this.getAllPackages()
  if (options.scope) {
   packages = this.matchPackages(packages, this.helpers.split(options.scope, ','))
  }

  const repositories = await this.processRepositories(uniqBy(packages.map(p => p.project), project => project.path), options)
  const packagesRemote: Map<Package, Package> = new Map()

  await this.helpers.parallel('Getting remote details', packages.map(pkg => ({
   title: pkg.path === pkg.project.path ? `${pkg.project.org}/${pkg.project.name}` : `${pkg.project.org}/${pkg.project.name}/${pkg.name}`,
   // eslint-disable-next-line arrow-parens
   callback: async () => {
    packagesRemote.set(pkg, await this.getNodePackageState(pkg))
   },
  })))

  for (let i = 0, length = packages.length; i < length; i++) {
   const pkg = packages[i]
   const repository = repositories.get(pkg.project)
   const packageRemote = packagesRemote.get(pkg)
   invariant(repository && packageRemote)
   table.push(this.getRow(pkg.project, pkg, packageRemote, repository))
  }
  this.log(table.show())
 }
origin: codetrial/got-auth-service

(uniqBy(roles, 'id') || []).reduce((prev, curr) => {
   return prev.concat(curr.resources || []);
  }, [])
origin: wise-old-man/wise-old-man

/**
 * Returns a list of all groups of which a given player is a member.
 */
async function getPlayerGroups(playerId, pagination = { limit: 10000, offset: 0 }) {
 if (!playerId) {
  throw new BadRequestError(`Invalid player id.`);
 }

 // Find all memberships for the player
 const memberships = await Membership.findAll({
  where: { playerId },
  include: [{ model: Group }]
 });

 // Extract all the unique groups from the memberships, and format them.
 const groups = uniqBy(memberships, (m: any) => m.group.id)
  .slice(pagination.offset, pagination.offset + pagination.limit)
  .map(p => p.group)
  .sort((a, b) => b.score - a.score)
  .map(format);

 const completeGroups = await attachMembersCount(groups);

 return completeGroups;
}
origin: wise-old-man/wise-old-man

const uniqueUsernames = uniqBy(usernames, u => playerService.standardize(u));
origin: JadTermsani/PubgRecords-server

 safetyZoneCoords: uniqBy(safetyZoneCoords, 'x'),
 redZoneCoords: uniqBy(redZoneCoords, 'x'),
 blackZoneCoords: uniqBy(blackZoneCoords, 'x')
};
lodash(npm)uniqBy

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

  • yargs
    yargs the modern, pirate-themed, successor to optimist.
  • request
    Simplified HTTP request client.
  • moment
    Parse, validate, manipulate, and display dates
  • express
    Fast, unopinionated, minimalist web framework
  • minimatch
    a glob matcher in javascript
  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • async
    Higher-order functions and common patterns for asynchronous code
  • crypto
  • Top plugins for Android Studio
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