In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DeepReadonly<T> = { | |
readonly [P in keyof T] | |
: DeepReadonly<T[P]>; | |
} |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'
instead ofconst foo = require('foo')
to import the package. You also need to put"type": "module"
in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)
from CommonJS instead ofrequire(…)
. - Stay on the existing version of the package until you can move to ESM.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
// examples from https://github.com/vriad/zod | |
// trying to use zod in JS w/ jsdoc type comments in vsCode | |
const z = require('zod') | |
const dogSchema = z.object({ | |
name: z.string(), |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:
- Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
- Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
- Is it going to be used as a dependency to a browser application (always bundled)?.
- In cases 2) and 3) you want to allow for tree shaking.
- In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
- In case 3) you also want to benefit from the native support of "ES6" from your browser.
Table of Contents
We subscribe to the Git Featrue Branch workflow, briefly described in that link.
In practice, it works as follows:
- Start with an updated local development branch -- by checking out the dev branch and pulling changes:
git checkout development
git pull origin development
NewerOlder