nestjs-slug
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Nest Logo

nestjs-slug

It's a simple idea for changing any text into a slug for the url.

Install it

$ npm install nestjs-slug --save

Package uses

The package consists of two methods:

generateSlug(text: string, options?: {
    seperator?: string;
    lowerCase?: boolean;
    upperCase?: boolean;
    length?: number;
    trim?: boolean;
    timestamp?: boolean;
    trimBySepator?: number;
    removeSpecialCharacters?: boolean;
}) : string

  isSlug(text: string): boolean  <-- to check if a slug

Examples

importing SlugService in app.service.ts:

  import { Injectable } from '@nestjs/common';
  import { SlugService } from 'nestjs-slug'; <---

  @Injectable()
  export class AppService {

    slug:string = "";

    constructor(
      private slugService: SlugService  <---
    ){}

    this.slug = this.slugService.generateSlug("iphone 14 pro max black")
    
  }

License

nestjs-slug is MIT licensed.

Package Sidebar

Install

npm i nestjs-slug

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

7.58 kB

Total Files

8

Last publish

Collaborators

  • aavision