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
#!/bin/bash | |
for i in $(find ./src -name '*.js' ); | |
do | |
if ! grep -q Copyright "$i" | |
then | |
echo "$i" | |
cat license-header.txt "$i" > "$i".new && mv "$i".new "$i" | |
fi | |
done |
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
const util = require('util'); | |
const fs = require('fs'); | |
/** | |
* identity function f(v) -> v | |
* Using ES6 Promise | |
* | |
* async/await approach: | |
* async function identityAsync(v) { | |
* return v; |
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
const { promisify } = require('util'); | |
const { read, open } = require('fs'); | |
const readPromisified = promisify(read); | |
const openPromisified = promisify(open); | |
const expected = Buffer.from('xyz\n'); | |
const buffer = Buffer.allocUnsafe(expected.length); | |
openPromisified('x.txt', 'r').then(fd => { |