Here are some different ways on how to set up Jest to support ESM. This applies for Jest v25, Node v13, and Babel v7.
Node v14 and Jest v26 support ESM natively with the --experimental-vm-modules
flag.
Install cross-env
:
%GetOptimizationStatus
return a set of bitwise flags instead of a single value,
to access the value, you need to take the binary representation of the returned value.
Now, for example, if 65
is returned, the binary representation is the following:
(65).toString(2).padStart(12, '0');
// 000001000001
Each binary digit acts as a boolean with the following meaning:
const a = { | |
a: 1, | |
b: null | |
}; | |
const b = { | |
a: 2, | |
b: null | |
}; | |
const c = { | |
a: 2, |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
<!-- | |
Complete feature detection for ES modules. Covers: | |
1. Static import: import * from './foo.js'; | |
2. Dynamic import(): import('./foo.js').then(module => {...}); | |
Demo: http://jsbin.com/tilisaledu/1/edit?html,output | |
Thanks to @_gsathya, @kevincennis, @rauschma, @malyw for the help. | |
--> |
Zach Caceres
Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.
The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.
Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.
#!/bin/bash | |
# Tom Hale, 2016. MIT Licence. | |
# Print out 256 colours, with each number printed in its corresponding colour | |
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163 | |
set -eu # Fail on errors or undeclared variables | |
printable_colours=256 |
Enable #enable-devtools-experiments
flag in chrome://flags
section.
Open Chorme Devtools and check Settings > Experiments > Allow extensions to load custom stylesheets
.
Create the following four files in a dedicated folder.
3.1. devtools.html
<html>
<head></head>
<body><script src="devtools.js"></script></body>
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm