What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-27 16:25:36
Working with BSON in JavaScript
/* This code comes from Vincent Lab And it has a video version linked here: https://www.youtube.com/watch?v=6pBWBNxzCUk */ // Import dependencies const fs = require("fs"); const BSON = require("bson"); // Serialize a document... Add solution -
Javascript 2022-03-07 02:55:14
how to write to a json file in javascript
'use strict'; const fs = require('fs'); let student = { name: 'Mike', age: 23, gender: 'Male', department: 'English', car: 'Honda' }; let data = JSON.stringify(student, null, 2); fs.writeFile('student-3.json', data, (err) =>... Add solution -
Javascript 2022-03-03 23:15:28
nodejs array write to lines file
let arr = ["a", "b", "c", "d", "e", "f"]; console.log(arr); // [ 'a', 'b', 'c', 'd', 'e', 'f' ] console.log(arr.join('\n')); // a // b // c // d // e // f let text = arr.join('\n'); fs.writeF... Add solution -
Javascript 2022-02-16 15:00:06
javascript create text file
const fs = require('fs'); fs.writeFile("/tmp/test", "Hey there!", function(err) { if(err) { return console.log(err); } console.log("The file was saved!"); }); // Or fs.writeFileSync('/tmp/test-sync', 'H... Add solution -
Javascript 2022-01-31 03:57:19
Manually Parsing Plain text in Node.js
/* This code comes from Vincent Lab And it has a video version linked here: https://www.youtube.com/watch?v=fy2RF9JR1BI */ // Import dependencies const fs = require("fs"); // Read the text file and split it on new lines const lines = f... Add solution -
Javascript 2022-01-30 12:25:37
how to use json schema faker
import { schema } from './mockDataSchema'; import chalk from 'chalk'; const {resolve, extend} = require('json-schema-faker'); const fs = require('fs'); extend('faker', () => require('faker')); resolve(schema).then(sample => { console.log(... Add solution -
Javascript 2021-11-21 22:33:13
nodejs sharp change image to multiple sizes
// Sharp and FS module needed. ;(async function(){ let imgBuffer = await sharp("./myimage.jpg").toBuffer() let thumbnail = await sharp(imgBuffer).resize(100, 100).toBuffer() let image = await sharp(imgBuffer).resize(1600, 900).toBuffer(... Add solution -
Other 2021-11-19 06:32:13
jsf deprecated
import { schema } from './mockDataSchema'; import chalk from 'chalk'; const {resolve, extend} = require('json-schema-faker'); const fs = require('fs'); extend('faker', () => require('faker')); resolve(schema).then(sample => { console.log(... Add solution -
Javascript 2021-11-17 22:26:08
puppeteer open browser authentication facebook
if (!Object.keys(cookies).length) {await page.goto("https://www.facebook.com/login", { waitUntil: "networkidle2" });await page.type("#email", config.username, { delay: 30 })await page.type("#pass", config.password, ... Add solution