npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@youmaole/easy-js

v2.0.3

Published

A lib to make the complex and daily used functions easy to use.

Downloads

6

Readme

easy-js

A lib to make the complex and daily used functions easy to use.

Install

  • npm i @youmaole/easy-js
  • yarn add @youmaole/easy-js

Import

import { store, json, string, array, object } from '@youmaole/easy-js'; // for version 1.x.x
import { store, json, object } '@youmaole/easy-js'; // for version 2.x.x

Deprecated methods

The deprecated methods will not be removed, available to use. But not be maintained.

Usage for local storage

Methods for storing data in local(by localStorage): store.saveL(key, value)

  • Example: store.saveL('test', {text: 'this is a test string for saving local'});

Methods for getting data from local: store.readL(key)

  • Example: store.readL('test');

Methods for deleting data(single) from local: store.deleteL(key)

  • Example: store.deleteL('test');

Methods for deleting all data from local: store.deleteA()

  • Example: store.deleteA();

Usage for json

Methods for covert object to string: json.toStr(obj)

  • Example: json.toStr({key: 'this is a test object'});

Methods for covert string to object: json.toObj(str)

  • Example:
var objectString = json.toStr({key: 'this is a test object'});
var object = json.toObj(objectString);

Usage for string V2

Methods to upper case:

//string.ymlUpper()
const test = '123xyzabc';
test.ymlUpper(); // 123XYZABC

Methods to lower case:

//string.ymlLower()
const test = '123XYZABC';
test.ymlLower(); // 123xyzabc

Methods to trim all space:

//string.ymlTrim()
const test = '123 X Y Z A B C';
test.ymlTrim(); // 123XYZABC

Methods to replace all:

//string.ymlReplace(source, target)
const test = 'abcabdabeabfab';
test.ymlReplace('ab', '-'); // -c-d-e-f-

Methods to compare string ignore case:

//string.ymlCompareIgnoreCase(target)
const test = 'ABC';
test.ymlCompareIgnoreCase('abC'); // true

Methods to compare string ignore space:

//string.compareIgnoreSpace(target)
const test = 'ABC';
test.compareIgnoreSpace('A BC'); // true

Usage for array V2

Methods to compare array with sort:

//array.ymlCompareWithSort(target)
const test = [1, 2, 'a'];
test.ymlCompareWithSort(['a', 2, 1]); // true
test.ymlCompareWithSort([1, 2, 'a', 3]); // false

Methods to compare array with sort:

//array.ymlCompareWithoutSort(target)
cosnt test = [1, 2, 'a'];
test.ymlCompareWithoutSort(['a', 2, 1]); // false
test.ymlCompareWithoutSort([1, 2, 'a']); // true

Methods to delete element from array by indexes quickly:

//array.ymlDelete(indexes)
const test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
test.ymlDelete([9, 2, 7, 1]); // [1, 4, 5, 6, 7, 9]

Methods to unique not object element:

//array.ymlUnique()
const test = [1,2,3,4,2,2,1,3];
test.ymlUnique(); // [1,2,3,4]

Methods to unique object element by specified field:

//array.ymlUniqueObject(field)
const test = [{a:1, b: 2}, {a: 1, b: 3}];
test.ymlUniqueObject('a'); // [{a: 1, b: 3}]

Methods to sum:

//array.ymlSum()
const test = [1,2,3,4,5];
test.ymlSum(); // 15

Usage for object

Methods to compare the values of object without nested object:

//object.ymlObjEqual(o1, o2)
const o1 = {a: 1, b: 2};
const o2 = {a: 1, b: 2};
const o3 = {a: 1};
object.ymlObjEqual(o1, o2); // true
object.ymlObjEqual(o1, o3); // false

Methods to check contained object without nested object:

//object.ymlObjContains(o1, o2)
const o1 = {a: 1, b: 2};
const o2 = {a: 1, b: 2};
const o3 = {a: 1};
const o4 = {a: 1, c: 2};
object.ymlObjContains(o1, o2); // true
object.ymlObjContains(o1, o3); // true
object.ymlObjContains(o1, o4); // false

Usage for string @deprecated

Methods to upper case: string.upper(str)

  • Example: string.upper('abc'); //ABC

Methods to lower case: string.lower(str)

  • Example: string.lower('ABC'); //abc

Methods to trim all space: string.trim(str)

  • Example: string.trim('ab c d e f g '); //abcdefg

Methods to replace all: string.replace(str, ori, tar)

  • Example: string.replace('abcabdabeabfab', 'ab', '-'); //-c-d-e-f-

Methods to compare string ignore case: string.compareIgnoreCase(str1, str2)

  • Example: string.compareIgnoreCase('ABC', 'abC'); //true

Methods to compare string ignore space: string.compareIgnoreSpace(str1, str2)

  • Example: string.compareIgnoreSpace('ABC', 'A BC'); //true

Usage for array @deprecated

Methods to compare array with sort: array.compareWithSort(array1, array2)

  • Example: array.compareWithSort([1, 2, 'a'], ['a', 2, 1]); //true
  • Example: array.compareWithSort([1, 2, 'a', 3], ['a', 2, 1]); //false

Methods to compare array with sort: array.compareWithoutSort(array1, array2)

  • Example: array.compareWithoutSort([1, 2, 'a'], ['a', 2, 1]); //false
  • Example: array.compareWithoutSort([1, 2, 'a'], [1, 2, 'a']); //true

Methods to delete element from array by indexes quickly: array.delete(sourceArray, indexesArray)

  • Example: array.delete([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [9, 2, 7, 1]); //[1, 4, 5, 6, 7, 9]

Note

  • Convert the date object to string before storing to local
  • No possible to handle object element in array compare functions