Skip to content

Instantly share code, notes, and snippets.

View policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:*",
"route53domains:*",
"cloudfront:ListDistributions",
"elasticloadbalancing:DescribeLoadBalancers",
View parcel-browser.md

I attempted to use parcel to bundle a commonJS project.

Example code

For example

const assert = require('assert')

const MyWebComponent = require('./my-web-component')
@Raynos
Raynos / mutex.js
Last active Jun 9, 2020
PromiseLock or Mutex ?
View mutex.js
/**
* A PromiseLock like object.
*
* Used to ensure that we only do one thing at a time on a shared resource.
*
* For example, with async iterator:
*
* this.readLock = new Mutex()
* this.readLock.do(async () => {
* const data = await itr.next();
@Raynos
Raynos / also-broken.cjs
Created May 28, 2020
Cannot require ESM
View also-broken.cjs
const isPromise = import('./third-party-is-promise.mjs')
console.log(typeof isPromise)
console.log('then method', typeof isPromise.then)
View x.ts
export class ValidationFail {
readonly validateErr: string
readonly ok: false
constructor(validateErr: string) {
this.validateErr = validateErr
this.ok = false
}
}
export class ValidationSuccess<T> {
View x.sh
$ npm pack @pre-bundled/tape@5.0.0 | wc -l
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled%2ftape 13ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled%2ftape 5ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled/tape/-/tape-5.0.0.tgz 3ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled/tape/-/tape-5.0.0.tgz 59ms (from cache)
npm notice
npm notice 📦 @pre-bundled/tape@5.0.0
npm notice === Tarball Contents ===
npm notice 17B pre-bundled/node_modules/dotignore/test/.1-ignore
npm notice 468B .editorconfig
View gist:6f83a548374ba9a243f3b0b82a5102ed
1 import fs, { readFileSync } from 'fs';
2 import { syncBuiltinESMExports, createRequire } from 'module';
3
4 const require = createRequire(import.meta.url)
5 const { readFileSync: readFileSync2 } = require('fs')
6
7 var ref = readFileSync
8
9 console.log('import', readFileSync)
10 console.log('var ok ?', ref)
View x.js
class DataTableExample extends DataTable {
computeRowValues (row) {
return [
row.message,
new Date(row.timestamp).toGMTString()
]
}
computeRowHeaders () {
View json-logger.js
'use strict'
const pino = require('pino')
const os = require('os')
const { modes } = require('./logger.js')
/**
* This class gives an improved interface for pino
*
View benchmark.md
raynos at raynos-ThinkPad-T440p  
~/gocode/src/github.com/uber/zanzibar on master*
$ go test -benchmem -cpu 2 -bench . ./wut_test.go 
testing: warning: no tests to run
BenchmarkClosure-2   	10000000	       113 ns/op	      64 B/op	       2 allocs/op
BenchmarkStruct-2    	10000000	       129 ns/op	      64 B/op	       2 allocs/op
PASS
ok  	command-line-arguments	2.684s