Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lingojs

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lingojs

A javascript library for formatting and manipulating text (strings).

  • 2.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

lingojs

A javascript library for formatting and manipulating text (strings)

NPM JavaScript Style Guide

Node

Install

npm install --save lingojs

Or

yarn add lingojs

Usage

import lingo from "lingojs";

Or

const lingo = require("lingojs");

CDN

Install

<script src="https://cdn.jsdelivr.net/gh/LarvenLLC/lingojs@latest/lingo.min.js"></script>

Usage

lingo is global and accessible. Therefore, it can be used directly after importing the script via CDN. See CDN Usage Example.

Create

Create an instance of lingo. lingo takes any input (number/string/etc) and tries to convert it into a string.

var myLingo = lingo(1000);

var value = myLingo.value();
// 1000

var myLingo2 = lingo("With a number 1,000");

var value2 = myLingo2.value();
// With a number 1,000

Functions

value

Function to get the (real, final & primitive) value of the manipulated string.

lingo("Tanzania").value();

// Tanzania

add

Function to concatenate words (add a word with a space infront of the string).

lingo("Tanzania")
  .add("the")
  .add("land")
  .add("of")
  .add("Kilimanjaro")
  .add("and")
  .add("Zanzibar")
  .value();

// Tanzania the land of Kilimanjaro and Zanzibar
Parameter (Data Type)Explanation(Sample) ValuesDefault
string (String)text to be added_ "Tanzania"
_ "234^12 USD"
``

convert

Function to convert a string from one naming convention to another.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").convert(
  "sentence",
  "kebab"
);

// tanzania,-the-land-of-kilimanjaro-and-zanzibar
Parameter (Data Type)ExplanationValuesDefault
from (String)current naming convention_ "sentence"
_ "pascal"
_ "snake"
_ "kebab"
_ "camel"
_ "title"
``
to (String)desired naming convention_ "sentence"
_ "pascal"
_ "snake"
_ "kebab"
_ "camel"
_ "title"
"sentence"

format

Function to format a string into a certain naming convention.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").format();

// Tanzania, the land of kilimanjaro and zanzibar

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").format("kebab");

// tanzania,-the-land-of-kilimanjaro-and-zanzibar
Parameter (Data Type)ExplanationValuesDefault
format (String)desired naming convention_ "sentence"
_ "pascal"
_ "snake"
_ "kebab"
_ "camel"
_ "title"
"sentence"

sentence

Function to format a string into the sentence naming convention (sentence case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").sentence();

// Tanzania, the land of kilimanjaro and zanzibar

pascal

Function to format a string into the pascal naming convention (pascal case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").pascal();

// Tanzania,TheLandOfKilimanjaroAndZanzibar

snake

Function to format a string into the snake naming convention (snake case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").snake();

// tanzania,_the_land_of_kilimanjaro_and_zanzibar

kebab | slug

Function to format a string into the kebab/slug naming convention (kebab/slug case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").kebab();
/* is same as */
lingo("Tanzania, the land of Kilimanjaro and Zanzibar").slug();

// tanzania,-the-land-of-kilimanjaro-and-zanzibar

camel

Function to format a string into the camel naming convention (camel case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").camel();

// tanzania,TheLandOfKilimanjaroAndZanzibar

title

Function to format a string into the title naming convention (title case).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").title();

// Tanzania, The Land Of Kilimanjaro And Zanzibar

name

Function to format a string into desired human names convention.

lingo("John Doe Nairobi").name();

// John Doe Nairobi

lingo("John Doe Nairobi").name("fms");

// JDN

lingo("John Doe Nairobi").name("S, F M");

// Nairobi, John Doe

lingo("John Doe Nairobi").name("f.m.s.");

// J.D.N.

lingo("John Doe Nairobi").name("F M");

// John Doe

lingo("John Doe Nairobi").name("F m.s.");

// John D.N.
  • F - first name
  • M - second/middle name
  • S - last name
  • f - first name initial
  • m - second/middle name initial
  • s - last name initial

reverse

Function to reverse the characters in a string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").reverse();

// rabiznaZ dna orajnamiliK fo dnal eht ,ainaznaT

reverseWords

Function to reverse the words in a string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").reverseWords();

// Zanzibar and Kilimanjaro of land the Tanzania,

characters

Function that returns all the characters of a string, separated by commas.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").characters();

// T,a,n,z,a,n,i,a,,,t,h,e,l,a,n,d,o,f,K,i,l,i,m,a,n,j,a,r,o,a,n,d,Z,a,n,z,i,b,a,r

words

Function that returns all the words of a string, separated by commas.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").words();

// Tanzania,,the,land,of,Kilimanjaro,and,Zanzibar

count

Function that returns the number of characters in a string (minus spaces).

For full count with spaces use the 'length' property

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").count();

// 40

countWords

Function that returns the number of words in a string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").countWords();

// 7

chunk

Function that divides a string into segments of equal lengths.

lingo("A89f45eR8dd73Q1T").chunk();

// A89f-45eR-8dd7-3Q1T

lingo("A89f45eR8dd73Q1T").chunk(4, " ");

// A89f 45eR 8dd7 3Q1T

lingo("A89f45eR8dd73Q1T").chunk(2, "/");

// A8/9f/45/eR/8d/d7/3Q/1T
Parameter (Data Type)Explanation(Sample) ValuesDefault
length (Number)length of each chunk_ 2
_ 10
4
separator (String)separator character between chunks_ "/"
_ "#"
_ ""
_ " "
"-"

wrap

Function that wraps the string by specified character(s).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").wrap();

// (Tanzania, the land of Kilimanjaro and Zanzibar)

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").wrap("{}");

// {Tanzania, the land of Kilimanjaro and Zanzibar}

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").wrap("''");

// 'Tanzania, the land of Kilimanjaro and Zanzibar'

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").wrap('""');

// "Tanzania, the land of Kilimanjaro and Zanzibar"

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").wrap("#");

// #Tanzania, the land of Kilimanjaro and Zanzibar#
Parameter (Data Type)Explanation(Sample) ValuesDefault
wrapper (String)character(s) to wrap text. max two characters: one at the start and one at the end of text_ "/"
_ "#"
_ "*"
_ "{}"
"()"

singleQuote

Function that wraps the string by single quotation marks.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").singleQuote();

// 'Tanzania, the land of Kilimanjaro and Zanzibar'

quote | doubleQuote

Function that wraps the string by double quotation marks.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").quote();
/* is same as */
lingo("Tanzania, the land of Kilimanjaro and Zanzibar").doubleQuote();

// "Tanzania, the land of Kilimanjaro and Zanzibar"

initials

Function that returns the initials of the string.

Accepts separator.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").initials();

// T.T.L.O.K.A.Z

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").initials("-");

// T-T-L-O-K-A-Z

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").initials("");

// TTLOKAZ
Parameter (Data Type)Explanation(Sample) ValuesDefault
separator (String)separator character between initials_ "/"
_ "-"
_ ""
_ " "
"."

first

Function that returns the first n characters of the string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").first(8);

// Tanzania

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").first();

// T
Parameter (Data Type)Explanation(Sample) ValuesDefault
length (Number)number of characters from the beginning of text to be returned_ 2
_ 10
1

last

Function that returns the last n characters of the string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").last(8);

// Zanzibar

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").last();

// r
Parameter (Data Type)Explanation(Sample) ValuesDefault
length (Number)number of characters from the end of text to be returned_ 2
_ 10
1

truncate | prune

Function that truncates/clips the string to return the first n characters of the string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").truncate();

// Tanzania,

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").truncate(3);

// Tanzania, the land
Parameter (Data Type)Explanation(Sample) ValuesDefault
length (Number)number of words from the beginning of text to be returned_ 2
_ 10
1

ellipsis

Function that truncates the string to return the first n characters of the string with a set of dots (…) at the end.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").ellipsis();

// Tanzania,...

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").ellipsis(3);

// Tanzania, the land...
Parameter (Data Type)Explanation(Sample) ValuesDefault
length (Number)number of words from the beginning of text to be returned_ 2
_ 10
1

decapitalize | lowerCase

Function to convert the whole string to lower case (small letters).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").decapitalize();
/* is same as */
lingo("Tanzania, the land of Kilimanjaro and Zanzibar").lowerCase();

// tanzania, the land of kilimanjaro and zanzibar

capitalize | upperCase

Function to convert the whole string to upper case (capital letters).

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").capitalize();
/* is same as */
lingo("Tanzania, the land of Kilimanjaro and Zanzibar").upperCase();

// TANZANIA, THE LAND OF KILIMANJARO AND ZANZIBAR

set

Function that overrides the string with a new value.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").set("Lingo");

// Lingo
Parameter (Data Type)Explanation(Sample) ValuesDefault
string (String)new text to override string_ "Lingo"
_ "1000 Tanzanians"
``

Properties

length

Function to return the number of characters in a string.

lingo("Tanzania, the land of Kilimanjaro and Zanzibar").length;

// 46

Keywords

FAQs

Package last updated on 14 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc