![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
[![github](https://badgen.net/badge//nju33,amida/000?icon=github&list=1)](https://github.com/nju33/amida) [![npm:version](https://badgen.net/npm/v/amida?icon=npm&label=)](https://www.npmjs.com/package/amida) [![typescript](https://badgen.net/badge/lang/ty
/**
* As to prepare of using the `amida`
*
* ```sh
* yarn add amida
* ```
*/
import Amida from 'amida';
or
<script src="https://unpkg.com/amida/amida.js"></script>
<script>
// Can use the `Amida` here.
</script>
interface BehaviorObject {
size: string;
}
const theme = {
size: 123,
};
const wm = new WeakMap();
wm.set(theme, theme);
const amida = new Amida<BehaviorObject>({
size: into => [
// In case of `string`
into((v: string) => v).if.string(),
// In case of `number`
into((num: number) =>
Math.round(num) === num ? `${num}px` : `${num}em`,
).if.number() /* or if('number') */,
// In case of `object`
into((obj: BehaviorObject) => `${obj.size}px`).if.object(),
// In case of `WeakMap`
into((wm: WeakMap<object, BehaviorObject>) => {
return `${wm.get(theme)!.size}px`;
}).if.weakmap() /* or if ('weakmap') */,
],
});
const obj = amida.from(theme);
expect(obj.size).toBe('123px');
obj.size = '100%';
expect(obj.size).toBe('100%');
(obj.size as unknown) = theme;
expect(obj.size).toBe('123px');
(obj.size as unknown) = 999;
expect(obj.size).toBe('999px');
(obj.size as unknown) = 2.1;
expect(obj.size).toBe('2.1em');
(obj.size as unknown) = wm;
expect(obj.size).toBe('123px');
const amida2 = new Amida<BehaviorObject>({
size: into => [
into((v: string) => v).if.string(),
into((v: object) => v).if.object(),
]
});
amida2.from({});
(amida2.size as any) = 123; // throw TypeError('size must be string, object')
FAQs
[![github](https://badgen.net/badge//nju33,amida/000?icon=github&list=1)](https://github.com/nju33/amida) [![npm:version](https://badgen.net/npm/v/amida?icon=npm&label=)](https://www.npmjs.com/package/amida) [![typescript](https://badgen.net/badge/lang/ty
The npm package amida receives a total of 4 weekly downloads. As such, amida popularity was classified as not popular.
We found that amida demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.