@huz-com/slugify

Slugifies text, array and map

Usage no npm install needed!

<script type="module">
  import huzComSlugify from 'https://cdn.skypack.dev/@huz-com/slugify';
</script>

README

Huz.Com > Component > Slugify

Slugifies text, text array and text map

Standards

  • Language: TS
  • Eslint: Yes
  • Static Code Analysis: Yes IntelliJ Code Inspections
  • DDD - Document Driven: Yes
  • EDD - Exception Driven: Yes
  • TDD - Test Driven: Yes go to test folder
  • Standards Complied: Huz Standards

Commands

  • npm run clear // clears "dist" folder
  • npm run lint // runs eslint for static code analysis
  • npm run test // runs test files in "test" folder
  • npm run build // builds JS files at "dist" folder
  • npm publish or npm run publix // publishes "dist" folder to npm

Install

npm i @huz-com/slugify

Sample

const {slugify} = require('@huz-com/slugify');
// to build slug, code etc
slugify.dashText('Hello world!'); // =>> 'hello-world'
slugify.dashText('Hello /? world!'); // =>> 'hello-world'
slugify.dashText('!Hello world!'); // =>> 'hello-world'
slugify.dashArray(["€1000","İSTANBUL/TÜRKİYE"]); // =>> '["euro-1000","istanbul-turkiye"]
slugify.dashMap({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro-1000", place: "istanbul-turkiye"}
//dashAny discover input and responses according to type (union of dashText, dashArray, dashMap)
slugify.dashAny('Hello world!'); // =>> 'hello-world'
slugify.dashAny(["€1000","İSTANBUL/TÜRKİYE"]); // =>> '["euro-1000","istanbul-turkiye"]
slugify.dashAny({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro-1000", place: "istanbul-turkiye"}

// to build raw, plain etc
slugify.plainText('Hello world!'); // =>> ''helloworld'
slugify.plainText('Hello /? world!'); // =>> ''helloworld'
slugify.plainText('!Hello world!'); // =>> ''helloworld'
slugify.plainArray(["€1000","İSTANBUL/TÜRKİYE"]); // =>> '["euro1000","istanbulturkiye"]
slugify.plainMap({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro1000", place: "istanbulturkiye"}
//plainAny discover input and responses according to type (union of plainText, plainArray, plainMap)
slugify.plainAny('Hello world!'); // =>> ''helloworld'
slugify.plainAny({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro1000", place: "istanbulturkiye"}
slugify.plainAny({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro1000", place: "istanbulturkiye"}

// to build sql like
slugify.keywordText('Hello world!'); // =>> ''hello%world'
slugify.keywordText('Hello /? world!'); // =>> ''hello%world'
slugify.keywordText('!Hello world!'); // =>> ''hello%world'
slugify.keywordArray(["€1000","İSTANBUL/TÜRKİYE"]); // =>> '["euro%1000","istanbul%turkiye"]
slugify.keywordMap({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro%1000", place: "istanbul%turkiye"}
//keywordAny discover input and responses according to type (union of keywordText, keywordArray, keywordMap)
slugify.keywordAny('Hello world!'); // =>> ''hello%world'
slugify.keywordAny({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro%1000", place: "istanbul%turkiye"}
slugify.keywordAny({price: '€1000', place: 'İSTANBUL/TÜRKİYE'}); // =>> '{price: "euro%1000", place: "istanbul%turkiye"}