Socket
Socket
Sign inDemoInstall

@drmercer/lentils

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @drmercer/lentils

A hodge-podge of useful TypeScript


Version published
Weekly downloads
5
increased by150%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 03 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc