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

yow

v1.0.118

Published

You Only Wish module

Downloads

1,176

Readme

Yow

Toolbox for Node. Contains stuff you only wished was there in the first place.

Installation

npm install yow --save

Methods

General Purpose

var sprintf = require('yow/sprintf');
var vsprintf = require('yow/vsprintf');
var once = require('yow/once');
var merge = require('yow/merge');
  • sprintf(args) - Just as you would expect. Uses the npm module 'sprintf-js'.
  • vsprintf(args) - Just as you would expect. Uses the npm module 'sprintf-js'.
  • once(fn, context) - Call a function just once and return the same result.
  • merge({}, objects...) - Like Object.assign() but does a deep merge.

File System

var mkdir = require('yow/mkdir')
var mkpath = require('yow/mkpath');
var fileExists = require('yow/fileExists');
var readJSON = require('yow/readJSON');
var writeJSON = require('yow/writeJSON');
  • mkdir(path) - Creates the directory you specify.
  • mkpath(path) - Creates the directory you specify. It will create multiple directories if they do not exit.
  • fileExists(path) - Nothing fancy, it just returns true/false.
  • readJSON(fileName) - Reads a JSON file and returns the contents.
  • writeJSON(fileName, object) - Writes an object to a JSON file.

Type Checks

var isArray = require('yow/isArray');
var isNumber = require('yow/isNumber');
var isString = require('yow/isString');
var isDate = require('yow/isDate');
var isFunction = require('yow/isFunction');
var isObject = require('yow/isObject');
var isInteger = require('yow/isInteger');
var isFloat = require('yow/isFloat');
  • isType(object, type) - Returns true/false if typeof equals 'type'.
  • isArray(object) - Is object an array?
  • isNumber(object) - Is object a JavaScript Number object?
  • isString(object) - Is object a String object?
  • isDate(object) - Is object a Date object (and contains a valid date)?
  • isFunction(object) - Is object a function object?
  • isObject(object) - Is object an object? BTW null is not an object.
  • isInteger(object) - Is object an integer?
  • isFloat(object) - Is object a float? Please note that isFloat(1.0) returns false.

Random

var random = require('yow/random');
  • random() - Returns Math.random().
  • random(integer) - Returns a random number from 0 to the integer specified (exclusive).
  • random(min, max) - Returns a random number from min to max (inclusive).
  • random(array) - Returns a randomly chosen object in the specified array.
  • random(object) - Returns a randomly chosen object property.

Also available as require('yow/random')

Range

var range = require('yow/range');
  • range(min, max, step) - Returns an range array generated by min, max, and step.

Console/Logging

require('yow/prefixConsole');
  • prefixConsole(fn) - Adds a prefix to all console methods.

Timer

var Timer = require('yow/timer');
var timer = new Timer();
  • timer.setTimer(delay, fn) - Executes the specified function fn after a delay. Previously set timers are cancelled.

  • timer.cancel() - Cancels the timer.

Request

var Request = require('yow/request');
var request = new Request(options);

A light-weight http/https request module.

function example() {

	var Request = require('yow/request');
	var yahoo = new Request('https://query.yahooapis.com');

	function getQuote(ticker) {
		var query = {};

		query.q        = 'select * from yahoo.finance.quotes where symbol =  "' + ticker + '"';
		query.format   = 'json';
		query.env      = 'store://datatables.org/alltableswithkeys';
		query.callback = '';

		yahoo.get('/v1/public/yql', {query:query}).then(function(response) {
			var quotes = response.body.query.results.quote;

			if (typeof qoutes != 'Array')
				quotes = [quotes];

			console.log(ticker, '=', quotes[0].LastTradePriceOnly);

		})

		.catch (function(error) {
			console.log(error);

		});

	}

	getQuote('AAPL');

};
  • request.request(options) - See https://nodejs.org/api/http.html#http_http_request_options_callback for documentation.
  • request.get(options) - Same as request('GET', options)
  • request.post(options) - Same as request('POST', options)
  • request.delete(options) - Same as request('DELETE', options)
  • request.put(options) - Same as request('PUT', options)