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

@bolajiolajide/utils

v1.0.15

Published

<!-- markdownlint-disable MD033 --> <div align="center"> <img src="https://github.com/BolajiOlajide/utils/blob/master/alfred.png?raw=true" alt="alfred avatar" width="500px" /> <p align="center"> </div>

Downloads

20

Readme

@bolajiolajide/utils

Collection of utility functions/helpers I use in my everyday development.

Methods

  • value string to be capitalize
const { capitalize } = require('@bolajiolajide/utils');

const data = capitalize('bolaji');
console.log(data);
// 'Bolaji'
  • value string slice to convert
  • separator string to use to separate the different items in the slice
const { convertSliceToString } = require('@bolajiolajide/utils');

const data = convertSliceToString('bolaji');
console.log(data);
// 'bolaji'

const data2 = convertSliceToString(['bol', 'aji']);
console.log(data2);
// 'bolaji'

const data3 = convertSliceToString(['bol', 'aji', 'pro', 'ton'], '**');
console.log(data3);
// 'bol**aji**pro**ton'
const { countries } = require('@bolajiolajide/utils');

console.log(countries);
// ['Afghanistan', ...]
const { delay } = require('@bolajiolajide/utils');

await delay(10000); // delay for 10seconds
const { generateCSV } = require('@bolajiolajide/utils');

const data = [
  { name: 'John Doe', age: 20 },
  { name: 'Jane Doe', age: 23 }
];
const csv = generateCSV(data);
console.log(csv);
// name, age
// John Doe, 20
// Jane Doe, 23
const { generateShortCode } = require('@bolajiolajide/utils');

const shortcode = generateShortCode(10);
console.log(shortcode);
// 637010000
  • value literal to check type
const { isDict } = require('@bolajiolajide/utils');

const data = isDict('bolaji');
console.log(data);
// false

const data2 = isDict({ amount: 230329 });
console.log(data2);
// true
  • value literal to check type
const { isString } = require('@bolajiolajide/utils');

const data = isString('bolaji');
console.log(data);
// true

const data2 = isString(230329);
console.log(data2);
// false
  • fn the function to be run only once
const { runOnce } = require('@bolajiolajide/utils');

const addTogether = function(num1:number, num2:number):number{
  return num1+num2
}
const addTogetherOnce = runOnce(addTogether)
let firstResult = addTogetherOnce(0,1)
let secondResult = addTogetherOnce(0,1)
console.log(firstResult)
console.log(secondResult)
});
// firstResult:  1
// secondResult: undefined
  • limit how many items to receive per page
  • page page number to be retrieved
  • data the array of data to be paginated
const { paginate } = require('@bolajiolajide/utils');

const data = paginate(2, 2, [
  'Jane',
  'John',
  'James',
  'Bill',
  'Steve',
  'Melissa',
  'Esther',
  'Shannon'
]);
console.log(data);
// ['James', 'Bill']
  • word the word/phrase to sentencize
  • separator a string separating the words in a phrase, defaults to ' '
const { sentencize } = require('@bolajiolajide/utils');

const data = sentencize('APPLE_MUSIC', '_');
console.log(data);
// 'Apple Music'

const data = sentencize('SPOTIFY');
console.log(data);
// 'Spotify'
  • url the url to be checked
const { isUrl } = require('@bolajiolajide/utils');

const response = isUrl('APPLE_MUSIC');
console.log(response);
// false

const response = isUrl('https://google.com');
console.log(response);
// true
  • url the url to be checked
const { isHttpUrl } = require('@bolajiolajide/utils');

const response = isHttpUrl('ftp://dskjdslds');
console.log(response);
// false

const response = isUrl('https://google.com');
console.log(response);
// true