0.8.0 • Published 7 months ago
@rdub/base v0.8.0
@rdub/base
JS/TS utils; helper functions I've missed from standard libraries (and React)
- a.tsx - Anchor component wrapper (sets
target="_blank"andrel="noreferrer"for external URLs). - arr.ts - Array utils:
Arr,concat,isSorted,range,scan, seedableshuffle,sum - color-scheme.tsx -
useColorSchemeReact hook for managing light/dark mode - console.ts - import-able
time,timeEnd,log,warn,error - dom.tsx - element-Props aliases, partially-apply
classNames - heading.tsx:
<H1>…<H6>components: headings with configurable link-target offsets - json/load.ts, json/fetch.ts:
fetchJson,loadJson{,Sync} - math.ts - exports most of
Math, also implementsclampandinterp - objs.ts - typed helpers for mapping between objects and arrays, over keys/values/entries
- singleton.ts - dedupe arrays, verify exactly one unique element, return it
- state.ts -
State<T, "name">helper ({ name: T, setName: (t: T) => void }),StateArr<T>([T, Dispatch<T>]), and aliases (NS<T, Name>,S<T>, etc.) - str.ts -
titlecasehelper - time.ts -
time,timeEnd,Timer - use-origin.ts -
useOriginhook: getwindow.location.origin, with optional/typesafe default - use-set.ts -
useSet,useOptSethooks for React
In Nextjs, add this package to transpilePackages:
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['@rdub/icons'],
// ...
}Otherwise you might see runtime errors like:
⨯ Error: Cannot find module '$PWD/node_modules/.pnpm/@rdub+base@file+..+..+..+js+base+dist_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@rdub/base/a' imported from $PWD/node_modules/.pnpm/@rdub+base@file+..+..+..+js+base+dist_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@rdub/base/index.js
at Error: Cannot find module '$PWD/node_modules/.pnpm/@rdub+base (file+..+..+..+js+base+dist_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@rdub/base/a' imported from $PWD/node_modules/.pnpm/@rdub+base@file+..+..+..+js+base+dist_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@rdub/base/index.js) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file://$PWD/node_modules/.pnpm/@rdub+base@file+..+..+..+js+base+dist_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@rdub/base/a'
}0.7.9
9 months ago
0.7.6
9 months ago
0.7.5
9 months ago
0.7.8
9 months ago
0.7.7
9 months ago
0.7.2
11 months ago
0.8.0
7 months ago
0.7.1
11 months ago
0.7.4
10 months ago
0.7.3
10 months ago
0.7.0
11 months ago
0.6.0
11 months ago
0.5.3
1 year ago
0.5.2
1 year ago
0.5.0
1 year ago
0.5.1
1 year ago
0.4.0
1 year ago
0.3.0
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.0
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago