1.5.0 • Published 6 months ago

nuxt-es-toolkit v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

es-toolkit for Nuxt

npm version npm downloads License Nuxt

es-toolkit auto-import module for Nuxt.

📦 Install

Install nuxt-es-toolkit as development dependency:

npm i nuxt-es-toolkit -D

Add it to the modules section of your nuxt.config:

export default defineNuxtConfig({
  modules: ["nuxt-es-toolkit"],
});

🚀 Example

Use any es-toolkit methods in your Nuxt application, they will be auto-imported!

<script setup>
<template>
  <div>
    <pre>{{ countBy }}</pre>
    <pre>{{ meanBy }}</pre>
    <pre>{{ capitalize }}</pre>
  </div>
</template>

<script setup>
const fish = [
  {
    name: 'Marlin',
    weight: 105,
    source: 'ocean',
  },
  {
    name: 'Bass',
    weight: 8,
    source: 'lake',
  },
  {
    name: 'Trout',
    weight: 1,
    source: 'lake',
  },
]

const ra = {
  Mode: 'god',
  Power: 'sun',
}

// array
const countBy = useCountby(fish, 'weight')
// math
const meanBy = useMeanby(fish, 'weight')
// object
const pick = usePick(ra, ['Mode', 'Power'])
// predicate
const isnil = isNil(ra)
// string
const capitalize = useCapitalize('hello')
</script>

🔨 Config

NameDefaultDescription
prefix'use'String to prepend before each Radash function (false to disable)
prefixSkip'is'Functions that starts with this keywords will be skipped by prefix (false to disable)
upperAfterPrefixtrueIf true it will automatically uppercase first letter after prefix (false to disable)
alias[]Array of array pairs to rename specific Radash functions (prefix is still added)

💻 Example - Config

export default defineNuxtConfig({
  modules: ["nuxt-es-toolkit"],
  'es-toolkit': {
    prefix: 'use',
    prefixSkip: 'is',
    upperAfterPrefix: true,
    alias: [
      ['snake', 'stringToSnake'], // => stringToSnake
    ]
  }
});

Acknowledgement

The development of nuxt-es-toolkit was made possible thanks to the inspiration and code base from nuxt-lodash.

📄 License

MIT License © 2024 - Mang

1.5.0

6 months ago

1.4.0

9 months ago

1.2.2

9 months ago

1.3.0

9 months ago

1.2.1

10 months ago

1.2.0

11 months ago

1.1.0

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

0.0.2

12 months ago

0.0.1

12 months ago