Git Product home page Git Product logo

typescript-string-operations's Introduction

Simple lightweight string operation library for Typescript

NPM

USAGE:

String.Empty

var id = String.Empty;

Returns an empty String. Just because we have those in C# ๐Ÿ˜‰

String.IsNullOrWhiteSpace():

var id = image.GetId();
if(String.IsNullOrWhiteSpace(id))
  return image;

Returns a boolean that indicates if a given string is null or contains no printable characters.

String.Format():

var id = image.GetId()
String.Format("image_{0}.jpg", id)
output: "image_2db5da20-1c5d-4f1a-8fd4-b41e34c8c5b5.jpg";

Replaces a given pattern with provided values. The value can further be formatted using the following specifiers:

var value = String.Format("{0:L}", "APPLE"); //output "apple"

value = String.Format("{0:U}", "apple"); // output "APPLE"

value = String.Format("{0:d}", "2017-01-23 00:00"); //output "23.01.2017"


value = String.Format("{0:s}", "21.03.2017 22:15:01") //output "2017-03-21T22:15:01"

value = String.Format("{0:n}", 1000000);
//output "1.000.000"
Specifier Result
L LowerCase
U UpperCase
d ShortDatePattern
s SortableDateTimePattern
n Thousand seperator
000 Pad the number with zeros

String.Join()

var value = String.Join("; ", "Apple", "Banana");
//output: "Apple; Banana";

OR

let array = ['Apple', 'Banana']
let value = String.Join("; ", array);
//output: "Apple; Banana";

Methods

Method Type Description Parameter
Empty Property simply returns "".
IsNullOrWhiteSpace Method returns true value if given parameter is either null, empty or undefined. format, args
Format Method Converts the value of objects to strings based on the formats specified and inserts them into another string. format, args
Join Method Combines arguments delimited by given seperator. delimiter,args
Join Method Combines arguments delimited by given seperator from array. delimiter,array

typescript-string-operations's People

Contributors

aequi42 avatar iwt-svenulrich avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.