Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:*",
"route53domains:*",
"cloudfront:ListDistributions",
"elasticloadbalancing:DescribeLoadBalancers",

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 June 9, 2020 15:43
PromiseLock or Mutex ?
/**
* 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 10:20
Cannot require ESM
const isPromise = import('./third-party-is-promise.mjs')
console.log(typeof isPromise)
console.log('then method', typeof isPromise.then)
export class ValidationFail {
readonly validateErr: string
readonly ok: false
constructor(validateErr: string) {
this.validateErr = validateErr
this.ok = false
}
}
export class ValidationSuccess<T> {
$ 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
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)
class DataTableExample extends DataTable {
computeRowValues (row) {
return [
row.message,
new Date(row.timestamp).toGMTString()
]
}
computeRowHeaders () {
'use strict'
const pino = require('pino')
const os = require('os')
const { modes } = require('./logger.js')
/**
* This class gives an improved interface for pino
*
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