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

How to use
Set
in
lodash

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

origin: d-lazarev/react-tetris

/**
 * Returns true if coordinates are within grid bounds.
 *
 * @param {array} grid
 * @param {Set} coordinateSet - set of [row,col] coordinates for given block
 */
export function isWithinGridBounds(grid, coordinateSet) {
  return coordinateSet.keysArray().every(([row, col]) => {
    return row >= 0 && row < grid.length && col >= 0 && col < grid[0].length;
  });
}
origin: DenisCarriere/mbtiles-offline

// Quadkey Schema
async function quadkey() {
  const tile = '1'
  const db = new MBTiles('foo', 'quadkey')
  await db.findOne(tile)
  await db.save(tile, image)
  await db.update(options)
  await db.delete(tile)
  const tiles: string[] = await db.findAll()
  const hashes = await db.hashes()
  hashes.size
  const container: Container = {}
  container['foo'].findOne(tile)
}
origin: DenisCarriere/mbtiles-offline

test('MBTiles -- plain_1', t => {
 const db = new MBTiles(directories.in + 'plain_1.mbtiles')

 Promise.all([
  db.metadata().then(metadata => t.deepEqual(metadata, metadataPlain1, 'metadata')),
  db.tables().then(status => t.assert(status, 'tables')),
  db.count().then(count => t.equal(count, 285, 'count')),
  db.findAll().then(tiles => t.equal(tiles.length, 285, 'findAll')),
  db.findOne([0, 0, 0]).then(image => t.equal(image.byteLength, 7072, 'findOne')),
  db.findOne([15, 9, 4]).then(image => t.equal(image.byteLength, 1167, 'findOne - resolves correctly')),
  db.hashes().then(hashes => t.equal(hashes.size, 285, 'hashes'))
 ]).then(() => {
  t.equal(db.hash([0, 0, 0]), 1, 'hash')
  t.end()
 })
})
origin: DenisCarriere/mbtiles-offline

test('MBTiles -- hashes', t => {
 const db1 = new MBTiles(directories.out + 'hashes-quadkey.mbtiles', 'quadkey')
 const db2 = new MBTiles(directories.out + 'hashes-tms.mbtiles', 'tms')
 const db3 = new MBTiles(directories.out + 'hashes-xyz.mbtiles', 'xyz')

 Promise.all([
  db1.save('021', Buffer.from([0, 1])),
  db2.save([1, 5, 3], Buffer.from([0, 1])),
  db3.save([1, 2, 3], Buffer.from([0, 1]))
 ]).then(() => {
  db1.hashes().then(hashes1 => {
   db2.hashes().then(hashes2 => {
    db3.hashes().then(hashes3 => {
     t.true(hashes1.has(hashes2.values().next().value), 'hashes1 contains hashes2')
     t.true(hashes2.has(hashes3.values().next().value), 'hashes2 contains hashes2')
    })
   })
  })
 })

 t.end()
})
origin: DenisCarriere/mbtiles-offline

// Default (TMS/XYZ Schema)
async function main() {
  const tile: Tile = [0, 0, 0]
  const db = new MBTiles(path.join(__dirname, 'test', 'in', 'plain_1.mbtiles'), 'tms')
  // Class properties
  db.db
  db.uri
  // Class methods
  await db.metadata()
  await db.count()
  await db.tables()
  await db.findAll()
  await db.findOne(tile)
  await db.index()
  await db.save(tile, image)
  await db.update(options)
  await db.delete(tile)
  const tiles: Tile[] = await db.findAll()
  const hashes = await db.hashes()
  hashes.size
  const container: Container = {}
  container['foo'].findOne(tile)

  // Sync functions
  db.metadataSync((error, metadata) => {})
  db.findOneSync(tile, (error, image) => {})
}
origin: DenisCarriere/mbtiles-offline

test('MBTiles -- blank', t => {
 const db = new MBTiles(directories.in + 'blank.mbtiles')

 Promise.all([
  db.metadata().then(metadata => t.deepEqual(metadata, baseMetadata, 'metadata')),
  db.count().then(count => t.equal(count, 0, 'count')),
  db.tables().then(status => t.true(status, 'tables')),
  db.findAll().then(tiles => t.equal(tiles.length, 0, 'findAll')),
  db.findOne([0, 0, 0]).then(image => t.not(image, 'findOne')),
  db.findOne([10, 0, 0]).then(image => t.not(image, 'findOne')),
  db.hashes().then(hashes => t.equal(hashes.size, 0, 'hashes'))
 ])
 .then(() => {
  t.equal(db.hash([0, 0, 0]), 1, 'hash')
  t.end()
 })
})
origin: d-lazarev/react-tetris

/**
 * Returns true if the given block's position does not collide
 * with another block on the grid.
 *
 * Note: if the block is out of grid bounds,
 * it is technically NOT colliding with an existing block,
 * and so this will return true.
 *
 * @param {array} grid - matrix
 * @param {Set} coordinateSet - set of [row,col] coordinates for given block
 */
export function hasNoBlockCollisions(grid, coordinateSet) {
  return coordinateSet.keysArray().every(([row, col]) => {
    return grid[row] === undefined || grid[row][col] === null;
  });
}
lodash(npm)Set

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

  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • request
    Simplified HTTP request client.
  • express
    Fast, unopinionated, minimalist web framework
  • winston
    A logger for just about everything.
  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • crypto
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • glob
    a little globber
  • node-fetch
    A light-weight module that brings window.fetch to node.js
  • 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