How to use sort-keys - 3 common examples

To help you get started, we’ve selected a few sort-keys 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 akameco / extract-react-intl-messages / src / index.ts View on Github external
locales.map(locale => {
      // If the default locale, overwrite the origin file
      let localeMap =
        locale === defaultLocale
          ? // Create a clone so we can use only current valid messages below
            { ...oldLocaleMaps[locale], ...newLocaleMaps[locale] }
          : { ...newLocaleMaps[locale], ...oldLocaleMaps[locale] }
      // Only keep existing keys
      localeMap = pick(localeMap, Object.keys(newLocaleMaps[locale]))

      const fomattedLocaleMap: object = flat
        ? sortKeys(localeMap, { deep: true })
        : unflatten(sortKeys(localeMap), { object: true })

      const fn = isJson(format) ? writeJson : writeYaml

      return fn(path.resolve(buildDir, locale), fomattedLocaleMap)
    })
  )
github akameco / extract-react-intl-messages / src / index.ts View on Github external
locales.map(locale => {
      // If the default locale, overwrite the origin file
      let localeMap =
        locale === defaultLocale
          ? // Create a clone so we can use only current valid messages below
            { ...oldLocaleMaps[locale], ...newLocaleMaps[locale] }
          : { ...newLocaleMaps[locale], ...oldLocaleMaps[locale] }
      // Only keep existing keys
      localeMap = pick(localeMap, Object.keys(newLocaleMaps[locale]))

      const fomattedLocaleMap: object = flat
        ? sortKeys(localeMap, { deep: true })
        : unflatten(sortKeys(localeMap), { object: true })

      const fn = isJson(format) ? writeJson : writeYaml

      return fn(path.resolve(buildDir, locale), fomattedLocaleMap)
    })
  )

sort-keys

Sort the keys of an object

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular sort-keys functions