npm init -y
npm i --save-dev nodemon
npm add babel-preset-env babel-cli
Create a .babelrc config in your project root. Insert the following
{
"presets": ["env"]
| // import ..... | |
| const inputUploadFile: CSSProperties = { | |
| display: 'none', | |
| }; | |
| const buttonUploadFile: CSSProperties = { | |
| margin: 8, | |
| }; |
| var mongoose = require('mongoose'); | |
| mongoose.connect('localhost', 'testing_emitUpdate'); | |
| var Schema = mongoose.Schema; | |
| var schema = new Schema({ | |
| name: String | |
| }); | |
| // plumbing | |
| schema.pre('save', function (next) { |
| const asyncRunAll = (arrOfFunc, numberOfWorkers) => { | |
| return new Promise((resolve, reject) => { | |
| if (!("length" in arrOfFunc) || arrOfFunc.length <= 0) return resolve([]); | |
| numberOfWorkers = Math.min( | |
| numberOfWorkers || arrOfFunc.length, | |
| arrOfFunc.length | |
| ); | |
| let stop = false; | |
| let freeWorkers = numberOfWorkers; | |
| let counter = 0; |
| const compose = (...functions) => args => functions.reduceRight((arg, fn) => fn(arg), args); |
| // Log incoming traffic | |
| var metricStore = new Map(); | |
| /** | |
| * | |
| * @param {string} key | |
| * @returns {void} | |
| */ | |
| const getCount = (key) => metricStore.has(key) ? metricStore.get(key) + 1 : 1; |
| // Log incoming traffic | |
| var metricStore = new Map(); | |
| /** | |
| * | |
| * @param {string} key | |
| * @returns {void} | |
| */ | |
| const getCount = (key) => metricStore.has(key) ? metricStore.get(key) + 1 : 1; |
| var fs = require('fs'); | |
| var readStream = fs.createReadStream('bigfilelogs.txt'); | |
| var stream = require('stream'); | |
| var xtream = new stream.Transform( { objectMode: true } ); | |
| xtream._transform = function(chunk, encoding, done) { | |
| var strData = chunk.toString(); | |
| if (this._invalidLine) { |
| #!/bin/bash | |
| for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do | |
| git branch --track ${branch#remotes/origin/} $branch | |
| done |
| var net = require('net'); | |
| var client = new net.Socket(); | |
| client.connect(1337, '127.0.0.1', function() { | |
| console.log('Connected'); | |
| client.write('Hello, server! Love, Client.'); | |
| }); | |
| client.on('data', function(data) { | |
| console.log('Received: ' + data); |