
P O U N D S, S H I L L I N G S, A N D P E N C E π·πΈπΉ
Examples
import leapYear from 'leap-year';
export default function yearDays(yearOrDate) {
return leapYear(yearOrDate) ? 366 : 365;
}
// This file is generated automatically by `scripts/build/indices.js`.
export { default as add } from './add/index'
...
export { default as toDate } from './toDate/index'
export * from './constants/index'
My first time writing an npm package/JS library
What will it expose?
Need setters on these to do bounds checks and overflows
strict
When on, creating an LSD with out-of-bounds numbers (pence over 12, shillings over 20) will raise an error
When off, it will do its best to make sense in a βpile of coinsβ way
An lsd
class
{ βpoundsβ : number, βshillingsβ : number, βpenceβ : number }
What tech shall we use?
typescript
Methods
Repo: https://github.com/SteGriff/old-money
looked at uvu ... too weird
+ addPence, + addShillings, + addPounds
a test runner...
override toString() to get a value like Β£1 9s 6d
Properties
L E A R N I N G S
...or you can specify a format string of your own
totalPence()
ava looks good, shame it has so many dependencies... Iβll go with it.
Constructors
ava?
new lsd(pence)
new lsd(Β£, s, d)
new lsd(string) ?
esbuild
Compiles ts with zero config!
npm
Itβs published!! https://www.npmjs.com/package/old-money
Use npm link
to test a package locally
https://docs.npmjs.com/cli/v7/commands/npm-link
npm init
publish
Ahhh esbuild wonβt generate .d.ts typescript typings πΏπΏπΏ
https://unpkg.com/old-money@1.0.1/dist/index.js
https://github.com/evanw/esbuild/issues/95
https://scotch.io/bar-talk/how-to-build-and-publish-a-npm-package#toc-publish