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

utonmae

v1.1.7

Published

Helper fun's :P, more on the readme.

Downloads

24

Readme

Helper fun's :P

Just implements a few helper functions to help get around both browser and node api's no support for deno.js ~~mainly because I don't know how~~

This package is not intended to run on, ungah bungah (older) versions of browsers and or versions of nodejs and will never support older versions that do not support anything in or beyond ES6.

install: npm i utonmae

Legend:

  • <hps|helpers> - hps || helpers

<hps|helpers>.defin

Basically, less of a headache, Object.defineProperty / Object.defineProperties. ~~Why do programmers insist on making it super hard or tedious for others..., instead of it being smart or easy~~

hps.defin(Map,
  ['array', {
    value () {
      // if you're not from ye olde
      return Array.from(this.entries())
    }
  }]
)

<hps|helpers>.empty

Basically, easy use case .length for the base types

let empt;
empt = {
  obj: {}, // object
  arr: [], // array
  str: '', // string
  rgxp: new RegExp('') // regular expression, had to do it this way otherwise the processer would've had a fit
}

console.log(`Is obj empty? ${hps.empty(empt.obj)}
Is arr empty? ${hps.empty(empt.arr)}
Is str empty? ${hps.empty(empt.str)}
Is rgxp empty? ${hps.empty(empt.rgxp)}`);

// these will all be true
// if its an unknown type or there is no size value, will throw an error ;P.

<hps|helpers>.parse | <hps|helpers>.stringify & <hps|helpers>.nType

Basically, extendable JSON stringifiy and parse that should've been a thing by now but nope-

// edit: indented it so some style enforcer doesn't have a stroke ;P
let Mow = (() => {
  let mo;
  mo = function Mow (moow) {
    if (!(this instanceof Mow)) {return new Mow(...arguments)}
    if (moow == null) {throw Error("MOOOOW")}
    this.moow = moow;
  }
  mo.prototype = {
    constructor: Mow
  }
  // defines the deconstrucor rule, basically turns it into json jargen
  mo.destructor = function (it) {
    return {
      yup: 'mow', // needed, the rest of it.. structure it how you like, of course, within the rules of a JSON file.
      data: it.moow
    }
  }
  // defines the reviver rule, basically turns that json jargen into the original data before json jargen
  mo.reviver = function (it) {
    return Mow(it.data)
  }

  // passes the custom class into a library which saves the data.
  hps.nType(mo);
  return mo
})();

// then you can use parse & stringify
let dt = hps.stringify({
  mo: Mow('mowmowmowmow')
}); // {"mo":{"yup":"mow",data:"mowmowmowmow"}}
hps.parse(dt) // {mo: Mow {moow: "mowmowmowmow"}}

<hps|helpers>.type

Returns the type of the first argument, if another is passed, compares the second to the first's type, of course, must be a string, what kind of person would do it any other way ;P

console.log(hps.type('moo')) // 'string';
// or
console.log(hps.type('moo', 'string')) // true;

<hps|helpers>.ncheck

Basically checks if the main is nodejs or a browser can just call it for the value if you don't want to do it callback wise.

hps.ncheck(yin => {
  if (!yin) {console.log('node-')}
  console.log('window-')
});

<hps|helpers>.mkdown

Basically, easy definable into the window process- if doing something from a self call anonymous function

(() => {
  let moo;
  moo = {weh: 'egg'}
  hps.mkdown(moo, 'cow');
})();
console.log(cow) /* or window.cow */ // {weh: "egg"}

<hps|helpers>.mns

Basically, ease of access localStorage

hps.mns('moocow', (exists, item, helperNodeShard) => {
  // exists || e
  // item || it
  // helperNodeShard || hns
  if (!exists) {helperNodeShard.define('weewow')}
  someGlobalVariable = helperNodeShard.dat
})

Contributing

This package does not require python or anything like that so its pretty easy to contribute stuff

H - O - W - E - V - E - R

not all "helper" functions are actually, "helpful" so.

it must have a more general use case or use case for optional packages like:

  • express
  • fs
  • readline
  • socket.io

to name a few.

otherwise?

IT'S USELESS.


Style Rules

  • DO NOT
    • use 'use-strict'.
    • overly use 'const'.
    • overly use 'var'.
    • (joke) use typescript, aka, the "more-work" language ;P
    • Leave comments in your code unless its TODO or NOTE
  • DO
    • use 'let'.
    • find the most optimal, fast and efficient way of writing code, that runs fast and efficient
    • Make sure its easy for other programmers, including myself.