yum install httpd -yDefault install directory /var/www/html
| /** | |
| * Problem: an array of data, that has an array of sub data. | |
| * Three ways to do this: | |
| * - map+split, reduce, push+spread, sort ( side effect: order is not retained ) | |
| * - map+split, flat | |
| * - flatMap+split | |
| */ | |
| const values = 'a|b|c|d,e|f,g|h|i|j|k|l' | |
| const A = values.split(',').map((v)=>v.split('|')).reduce((acc,v)=>{ |
Currying is the process of turning a function that expects multiple parameters into one that, when supplied fewer parameters, returns a new function that awaits the remaining ones. [1]
| 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');