Last active
April 19, 2021 13:17
-
-
Save willgvfranco/fd4f7940548031383741a68a8a70f69c to your computer and use it in GitHub Desktop.
node-js-react
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
let single_or_array = ['a'] | |
Array.isArray(single_or_array) ? single_or_array.map(d => console.log(d)) : console.log(single_or_array) |
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 mongodb from 'mongodb'; | |
const { MongoClient } = mongodb | |
const connectionURL = 'mongodb://127.0.0.1:27017' | |
const databaseName = 'NAME' | |
// const id = new ObjectID() | |
// console.log(id) | |
MongoClient.connect(connectionURL, { useUnifiedTopology: true }, (error, client) => { | |
if (error) { | |
return console.log('Unable to connect to database!') | |
} | |
const db = client.db(databaseName) | |
console.log('Connected correctly!') | |
// db.collection('users').insertOne({ | |
// name: 'Test', | |
// age: 111 | |
// }, (error, result) => { | |
// if (error) { | |
// return console.log('Unable to insert user') | |
// } | |
// console.log(result.ops) | |
// }) | |
}) |
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
process.env.UV_THREADPOOL_SIZE = 2; | |
// Windows -> set UV_THREADPOOL_SIZE=7 && node threads.js | |
const crypto = require('crypto') | |
const start = Date.now(); | |
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => { | |
console.log('1:', Date.now() - start); | |
}); | |
crypto.pbkdf2('a', 'b', 100000, 512, 'sha512', () => { | |
console.log('2:', Date.now() - start); | |
}); | |
console.log('1:', Date.now() - start); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment