Use case, you have a csv file, you want it to be split by 100 line numbers into files.. The onlys ide effect is you get sample-aa
, sample-ab
.... no extension
split -l 100 sample.csv sample-
const pattern = 'abcdefgh'; | |
for (const [currentChar, nextChar] of pattern.split('').reduce((acc,value,idx,arr)=>{const entry = [value]; if ( arr.length > idx + 1 ) entry.push(arr[idx+1]); acc.push(entry); return acc},[])) { | |
console.log(currentChar,nextChar) | |
} | |
/** | |
a b | |
b c | |
c d | |
d e |
const {readFile} = require("fs").promises; | |
const run = async () => { | |
const loadCSV = async (fileName ) => { | |
const contents = await readFile(fileName, 'utf8'); | |
const lines = contents | |
.split('\n') | |
.filter(Boolean) | |
.map((t)=>t.trim()) // remove leading and trailing \r for non-utf8 files | |
.map((line)=>{ |
const AWS = require('aws-sdk') | |
const fs = require("fs").promises; | |
const {join} = require('path') | |
const path = require("path"); | |
const { createReadStream, createHash } = require('crypto') | |
const credentials = { | |
accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'test', | |
secretAccessKey: process.env.AWS_SECRET_KEY || 'test' , | |
} |
git diff --name-only HEAD
In Node.js, the process.exit()
method is used to exit the current Node.js process with a given exit code. The number
argument passed to process.exit()
represents the exit code that the Node.js process will exit with.
Here are the commonly used exit codes and their meanings:
0
: The process exits successfully without any errors.1
: The process exits due to an uncaught exception.2
: The process exits due to a misconfiguration or missing file.3
: The process exits due to a fatal error.In Node.js, process.nextTick()
is a method that allows you to schedule a function to be executed on the next iteration of the event loop. It is often used to defer the execution of a function until after the current function has completed.
The process.nextTick()
method is similar to setImmediate()
, but with a few key differences. While setImmediate()
schedules a callback to run in the next iteration of the event loop, process.nextTick()
schedules a callback to run at the end of the current iteration of the event loop, before any I/O operations.
Here is an example of how process.nextTick()
can be used:
console.log('start');
Stability: 2 - Stable
// BUFFER | |
// Load the whole content into a buffer/ into memory once before wrting it out to user | |
const http = require("http"); | |
const media = "./testvid.mp4"; | |
const fs = require("fs"); | |
http | |
.createServer((req, res) => { |