Artefacts
API
Examples
Tech
npm
esbuild

https://en.wikipedia.org/wiki/%C2%A3sd

P O U N D S, S H I L L I N G S, A N D P E N C E πŸ’·πŸ’ΈπŸ’Ή

Examples

https://github.com/sindresorhus/year-days/blob/main/index.js

import leapYear from 'leap-year';

export default function yearDays(yearOrDate) {
	return leapYear(yearOrDate) ? 366 : 365;
}

https://github.com/date-fns/date-fns/blob/master/src/index.js

// 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

Future

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://esbuild.github.io/getting-started/

https://scotch.io/bar-talk/how-to-build-and-publish-a-npm-package#toc-publish