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

envy-jsutil

v1.0.7

Published

A free javascript browser environment utility library

Downloads

4

Readme

envy.js

A free javascript browser environment utility library

Installation

There are two versions packaged. One is the development version, the other is a minified version. I believe this should be self explanatory.

Git Clone

git clone https://github.com/alicenq/envy.js.git
cd envy.js/dist

NPM

npm install envy-jsutil

UNPKG

Development

<script src='https://unpkg.com/envy-jsutil/dist/envy.js'></script>

Production

<script src='https://unpkg.com/envy-jsutil/dist/envy.min.js'></script>

Window Utility

WARNING!!!!!

DO NOT USE window.onload! Many of these methods will refuse to work if you override it!

on

This is used to register window events, such as onload. Unlike the standard events however, this allows you to register multiple callbacks, which will then be called in whatever sequence they were registered.

Usage:

NV.on('load', function(){
   alert('The window has loaded!')
})

onload

This is simply shorthand for NV.on('load', ...)

Usage:

NV.onload(function(){
    alert('The window has loaded!')
})

Document Utility

import

Used to import an external script by creating a <script> tag. A Promise is returned. If a reference child is specified this script will be inserted before the reference child, otherwise it'll be inserted before the envy script.

Usage:

// Simple script import
NV.import('my/script.js')

// Prints out a script tag 
NV.import('my/script.js', { type: 'text/javascript' }).then(console.log)

link

Used to import an external file, usually a stylesheet by creating a <link> tag. A Promise is returned. If a reference child is specified this script will be inserted before the reference child, otherwise it'll be inserted before the envy script.

Usage:

// Simple CSS import
NV.link('my/stylesheet.css')

// Prints out a link tag 
NV.link('my/stylesheet.css', { type: 'text/css', rel: 'stylesheet' }).then(console.log)

Object Utility

fetchJson

An extension of the fetch API which simply returns an object in its Promise instead of a Response. This can already be done quite easily using the fetch API, this just makes it faster and easier to type.

Usage:

// Prints decoded JSON data
NV.fetchJson('/my/path').then(console.log)

fetchText

An extension of the fetch API which simply returns a string in its Promise instead of a Response. This can already be done quite easily using the fetch API, this just makes it faster and easier to type.

Usage:

// Prints text data
NV.fetchData('/my/path').then(console.log)

merge

This performs a deep version of Object.assign by copying data from a source object to a target object. The last parameter is an optional merge strategy. This can be either a callback function or one of the following strings: 'theirs', 'ours', 'sum', 'error'. By default if undefined this is 'theirs'

This works recursively so when used on an object will merge all root-level parameters as well as every child object.

Usage:

// prints { a:2, b:2, c:3 }
console.log(NV.merge(
    { a: 2 }, 
    { b: 2, c: 3 }
));	

// prints { a:100, b:2, c:3 }
console.log(NV.merge(
    { a: 100 }, 
    { a: 1, b: 2, c: 3}, 
    'ours'
));	

// prints { a:50, b:2, c:3 }
console.log(NV.merge(
    { a: 100 },
    { a: 0, b: 2, c: 3 }, 
    function(a, b){ return (a+b)/2; } 
));	

// prints { a: [0, 1, 2, 100, 200, 300], b: {c: 1, d: 1} }
console.log(NV.merge(
    { a: [0, 1, 2], b: {c: 1} },
    { a: [100, 200, 300], b: {d: 1} },
    'combine'
));