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

ts-operator-lib

v1.1.0

Published

```ts indexOfKey(key: string, value: any): Number findSingle(key: string, value: any): object findMulti(key: string, value: any): Array<any> findMultiForObject(obj: Array<any>, find: any, type: 'number' | 'string'): Array<any> orderBy(key: string, so

Downloads

2

Readme

Prototypes

Array & Objects

indexOfKey(key: string, value: any): Number
findSingle(key: string, value: any): object
findMulti(key: string, value: any): Array<any>
findMultiForObject(obj: Array<any>, find: any, type: 'number' | 'string'): Array<any>
orderBy(key: string, sort_type: `asc` | `desc`): Array<any>

//Usage --------------------------------------------------------------------    
let value: Array<any> = [{id:1,type:1},{id:2,type:2},{id:3,type:2}];
value.indexOfKey('id',2); //return 1.index
value.findSingle('id',2); //return {id:2,type:2}
value.findMulti('type',2); //return [{id:2,type:2},{id:3,type:2}]
value.orderBy('type','desc'); //return [{id:2,type:2},{id:3,type:2},{id:1,type:1}]

Date

addDays(n: any): Date
nextDay() : Date
addMonths(n: any): Date
addYears(n: any): Date
getStringWithMask(mask: string | DateMask, utc?: boolean) : string
diffMinutes(date: Date): Number

//Usage --------------------------------------------------------------------    
let date = new Date();
data.addDays(1);
data.nextDay(1);
data.addMonths(1);
data.addYears(1);
data.getStringWithMask(DateMask.ALL);
data.diffMinutes(new Date());

Math

Random(min: number, max: number): Number
Range(value:number,min: number, max: number,equal: boolean): Boolean

//Usage --------------------------------------------------------------------    
Math.Random(10,350); //return a number between 10 and 350
Math.Range(50,1,100); //return true

Number

isInt(): boolean
isFloat(): boolean

//Usage --------------------------------------------------------------------    
let numb = 10;
numb.isInt(); //return true 
numb.isFloat(); //return false 

String

replaceAll(find: string, replace: string): string
replaceArray(find: Array<string>, replace: Array<string>): string
removeLastChar(remove_count?: number): string
Encode(): string
Decode(): string
convertKey(): string
stripTags(): string
convertSEOUrl(): string

Variables

Variables Functions

Clear(variable: any, type: ClearTypes = ClearTypes.STRING, clear_html_tags = true) : any
ClearAllData(data: object | any, not_column: Array<string> = []) : object | any
isSet(...variable: any) : boolean
isEmpty(...variable: any) : boolean
setDefault(variable: any, default_value: any) : any
filterVar(variable: any, filter_type: FilterTypes) : string

Variables Types

export enum FilterTypes {
    EMAIL,
    INT,
    FLOAT
}

export enum ClearTypes {
    STRING,
    EMAIL,
    INT,
    FLOAT,
    SEO_URL,
    ALPHABETS
}

export enum DateMask {
    ALL = "yyyy-mm-dd HH:MM:ss",
    UNIFIED_ALL = "yyyymmddHHMMss",
    DATE = "yyyy-mm-dd"
}

Usage

import {DateMask,Statement,ClearTypes,User,Variabl} from 'ts-operator-lib'

let string = `test`;
string.replaceAll(`t`, `e`);

let number = 10;
let str = `hello my friend I'm good `;

console.log('Number isInt: ',number.isInt())
console.log('Number isFloat: ',number.isFloat())
console.log('String Encode: ',str.Encode())


let date = new Date();
console.log(date, date.getStringWithMask(DateMask.ALL));

let c = Statement.Switch(number, [
    [1, () => false],
    [2, () => false],
    [10, () => true],
    [`default`, () => null]
])
console.log(c);