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

@drmercer/lentils

v0.0.5

Published

A hodge-podge of useful TypeScript

Downloads

10

Readme

Lentils 🥘

A miscellaneous hodge-podge of TypeScript utilities. Designed to be usable in source form (the build step happens in the dependent projects, not in this one).

As published on npm, this package includes two versions of each file - ES modules and CommonJS. For example, common/types/checks.ts gets published both as @drmercer/lentils/cjs/common/types/checks (CommonJS) and as @drmercer/lentils/esm/common/types/checks (ES module). This is because ES modules are more modern and provide smaller bundles with tools like Webpack (in my experience), while CommonJS modules are more broadly compatible.

Using in Deno

To use these utilities in Deno, I recommend using esm.sh to compile them into ES modules with Deno typings headers included. You'll have to use the CommonJS version of the files, because esm.sh doesn't properly compile the ES module kind for some reason. (It's probably because the package.json doesn't have "type": "module", for CommonJS Node compatibility).

import { isNonNull } from 'https://esm.sh/@drmercer/lentils/cjs/common/types/checks.js';

Using in Node

To use these utilities in Node, just add them to your project:

yarn add @drmercer/lentils

and then import the CommonJS files like so:

const { isNonNull } = require('@drmercer/lentils/cjs/common/types/checks');
// OR, if you're using TS, you can probably do this:
import { isNonNull } from '@drmercer/lentils/cjs/common/types/checks';

Using in the browser via Webpack (and probably other bundlers)

In Webpack, you can import the esm/ version of the file you need, to get smaller output builds. The cjs/ files should also work just fine, if you prefer.

import { isNonNull } from '@drmercer/lentils/esm/common/types/checks';

If you want to write code that can be used in both Node and the browser while preserving the Webpack benefits of ES modules, you can probably use Webpack's alias feature to convert cjs/ imports to esm/ imports at compile time.

Using in the browser directly

You can probably use esm.sh for direct ES module usage in the browser, just like in Deno. You also could try using the esm/ version via a CDN like unpkg, which doesn't do compiling like esm.sh does.

import { isNonNull } from 'https://esm.sh/@drmercer/lentils/cjs/common/types/checks.js';

A note about missing dependencies

Some of the code in this library depends on other libraries, like turndown. If you run into "missing dependency" errors, check the devDependencies in package.json for the version to use. I used devDependencies instead of peerDependencies or optionalDependencies because I don't want those deps to be installed by default in projects that use this library, in case they're not used, and I don't want to give unnecessary errors/warnings when installing this library in a project.