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
// After body-parsing middleware... | |
app.use(function(req, res, next) { | |
console.log( | |
"curl '%s://%s%s' -X %s -H 'Content-Type: %s' -d '%s'", | |
req.protocol, | |
req.get("host"), | |
req.originalUrl, | |
req.method, | |
req.get("Content-Type"), | |
JSON.stringify(req.body) |
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
import { scaleLinear } from "d3-scale"; | |
const getColor = scaleLinear().domain([0, 100]).range(["#ccc", "#419fcf"]); | |
getColor(0); // 0% = #ccc | |
getColor(80); // 80% = #5da8ce | |
getColor(100); // 100% = #419fcf |
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
{ | |
"rules": { | |
"no-restricted-syntax": [ | |
"error", | |
"[generator=true]", | |
"[async=true]", | |
"AwaitExpression" | |
] | |
} | |
} |
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
import gulp from 'gulp'; | |
import Vinyl from 'vinyl'; | |
import vinylAdapter from './vinyl-adapter'; | |
gulp.task('build', () => { | |
const file = new Vinyl({ | |
path: 'hello.js', | |
contents: Buffer.from(`console.log('👋');`) | |
}); |
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 Input<Output> = { | |
[K in keyof Output]: { foo: () => Output[K] }; | |
}; | |
function convert<Output>(input: Input<Output>): Output { | |
const keys = Object.keys(input) as (keyof Input<Output>)[]; | |
return keys.reduce( | |
(output, key) => ({ ...output, [key]: input[key].foo() }), | |
{} as Output |
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
import gulp from 'gulp'; | |
import { Transform } from 'node:stream'; | |
gulp.task('build', () => { | |
return gulp | |
.src('src/**/*.js') | |
.pipe( | |
new Transform({ | |
objectMode: true, | |
transform(file, encoding, callback) { |
OlderNewer