JSPM

  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q26735F
  • License MIT

To help on work with Dates, Arrays and Strings

Package Exports

  • dot_functions_utils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dot_functions_utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Dot Functins Utils

NPM Version NPM Downloads Maintenance GitHub issues TravisCi Build

How to use

Install

npm i dot_functions_utils
or
yarn add dot_functions_utils

Dates

require('dot_functions_utils');

var dateNow = new Date;                           // 2020-04-13T14:09:02.649Z

dateNow.getWeekDay();                             // Monday
dateNow.getWeekDay('eng');                        // Monday
dateNow.getWeekDay('es');                         // Lunes
dateNow.getWeekDay('pt-br');                      // Segunda
dateNow.getFirstDay();                            // 2020-04-01T03:00:00.000Z
dateNow.getLastDay();                             // 2020-04-30T03:00:00.000Z
dateNow.getWeekEnd();                             // 2020-04-18T14:09:02.649Z
dateNow.getWeekBegin();                           // 2020-04-12T14:09:02.649Z
dateNow.nextDay(5);                               // 2020-04-18T14:09:02.649Z
dateNow.backDay(5);                               // 2020-04-08T14:09:02.649Z
dateNow.format();                                 // '2020-04-13'
dateNow.format('yyyy-mm-dd');                     // '2020-04-13'
dateNow.format('dd-mm-yyyy');                     // '13-04-2020'
dateNow.nextMonth(1);                             // 2020-05-13T14:09:02.649Z
dateNow.previousMonth(1);                         // 2020-03-13T14:09:02.649Z
dateNow.nextYear(1);                              // 2021-04-13T14:09:02.649Z
dateNow.previousYear(1);                          // 2019-04-13T14:09:02.649Z
dateNow.getMonthName();                           // April
dateNow.getMonthName('eng');                      // April
dateNow.getMonthName('es');                       // Abril
dateNow.getMonthName('pt-br');                    // Abril
dateNow.getDayOfYear();                           // 105

Arrays

require('dot_functions_utils');

let list = [1, 2, 3, 4];
let myList = [2, 3, 4];

list.getLastElement();                            // 4
list.getFirstElement();                           // 1
list.getMiddleElement();                          // [2, 3]
myList.getMiddleElement();                        // [3]

Strings

require('dot_functions_utils');

let myFirstString = '1';

myFirstString.twoDigits();                        // '01'
myFirstString.threeDigits();                      // '001'

let mySecondString = '11';

mySecondString.twoDigits();                       // '11'
mySecondString.threeDigits();                     // '011'

let myThirdString = '123';

myThirdString.twoDigits();                        // '123'
myThirdString.threeDigits();                      // '123'

let myFourthString = 'my string';

myFourthString.captalize();                       // 'My string'
myFourthString.captalizeAll();                    // 'My String'

let myString = 'my string';

myFourthString.splitToArray(3);                   // [ 'my ', 'str', 'ing' ]
myFourthString.splitToArray(2);                   // [ 'my', ' s', 'tr', 'in', 'g' ]

myString = '';

myString.splitToArray(2);                         // []

myString = 'Hello World!';

myString.toBase64();                              // 'SGVsbG8gV29ybGQh'

myString = 'SGVsbG8gV29ybGQh';

myString.fromBase64();                            // 'Hello World!'

myString = 'Hello World!';

myString.decapitalize();                          // 'hello World!'

Functions

const { threeDigits, twoDigits, generateUniqueID  } = require('dot_functions_utils');

let firstString = '1';

twoDigits(firstString);                           // '01'
threeDigits(firstString);                         // '001'

let secondString = '11';

twoDigits(secondString);                          // '11'
threeDigits(secondString);                        // '011'

let thirdString = '123';

twoDigits(thirdString);                           // '123'
threeDigits(thirdString);                         // '123'

generateUniqueID ();                              // "3ace9a54-524e-c7df-9556-c97042413565"


npm