Writing a JS Library
- 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?
- Methods
- looked at uvu ... too weird
- Properties
- L E A R N I N G S
- esbuild
- publish
Writing a JS Library
- 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?
- Methods
- looked at uvu ... too weird
- Properties
- L E A R N I N G S
- esbuild
- publish