yummies
raw JSON → 7.19.4 verified Fri May 01 auth: no javascript
yummies is a collection of frontend utilities for JavaScript/TypeScript projects, currently at v7.19.4. It provides a wide range of functions for common tasks including DOM manipulation, data structures, type guards, React hooks, MobX integrations, and more. The library is actively maintained with frequent releases (multiple patches/minors per month). Its key differentiator is the breadth of utilities under a single package, covering areas like async templates (asyncTemplate), class variance authority (cva), and MobX annotations (annotation), all with TypeScript support. The package requires MobX and React as peer dependencies.
Common errors
error ERR_REQUIRE_ESM: require() of ES Module not supported ↓
cause Trying to use require() to import yummies, which is ESM-only.
fix
Use dynamic import: const { asyncTemplate } = await import('yummies'); or switch to ESM imports.
error Module 'yummies' does not export 'hasEnumerableKeys' ↓
cause Importing from 'yummies' instead of the subpath 'yummies/data'.
fix
Change import to: import { hasEnumerableKeys } from 'yummies/data'.
error Cannot find module 'yummies/utility-types' or 'yummies/utils/types' ↓
cause Imports from removed paths after v6 migration.
fix
Replace with 'yummies/types.global' and 'yummies/types' respectively.
Warnings
breaking Imports from 'yummies/utility-types' and 'yummies/utils/types' are removed in v6. Use 'yummies/types.global' and 'yummies/types' respectively. ↓
fix Replace imports: 'yummies/utility-types' -> 'yummies/types.global', 'yummies/utils/types' -> 'yummies/types'.
gotcha Some utilities like hasEnumerableKeys are exported from subpaths (e.g., 'yummies/data'), not the main entry. Importing from 'yummies' will not include them. ↓
fix Use correct subpath import: import { hasEnumerableKeys } from 'yummies/data'.
gotcha The package is ESM-only. Using require() may fail entirely or require specific bundler configuration. ↓
fix Use ES module imports (import/export syntax) or configure your environment for ESM (e.g., "type": "module" in package.json).
deprecated The 'yummies/utility-types' and 'yummies/utils/types' subpaths are deprecated and removed in v6. ↓
fix See breaking change for v6 migration.
Install
npm install yummies yarn add yummies pnpm add yummies Imports
- asyncTemplate wrong
const { asyncTemplate } = require('yummies')correctimport { asyncTemplate } from 'yummies' - cva wrong
import cva from 'yummies'correctimport { cva } from 'yummies' - annotation wrong
import { annotation } from 'yummies/mobx'correctimport { annotation } from 'yummies' - hasEnumerableKeys wrong
import { hasEnumerableKeys } from 'yummies'correctimport { hasEnumerableKeys } from 'yummies/data' - assert wrong
import assert from 'yummies'correctimport { assert } from 'yummies'
Quickstart
import { asyncTemplate, cva, annotation, hasEnumerableKeys, assert } from 'yummies';
import { observable } from 'mobx';
// asyncTemplate: interpolate promises and functions
const result = await asyncTemplate`Hello ${async () => 'world'}!`;
console.log(result); // 'Hello world!'
// cva: class variance authority
const button = cva(['base', 'btn'], {
variants: {
size: {
small: ['text-sm'],
large: ['text-lg']
},
intent: {
primary: ['bg-blue-500'],
secondary: ['bg-gray-500']
}
}
});
const classes = button({ size: 'small', intent: 'primary' });
console.log(classes); // 'base btn text-sm bg-blue-500'
// annotation: MobX annotation helper
const annotate = annotation({
prop1: observable,
prop2: observable
});
console.log(annotate); // object with MobX decorators
// hasEnumerableKeys: check own enumerable keys
const obj = { a: 1, b: 2 };
console.log(hasEnumerableKeys(obj, ['a', 'b'])); // true
// assert: type guard with error
assert.array([1, 2, 3], 'Must be array'); // passes
assert.object(42, 'Must be object'); // throws 'Must be object'