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

@sassywares/trunk

v1.0.3

Published

Trunk is a simple set of utilities for your JavaScript applications. Read the documentation at https://github.com/sassywares/trunk#readme

Downloads

4

Readme

Trunk

npm version Builds

Trunk is a set of utilities for JavaScript applications. Read more below.

Functions

log

import { log } from '@sassywares/trunk';

// Only logs when NODE_ENV is set to development
log('Hello World');

scrollIntoViewById

import { scrollIntoViewById } from '@sassywares/trunk';

// Scrolls to the element with the id of 'my-id'
scrollIntoViewById('my-id');

// Can pass behavior as the second argument
scrollIntoViewById('my-id', 'smooth');

detectBrowser

import { detectBrowser } from '@sassywares/trunk';

// Returns the detected browser as well as sets it as a class on the html element
detectBrowser();

detectOs

import { detectOs } from '@sassywares/trunk';

// Returns the detected OS as well as sets it as a class on the html element
detectOs();

isArray

import { isArray } from '@sassywares/trunk';

// Returns true
isArray([]);

// Returns false
isArray({});

isObject

import { isObject } from '@sassywares/trunk';

// Returns true
isObject({});

// Returns false
isObject([]);

switchTheme

import { switchTheme } from '@sassywares/trunk';

// Switches the theme to dark
switchTheme('dark');

// Switches the theme to light
switchTheme('light');

// Switches the theme to user's preferred theme and observes for changes
switchTheme('system');

getTheme

import { getTheme } from '@sassywares/trunk';

// Returns the current theme or null if no theme is set
getTheme();

debounce

import { debounce } from '@sassywares/trunk';

// Debounces the function by 500ms
const debouncedLog = debounce((obj) => console.log(obj), 500);

msToSeconds

import { msToSeconds } from '@sassywares/trunk';

// Returns 1
msToSeconds(1000);

// Returns 2
msToSeconds(2000);

Getting Started

To get started with Trunk, install it using NPM, Yarn, or PNPM:

npm install @sassywares/trunk
yarn add @sassywares/trunk
pnpm add @sassywares/trunk

Then, import the functions you need:

import { isObject, detectBrowser } from '@sassywares/trunk';

Contributing

Trunk comes from the community for the community. We are always looking for ways to improve Trunk and make it better. If you have any suggestions, ideas, or feedback, please open an issue or a pull request.

License

Trunk is open source software released under the MIT License. We encourage you to use, modify, and distribute Trunk as you see fit.