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

javascript-trickster

v1.0.1

Published

Trickster is a javascript library of wrapped functions of javascript tricks.

Downloads

7

Readme

Trickster


Trickster is a javascript library of wrapped functions of javascript tricks.

Table of Contents

Installation

With NPM

npm install javascript-trickster

With Github (also run example)

git clone https://github.com/fauzan121002/trickster.git
cd trickster
npm start

Usage

Format JSON

Format Object to JSON

console.log(trickster.formatJSON({name: "trickster"}));
// expected result : 
/* {
       "name": "trickster"
   } */

Get unique array values

Get unique values from array

console.log(trickster.getUniqueArrayValues(["name","trickster","lorem","lorem","trickster"]));
// expected result : 
// [ 'name', 'trickster', 'lorem' ]

Filter falsy values of array

Filter falsy values of array (e.g NaN,0,"",false,etc.)

console.log(trickster.filterFalsy([NaN,"trickster",0,"",false]));
// expected result : 
// [ 'trickster' ]

Sort number of array

Sort number of array

console.log(trickster.sortNumberArray([1,2,99,4,88,1002,103,72]));
// expected result : 
/* [
      1,  2,   4,   72,
      88, 99, 103, 1002
   ] */

Merge any

Merge anything (e.g object,Array,string,null or undefined,etc.)

console.log(trickster.mergeAny([1,2,99,4,88,1002,103,72],"hi"));
// expected result : 
/* [
      1,    2,    99,  4,
      88,   1002, 103, 72,
      'hi'
   ] */

Transform the argument object to array

Transform the arguments object into an array

console.log(trickster.transform());
// expected result : 
/* [
      {},
      [Function: require] {
         resolve: [Function: resolve] { paths: [Function: paths] },
         main: Module {
            id: '.',
            path: 'D:\\Projects\\Javascript\\trickster',
            exports: {},
            parent: null,
            filename: 'D:\\Projects\\Javascript\\trickster\\trickster',
            loaded: false,
            children: [Array],
            paths: [Array]
         },
         extensions: [Object: null prototype] {
            '.js': [Function (anonymous)],
            '.json': [Function (anonymous)],
            '.node': [Function (anonymous)]
         },
         cache: [Object: null prototype] {
            'D:\\Projects\\Javascript\\trickster\\trickster': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\index.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\format_json.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\get_unique_array_values.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\filter_falsy_values.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\sort_number_array.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\merge_any.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\transform.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\html_escape.js': [Module],
            'D:\\Projects\\Javascript\\trickster\\src\\random_number_with_range.js': [Module]
         }
      },
      Module {
         id: 'D:\\Projects\\Javascript\\trickster\\src\\transform.js',
         path: 'D:\\Projects\\Javascript\\trickster\\src',
         exports: [Function (anonymous)],
         parent: Module {
            id: 'D:\\Projects\\Javascript\\trickster\\src\\index.js',
            path: 'D:\\Projects\\Javascript\\trickster\\src',
            exports: [Object],
            parent: [Module],
            filename: 'D:\\Projects\\Javascript\\trickster\\src\\index.js',
            loaded: true,
            children: [Array],
            paths: [Array]
         },
         filename: 'D:\\Projects\\Javascript\\trickster\\src\\transform.js',
         loaded: true,
         children: [],
         paths: [
            'D:\\Projects\\Javascript\\trickster\\src\\node_modules',
            'D:\\Projects\\Javascript\\trickster\\node_modules',
            'D:\\Projects\\Javascript\\node_modules',
            'D:\\Projects\\node_modules',
            'D:\\node_modules'
         ]
      },
      'D:\\Projects\\Javascript\\trickster\\src\\transform.js',
      'D:\\Projects\\Javascript\\trickster\\src'
   ] */

HTML escape

Escape html string (' < >,&," ')

console.log(trickster.htmlEscape('"&<html>'));
// expected result : 
// &quot;&amp;&lt;html&gt;

Random number with range

Get random number with defined range

console.log(trickster.randomNumberWithRange(10000));
// expected result : 
// 0 -> 10000