How to use the rambdax.prop function in rambdax

To help you get started, we’ve selected a few rambdax 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 Nozbe / WatermelonDB / src / Schema / migrations / index.js View on Github external
+toVersion: SchemaVersion,
  +steps: MigrationStep[],
}>

type SchemaMigrationsSpec = $Exact<{
  +migrations: Migration[],
}>

export type SchemaMigrations = $Exact<{
  +validated: true,
  +minVersion: SchemaVersion,
  +maxVersion: SchemaVersion,
  +sortedMigrations: Migration[],
}>

const sortMigrations = sortBy(prop('toVersion'))

// Creates a specification of how to migrate between different versions of
// database schema. Every time you change the database schema, you must
// create a corresponding migration.
//
// See docs for more details
//
// Example:
//
// schemaMigrations({
//   migrations: [
//     {
//       toVersion: 3,
//       steps: [
//         createTable({
//           name: 'comments',
github Nozbe / WatermelonDB / src / adapters / lokijs / worker / encodeQuery / index.js View on Github external
// Loki's Collection.count() works but count({}) doesn't
const concatRawQueries: (LokiRawQuery[]) => LokiRawQuery = (cond([
  [lengthEq(0), always(undefined)],
  [lengthEq(1), head],
  [T, objOf('$and')],
]): any)

const encodeConditions: (Where[] | On[]) => LokiRawQuery = pipe(
  conditions => map(encodeCondition, conditions),
  concatRawQueries,
)

const encodeMapKey: AssociationInfo => ColumnName = ifElse(
  propEq('type', 'belongs_to'),
  always(columnName('id')),
  prop('foreignKey'),
)

const encodeJoinKey: AssociationInfo => ColumnName = ifElse(
  propEq('type', 'belongs_to'),
  prop('key'),
  always(columnName('id')),
)

const encodeOriginalConditions: (On[]) => Where[] = map(({ left, comparison }) => ({
  type: 'where',
  left,
  comparison,
}))

const encodeJoin: (AssociationArgs, On[]) => LokiJoin = ([table, associationInfo], conditions) => ({
  table,
github selfrefactor / useful-javascript-libraries / src / indexProve.js View on Github external
function isLibrary(library){
  return allTrue(
    prop('isLibrary', library),
    prop('isReact', library) === false,
    prop('isTypescript', library) === false
  )
}
github Nozbe / WatermelonDB / src / adapters / lokijs / worker / executor.js View on Github external
getDeletedRecords(table: TableName): RecordId[] {
    return this.loki
      .getCollection(table)
      .find({ _status: { $eq: 'deleted' } })
      .map(prop('id'))
  }
github selfrefactor / useful-javascript-libraries / src / indexProve.js View on Github external
async function updateFromSelfrefactor(){
  const base = 'https://api.github.com/users/selfrefactor'
  const starsUrl = `${ base }/starred`
  const watchesUrl = `${ base }/subscriptions`
  const { data: stars } = await get(starsUrl)
  const { data: watches } = await get(watchesUrl)

  const links = [ ...stars, ...watches ].map(prop('html_url')).join('\n')
  const bookmarks = readFileSync(BOOKMARKS).toString()

  writeFileSync(BOOKMARKS, `${ bookmarks }\n${ links }`)
}
github selfrefactor / useful-javascript-libraries / src / indexProve.js View on Github external
if (fromSelfrefactor) await updateFromSelfrefactor()
  if (updateSecondary) await updateSecondaryFn()
  if (createData) await createDataJSON()
  if (score) await createScores()
  if (!createReadme) return

  const { repoData } = readJSONSync(REPO_DATA)
  const sorted = sort((a, b) => b.score - a.score, repoData)
  const reposRaw = uniqWith((a, b) => a.name === b.name, sorted)
  const awesomeRepos = reposRaw.filter(isAwesomeRepo)
  const repos = reject(isAwesomeRepo, reposRaw)

  const jsRelated = repos.filter(isJS)
  const jsLibs = jsRelated.filter(isLibrary)
  const reactLibs = jsRelated.filter(prop('isReact'))
  const tsLibs = jsRelated.filter(prop('isTypescript'))
  const jsProjects = jsRelated.filter(complement(prop('isLibrary')))
  const otherLibs = repos.filter(complement(isJS))

  const jsContent = createReadmePartial(jsLibs)
  const awesomeContent = createReadmePartial(awesomeRepos)
  const reactContent = createReadmePartial(reactLibs)
  const tsContent = createReadmePartial(tsLibs)
  const jsProjectsContent = createReadmePartial(jsProjects)
  const otherContent = createReadmePartial(otherLibs)

  const jsTitle = template(TITLE, {
    num : jsLibs.length,
    tag : 'Javascript',
  })
  const awesomeTitle = template(AWESOME_TITLE, {
    num : awesomeRepos.length,
github selfrefactor / useful-javascript-libraries / src / indexProve.js View on Github external
function isLibrary(library){
  return allTrue(
    prop('isLibrary', library),
    prop('isReact', library) === false,
    prop('isTypescript', library) === false
  )
}
github Nozbe / WatermelonDB / src / adapters / lokijs / worker / encodeQuery / index.js View on Github external
const encodeOriginalConditions: (On[]) => Where[] = map(({ left, comparison }) => ({
  type: 'where',
  left,
  comparison,
}))

const encodeJoin: (AssociationArgs, On[]) => LokiJoin = ([table, associationInfo], conditions) => ({
  table,
  query: encodeConditions(conditions),
  originalConditions: encodeOriginalConditions(conditions),
  mapKey: encodeMapKey(associationInfo),
  joinKey: encodeJoinKey(associationInfo),
})

const groupByTable: (On[]) => On[][] = pipe(
  groupBy(prop('table')),
  values,
)

const zipAssociationsConditions: (AssociationArgs[], On[]) => [AssociationArgs, On[]][] = (
  associations,
  conditions,
) => zip(associations, groupByTable(conditions))

const encodeJoins: (AssociationArgs[], On[]) => LokiJoin[] = (associations, on) => {
  const conditions = zipAssociationsConditions(associations, on)
  return map(([association, _on]) => encodeJoin(association, _on), conditions)
}

export default function encodeQuery(query: SerializedQuery): LokiQuery {
  const {
    table,
github Nozbe / WatermelonDB / scripts / make.js View on Github external
const DO_NOT_BUILD_PATHS = [
  /__tests__/,
  /adapters\/__tests__/,
  /test\.js/,
  /integrationTest/,
  /__mocks__/,
  /\.DS_Store/,
  /package\.json/,
]

const isNotIncludedInBuildPaths = value => !anymatch(DO_NOT_BUILD_PATHS, value)

const cleanFolder = dir => rimraf.sync(dir)

const takeFiles = pipe(
  prop('path'),
  both(endsWith('.js'), isNotIncludedInBuildPaths),
)

const takeModules = pipe(
  filter(takeFiles),
  map(prop('path')),
)

const removeSourcePath = replace(SOURCE_PATH, '')

const createModulePath = format => {
  const formatPathSegment = format === CJS_MODULES ? [] : [format]
  const modulePath = resolvePath(DIR_PATH, ...formatPathSegment)
  return replace(SOURCE_PATH, modulePath)
}