### Install call-bind-apply-helpers Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/call-bind-apply-helpers/README.md Installs the `call-bind-apply-helpers` package using npm. This is the initial setup step before using the package's functionalities. ```sh npm install --save call-bind-apply-helpers ``` -------------------------------- ### Add simple web-service example Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/History.md Includes a basic example of how to set up a simple web service using Express. This serves as a starting point for building APIs or dynamic web applications. ```javascript const express = require('express'); const app = express(); app.get('/api/greeting', (req, res) => { res.json({ message: 'Hello, World!' }); }); app.listen(3000, () => { console.log('Web service listening on port 3000'); }); ``` -------------------------------- ### Start MongoDB Server Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mongodb/README.md This command starts a MongoDB server instance. It requires a database path to be specified, which is where MongoDB will store its data files. Ensure MongoDB is installed before running this command. ```bash mongod --dbpath=/data ``` -------------------------------- ### Create and start a new Express application Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/Readme.md This sequence of console commands outlines the process of creating a new Express application using the Express Generator, navigating into the new application's directory, installing its dependencies, and starting the development server. It assumes the express-generator has been installed globally. ```bash express /tmp/foo && cd /tmp/foo npm install npm start ``` -------------------------------- ### Usage examples for object-assign Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/object-assign/readme.md Demonstrates various ways to use the object-assign function. It covers basic assignment, handling multiple sources, overwriting keys, and ignoring null/undefined sources. The examples assume the package has been installed and imported. ```javascript const objectAssign = require('object-assign'); objectAssign({foo: 0}, {bar: 1}); //=> {foo: 0, bar: 1} // multiple sources objectAssign({foo: 0}, {bar: 1}, {baz: 2}); //=> {foo: 0, bar: 1, baz: 2} // overwrites equal keys objectAssign({foo: 0}, {foo: 1}, {foo: 2}); //=> {foo: 2} // ignores null and undefined sources objectAssign({foo: 0}, null, {bar: 1}, undefined); //=> {foo: 0, bar: 1} ``` -------------------------------- ### Install get-proto using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/get-proto/README.md This command installs the 'get-proto' package as a dependency for your project. It uses npm, the Node Package Manager, to download and install the package. ```sh npm install --save get-proto ``` -------------------------------- ### Install yargs-parser Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/yargs-parser/README.md Install the yargs-parser package using npm for use in Node.js projects. This is the first step to start parsing command-line arguments. ```sh npm i yargs-parser --save ``` -------------------------------- ### Install and Build Project Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/bson/README.md These commands are used to install project dependencies and build the project. 'npm install' downloads the necessary packages, and 'npm run build' compiles the source code. ```shell npm install npm run build ``` -------------------------------- ### Install ee-first using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/ee-first/README.md This command installs the ee-first package and its dependencies using npm, the Node Package Manager. Ensure you have Node.js and npm installed on your system. ```sh npm install ee-first ``` -------------------------------- ### Install Express.js using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/Readme.md This console command shows how to install the Express.js framework locally for a project using npm (Node Package Manager). Ensure Node.js and npm are installed. This command downloads and installs the 'express' package into the 'node_modules' directory of your project. ```bash npm install express ``` -------------------------------- ### Install Development Dependencies and Run Benchmarks Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/braces/README.md This bash command installs the necessary development dependencies for the project using npm and then executes the benchmarking script. ```bash npm i -d && npm benchmark ``` -------------------------------- ### Install Methods Module using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/methods/README.md This command installs the 'methods' module from the npm registry. It is a prerequisite for using the module in a Node.js project. ```bash npm install methods ``` -------------------------------- ### Install create-require with Yarn or npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/create-require/README.md This snippet shows how to install the `create-require` package using either Yarn or npm. It's a standard package installation command. ```sh yarn add create-require npm install create-require ``` -------------------------------- ### Install Mongoose with npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mongoose/README.md Install the Mongoose package using npm. This is the standard way to add Mongoose to a Node.js project. Ensure Node.js and MongoDB are installed first. ```sh npm install mongoose ``` -------------------------------- ### Installation via npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/acorn-walk/README.md Instructions for installing the acorn-walk library using npm. This is the recommended method for integrating the library into a project. ```sh npm install acorn-walk ``` -------------------------------- ### Install Braces.js with npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/braces/README.md This snippet shows how to install the braces.js library using npm. It is a standard dependency installation command. ```sh $ npm install --save braces ``` -------------------------------- ### Install ignore-by-default Package Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/ignore-by-default/README.md This command installs the 'ignore-by-default' package as a project dependency using npm. ```bash npm install --save ignore-by-default ``` -------------------------------- ### Install @jridgewell/trace-mapping Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@jridgewell/trace-mapping/README.md Installs the @jridgewell/trace-mapping package using npm. This is the primary step to begin using the library in your project. ```sh npm install @jridgewell/trace-mapping ``` -------------------------------- ### Install on-finished using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/on-finished/README.md This command installs the 'on-finished' module from the npm registry. It is a dependency for using the module in a Node.js project. ```sh $ npm install on-finished ``` -------------------------------- ### Add express(1) npm install reminder Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/History.md Includes a reminder to run `npm install` in newly generated Express applications. This helps ensure that all project dependencies are correctly installed after project creation. ```bash # After running 'express myapp': cd myapp npm install ``` -------------------------------- ### Install binary-extensions via npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/binary-extensions/readme.md This command installs the binary-extensions package using npm, making it available for use in your Node.js projects. Ensure you have Node.js and npm installed. ```sh npm install binary-extensions ``` -------------------------------- ### Install BSON Package Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/bson/README.md This command installs the BSON package using npm. It is the standard method for adding the library to your Node.js project. ```shell npm install bson ``` -------------------------------- ### Install yn using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/yn/readme.md This command installs the 'yn' package using npm, making it available for use in your Node.js project. Ensure you have Node.js and npm installed. ```bash npm install yn ``` -------------------------------- ### Engine.IO Client Setup (HTML/JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md Initializes an Engine.IO client connection to a server. It includes the necessary script and demonstrates how to establish a socket connection, listen for 'open', 'message', and 'close' events. ```html ``` -------------------------------- ### Install Punycode.js via npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/punycode/README.md This command installs the Punycode.js library as a dependency for your project using npm. ```bash npm install punycode --save ``` -------------------------------- ### Install color-convert using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/color-convert/README.md Instructions for installing the color-convert library using npm, the Node Package Manager. ```bash $ npm install color-convert ``` -------------------------------- ### Install anymatch with npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/anymatch/README.md Installs the anymatch module using npm. This is the initial step to include the library in your project. ```sh npm install anymatch ``` -------------------------------- ### Server Initialization and Options Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md Details on how to initialize the server and the various options available for configuration, including timeouts, buffer sizes, transport settings, and compression. ```APIDOC ## POST /api/server/constructor ### Description Initializes the server with optional configuration. ### Method POST ### Endpoint /api/server/constructor ### Parameters #### Request Body - **options** (Object) - Optional - Configuration options for the server. - **pingTimeout** (Number) - Optional - How many ms without a pong packet to consider the connection closed (default: 20000). - **pingInterval** (Number) - Optional - How many ms before sending a new ping packet (default: 25000). - **upgradeTimeout** (Number) - Optional - How many ms before an uncompleted transport upgrade is cancelled (default: 10000). - **maxHttpBufferSize** (Number) - Optional - Maximum bytes or characters a message can be before closing the session (default: 1E6). - **allowRequest** (Function) - Optional - A function to determine if a handshake or upgrade request should be allowed. - **transports** (Array) - Optional - Allowed connection transports (default: ['polling', 'websocket']). - **allowUpgrades** (Boolean) - Optional - Whether to allow transport upgrades (default: true). - **perMessageDeflate** (Object|Boolean) - Optional - Parameters for WebSocket permessage-deflate extension (default: false). - **threshold** (Number) - Optional - Data is compressed only if byte size is above this value (default: 1024). - **httpCompression** (Object|Boolean) - Optional - Parameters for http compression for polling transports (default: true). - **threshold** (Number) - Optional - Data is compressed only if byte size is above this value (default: 1024). - **cookie** (Object|Boolean) - Optional - Configuration for the cookie used in handshake response headers (default: false). - **wsEngine** (Function) - Optional - WebSocket server implementation to use (default: ws). - **cors** (Object) - Optional - Options forwarded to the cors module (default: no CORS allowed). - **initialPacket** (Object) - Optional - An optional packet to concatenate to the handshake packet. - **allowEIO3** (Boolean) - Optional - Whether to support v3 Engine.IO clients (default: false). ### Response #### Success Response (200) - **Server** (Object) - The initialized server instance. ### Response Example ```json { "serverInstance": "..." } ``` ``` -------------------------------- ### Install serve-static using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/serve-static/README.md This command installs the serve-static module locally for a Node.js project. It is a prerequisite for using the module in your application. Ensure you have Node.js and npm installed. ```sh npm install serve-static ``` -------------------------------- ### Install concurrently Globally Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/concurrently/README.md Installs the concurrently tool globally, making it accessible system-wide. This allows you to use the `concurrently` command from any directory without needing to install it for each project. ```bash npm i -g concurrently yarn global add concurrently pnpm add -g concurrently bun add -g concurrently ``` -------------------------------- ### Get range of first matching pair (JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/balanced-match/README.md This example shows how to use the `balanced.range` function to retrieve only the start and end indices of the first non-nested matching pair of delimiters in a string. This is useful when only the location of the match is needed, without the surrounding text. It also handles string and regex delimiters. ```javascript var balanced = require('balanced-match'); // Assuming 'example.js' contains the calls to balanced.range // Example usage: // console.log(balanced.range('{', '}', 'pre{in{nested}}post')); // console.log(balanced.range('{', '}', 'pre{first}between{second}post')); ``` -------------------------------- ### Install range-parser Node.js Module Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/range-parser/README.md Instructions for installing the range-parser Node.js module using npm. This is a standard Node.js package. ```sh npm install range-parser ``` -------------------------------- ### Engine.IO Client Installation Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md This snippet demonstrates how to clone the Engine.IO repository and install its dependencies using npm. This is the standard procedure for setting up the project for development, testing, or contributing. ```shell git clone git://github.com/LearnBoost/engine.io.git cd engine.io npm install ``` -------------------------------- ### Install TypeScript (Stable) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/typescript/README.md Command to install the latest stable version of TypeScript as a development dependency using npm. ```bash npm install -D typescript ``` -------------------------------- ### Authentication Example in Express.js Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/History.md Includes an example demonstrating how to implement authentication within an Express.js application. This serves as a starting point for securing routes. ```javascript // Conceptual example of an authentication route app.post('/login', function(req, res, next) { // Authentication logic here // if (authenticated) { // res.redirect('/dashboard'); // } else { // res.send('Invalid credentials'); // } }); ``` -------------------------------- ### Install Dependencies using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/whatwg-url/README.md Installs the necessary project dependencies using the Node Package Manager (npm). This command should be run from the project's root directory. ```bash npm install ``` -------------------------------- ### Install Yargs (Stable and Bleeding Edge) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/yargs/README.md Instructions for installing the stable version of Yargs using npm, and the bleeding edge version for the most recent features. ```bash npm i yargs npm i yargs@next ``` -------------------------------- ### Install string-width using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/string-width/readme.md This command installs the string-width package using npm, the Node Package Manager. It adds the package to your project's dependencies. ```bash npm install string-width ``` -------------------------------- ### Install require-directory Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/require-directory/README.markdown This command installs the require-directory package using npm. It is a prerequisite for using the package in your Node.js project. ```bash npm install require-directory ``` -------------------------------- ### Build and Run Live Viewer using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/whatwg-url/README.md Prepares and builds the live viewer for the project using npm scripts. This typically involves compiling assets and setting up a development server. ```bash npm run prepare npm run build-live-viewer ``` -------------------------------- ### Install Chalk npm package Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/chalk/readme.md This command installs the 'chalk' npm package, which is a popular library for adding color and styling to terminal output. It is a prerequisite for using the subsequent JavaScript code examples. ```console $ npm install chalk ``` -------------------------------- ### Install object-assign using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/object-assign/readme.md This snippet shows how to install the object-assign package using npm. This is a prerequisite for using the package in your project. ```bash $ npm install --save object-assign ``` -------------------------------- ### Install TypeScript (Nightly) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/typescript/README.md Command to install the latest nightly build of TypeScript as a development dependency using npm. ```bash npm install -D typescript@next ``` -------------------------------- ### Instantiate Engine.IO Server Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md Demonstrates various ways to instantiate an Engine.IO server, either by directly calling the module or by attaching it to an existing Node.js http.Server instance. Options can be passed during instantiation. ```javascript const httpServer; // previously created with `http.createServer();` from node.js api. // create a server first, and then attach const eioServer = require('engine.io').Server(); eioServer.attach(httpServer); // or call the module as a function to get `Server` const eioServer = require('engine.io')(); eioServer.attach(httpServer); // immediately attach const eioServer = require('engine.io')(httpServer); // with custom options const eioServer = require('engine.io')(httpServer, { maxHttpBufferSize: 1e3 }); ``` -------------------------------- ### Setup Lodash CLI Environment Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/lodash/release.md Creates a directory structure for lodash-cli, copies lodash.js and package.json into it, and installs production dependencies. This setup is likely for preparing lodash-cli to work with a specific lodash version. ```sh mkdir -p ./node_modules/lodash-cli/node_modules/lodash; cd $_; cp ../../../../lodash.js ./lodash.js; cp ../../../../package.json ./package.json ``` ```sh cd ../../; npm i --production; cd ../.. ``` -------------------------------- ### Usage Example: Get and Set Object Prototype with dunder-proto Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/dunder-proto/README.md This JavaScript example demonstrates how to use the 'getDunder' and 'setDunder' functions from the 'dunder-proto' library. It asserts the initial prototype of an object, sets it to null, and then asserts the change. It requires the 'assert' module for verification. ```javascript const assert = require('assert'); const getDunder = require('dunder-proto/get'); const setDunder = require('dunder-proto/set'); const obj = {}; assert.equal('toString' in obj, true); assert.equal(getDunder(obj), Object.prototype); setDunder(obj, null); assert.equal('toString' in obj, false); assert.equal(getDunder(obj), null); ``` -------------------------------- ### Install node-touch via npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/touch/README.md Installs the node-touch package using npm. This is the primary method for adding the library to your Node.js project. ```bash npm install touch ``` -------------------------------- ### Install memory-pager using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/memory-pager/README.md This command installs the memory-pager package from npm, making it available for use in your Node.js project. ```bash npm install memory-pager ``` -------------------------------- ### Socket.IO Installation (Bash) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/socket.io/Readme.md Provides commands to install the Socket.IO library using package managers npm and yarn. These commands are typically run in a terminal within your project directory. ```bash // with npm npm install socket.io ``` ```bash // with yarn yarn add socket.io ``` -------------------------------- ### Deno/ESM Support for CLI UI Creation (TypeScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/cliui/README.md Illustrates how to use cliui with Deno and ESM modules. This example shows the import statement for Deno and the basic setup for creating a simple CLI interface structure, similar to the JavaScript example but adapted for modern module systems. ```typescript import cliui from "https://deno.land/x/cliui/deno.ts"; const ui = cliui({}) ui.div('Usage: $0 [command] [options]') ui.div({ text: 'Options:', padding: [2, 0, 1, 0] }) ui.div({ text: "-f, --file", width: 20, padding: [0, 4, 0, 4] }) console.log(ui.toString()) ``` -------------------------------- ### Install unpipe package Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/unpipe/README.md Installs the unpipe package using npm. This is a prerequisite for using the unpipe functionality in your Node.js project. ```sh npm install unpipe ``` -------------------------------- ### Install raw-body using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/raw-body/README.md Installs the raw-body module for Node.js projects using the npm package manager. ```sh npm install raw-body ``` -------------------------------- ### Initialize Node.js Project Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mongodb/README.md Creates a new project directory and initializes it with a package.json file using npm init. ```bash mkdir myProject cd myProject npm init -y ``` -------------------------------- ### Usage Example: Safe Array Slice with call-bound Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/call-bound/README.md This JavaScript example demonstrates how to use 'call-bound' to safely access the Array.prototype.slice method. It first gets a bound version of 'slice', then temporarily removes the original 'slice' from Array.prototype to prove the bound version works independently. Finally, it asserts the correctness of the slicing operation. ```javascript const assert = require('assert'); const callBound = require('call-bound'); const slice = callBound('Array.prototype.slice'); delete Function.prototype.call; delete Function.prototype.bind; delete Array.prototype.slice; assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]); ``` -------------------------------- ### Install sparse-bitfield using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/sparse-bitfield/README.md This command installs the sparse-bitfield module from the npm registry. It is a direct dependency for using the sparse bitfield functionality in your project. ```bash npm install sparse-bitfield ``` -------------------------------- ### Basic Express.js app with cookie-parser middleware Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/cookie-parser/README.md This example shows a minimal Express.js application setup that includes the cookie-parser middleware. It demonstrates how to log both regular and signed cookies from incoming requests. ```javascript var express = require('express') var cookieParser = require('cookie-parser') var app = express() app.use(cookieParser()) app.get('/', function (req, res) { // Cookies that have not been signed console.log('Cookies: ', req.cookies) // Cookies that have been signed console.log('Signed Cookies: ', req.signedCookies) }) app.listen(8080) ``` -------------------------------- ### Server Instantiation API Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md This section details how to create a new Engine.IO server instance, either by attaching to an existing HTTP server or by instantiating it directly. ```APIDOC ## Server Instantiation ### Description Returns a new `Server` instance. If the first argument is an `http.Server` then the new `Server` instance will be attached to it. Otherwise, the arguments are passed directly to the `Server` constructor. ### Method `require('engine.io')()` or `require('engine.io').Server()` ### Parameters - **http.Server** (http.Server) - Optional - The HTTP server instance to attach to. - **Object** (Object) - Optional - Options object for the server constructor. ### Request Example ```javascript // Create a server first, and then attach const httpServer; const eioServer = require('engine.io').Server(); eioServer.attach(httpServer); // or call the module as a function to get `Server` const eioServer = require('engine.io')(); eioServer.attach(httpServer); // immediately attach const eioServer = require('engine.io')(httpServer); // with custom options const eioServer = require('engine.io')(httpServer, { maxHttpBufferSize: 1000 }); ``` ### Response #### Success Response (200) - **Server** (Object) - A new Engine.IO Server instance. #### Response Example ```json { "message": "Server instance created and attached successfully." } ``` ``` -------------------------------- ### React Native Polyfill Setup for BSON Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/bson/README.md Provides the necessary polyfills for React Native projects when using the BSON library. It includes installing `react-native-get-random-values` and importing it at the entry point. ```typescript // Required Polyfills For ReactNative import 'react-native-get-random-values'; ``` ```typescript import { BSON, EJSON } from 'bson'; ``` -------------------------------- ### Install tslib using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/tslib/README.md Provides npm commands for installing the tslib library. It includes specific commands for different versions of TypeScript to ensure compatibility. For newer versions (3.9.2+), a direct install is recommended, while older versions might require specifying a version range. ```Shell # TypeScript 3.9.2 or later npm install tslib # TypeScript 3.8.4 or earlier npm install tslib@^1 # TypeScript 2.3.2 or earlier npm install tslib@1.6.1 ``` -------------------------------- ### Nodemon Configuration Example Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/nodemon/README.md An example of a nodemon.json configuration file. This file allows for custom settings such as verbose logging, file ignores, and mapping file extensions to specific executables. ```json { "verbose": true, "ignore": ["*.test.js", "**/fixtures/**"], "execMap": { "rb": "ruby", "pde": "processing --sketch={{pwd}} --run" } } ``` -------------------------------- ### Comments in .env file Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/dotenv/README-es.md This example illustrates how to add comments in a .env file. Comments start with '#' and can be on their own line or at the end of a line. Values containing '#' should be enclosed in quotes. ```dosini # This is a comment SECRET_KEY=YOURSECRETKEYGOESHERE # comment SECRET_HASH="something-with-a-#-hash" ``` -------------------------------- ### Calculate string width with JavaScript Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/string-width/readme.md This JavaScript snippet demonstrates how to use the string-width module. It shows examples of calculating the width of a standard character, a fullwidth character, and a string with ANSI escape codes. ```javascript const stringWidth = require('string-width'); stringWidth('a'); //=> 1 stringWidth('古'); //=> 2 stringWidth('\u001B[1m古\u001B[22m'); //=> 2 ``` -------------------------------- ### Engine.IO Server: Listen on a Port (JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md Sets up an Engine.IO server to listen on a specified port. It handles incoming connections and allows sending string or binary data to clients. This is a straightforward way to start an Engine.IO server. ```javascript const engine = require('engine.io'); const server = engine.listen(80); server.on('connection', socket => { socket.send('utf 8 string'); socket.send(Buffer.from([0, 1, 2, 3, 4, 5])); // binary data }); ``` -------------------------------- ### Get proxied request address with IPv6 trust Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/proxy-addr/README.md This example illustrates proxyaddr's support for IPv6 addresses. It shows how to specify IPv6 addresses and CIDR ranges for trust, including automatic normalization of IPv6 formats. ```javascript proxyaddr(req, '::1') proxyaddr(req, ['::1/128', 'fe80::/10']) ``` -------------------------------- ### Usage Example for side-channel-list Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/side-channel-list/README.md This JavaScript example demonstrates how to use the side-channel-list library. It shows initializing the channel, setting a key-value pair, asserting its existence, retrieving the value, and deleting the key. Assertions are used to verify the expected behavior. ```javascript const assert = require('assert'); const getSideChannelList = require('side-channel-list'); const channel = getSideChannelList(); const key = {}; assert.equal(channel.has(key), false); assert.throws(() => channel.assert(key), TypeError); channel.set(key, 42); channel.assert(key); // does not throw assert.equal(channel.has(key), true); assert.equal(channel.get(key), 42); channel.delete(key); assert.equal(channel.has(key), false); assert.throws(() => channel.assert(key), TypeError); ``` -------------------------------- ### Install Nodemon Globally (npm/yarn) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/nodemon/README.md Installs nodemon globally on your system using either npm or yarn. This makes the 'nodemon' command available system-wide. ```bash npm install -g nodemon # or using yarn: yarn global add nodemon ``` -------------------------------- ### Send a file for download with Content-Disposition in Node.js Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/content-disposition/README.md This example illustrates a complete Node.js HTTP server setup to send a file for download. It correctly sets the 'Content-Type' and 'Content-Disposition' headers using the 'content-disposition' package and pipes the file stream to the response. ```js var contentDisposition = require('content-disposition') var destroy = require('destroy') var fs = require('fs') var http = require('http') var onFinished = require('on-finished') var filePath = '/path/to/public/plans.pdf' http.createServer(function onRequest (req, res) { // set headers res.setHeader('Content-Type', 'application/pdf') res.setHeader('Content-Disposition', contentDisposition(filePath)) // send file var stream = fs.createReadStream(filePath) stream.pipe(res) onFinished(res, function () { destroy(stream) }) }) ``` -------------------------------- ### Install @jridgewell/sourcemap-codec Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@jridgewell/sourcemap-codec/README.md Installs the sourcemap-codec package using npm. This is the primary way to add the library to your project for encoding and decoding sourcemap mappings. ```bash npm install @jridgewell/sourcemap-codec ``` -------------------------------- ### Get and Use JavaScript Intrinsics with get-intrinsic Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/get-intrinsic/README.md This example demonstrates how to use the `get-intrinsic` package to retrieve and utilize built-in JavaScript methods and properties. It shows how to access static methods like `Math.pow` and instance methods like `Array.prototype.push`. The example also illustrates how `get-intrinsic` can be used to access these intrinsics even after they have been deleted from their original locations, and how it handles missing intrinsics by throwing an error or returning undefined. ```javascript var GetIntrinsic = require('get-intrinsic'); var assert = require('assert'); // static methods assert.equal(GetIntrinsic('%Math.pow%'), Math.pow); assert.equal(Math.pow(2, 3), 8); assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); delete Math.pow; assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); // instance methods var arr = [1]; assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push); assert.deepEqual(arr, [1]); arr.push(2); assert.deepEqual(arr, [1, 2]); GetIntrinsic('%Array.prototype.push%').call(arr, 3); assert.deepEqual(arr, [1, 2, 3]); delete Array.prototype.push; GetIntrinsic('%Array.prototype.push%').call(arr, 4); assert.deepEqual(arr, [1, 2, 3, 4]); // missing features delete JSON.parse; // to simulate a real intrinsic that is missing in the environment assert.throws(() => GetIntrinsic('%JSON.parse%')); assert.equal(undefined, GetIntrinsic('%JSON.parse%', true)); ``` -------------------------------- ### Install ws library Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/ws/README.md Installs the 'ws' Node.js WebSocket library using npm. This is the primary step to include WebSocket functionality in your project. ```bash npm install ws ``` -------------------------------- ### Usage Example: side-channel JavaScript Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/side-channel/README.md Demonstrates how to use the 'side-channel' package in JavaScript. It covers initializing a channel, setting, getting, asserting, and deleting key-value pairs, including error handling for non-existent keys. ```javascript const assert = require('assert'); const getSideChannel = require('side-channel'); const channel = getSideChannel(); const key = {}; assert.equal(channel.has(key), false); assert.throws(() => channel.assert(key), TypeError); channel.set(key, 42); channel.assert(key); // does not throw assert.equal(channel.has(key), true); assert.equal(channel.get(key), 42); channel.delete(key); assert.equal(channel.has(key), false); assert.throws(() => channel.assert(key), TypeError); ``` -------------------------------- ### Deprecate Property Access with `depd` (JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/depd/Readme.md The `depd` module can be used to mark property access (both getting and setting) as deprecated. This example shows how to automatically derive the message from the property name or provide an explicit message. ```javascript var deprecate = require('depd')('my-cool-module') exports.oldprop = 'something' // message automatically derives from property name deprecate.property(exports, 'oldprop') // explicit message deprecate.property(exports, 'oldprop', 'oldprop >= 0.10') ``` -------------------------------- ### Basic Hello World Express.js Server Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/Readme.md This JavaScript code snippet demonstrates the creation of a basic 'Hello World' web server using the Express.js framework. It requires Node.js and the 'express' package to be installed. The server listens on port 3000 and responds with 'Hello World' to requests on the root path. ```javascript const express = require('express') const app = express() app.get('/', function (req, res) { res.send('Hello World') }) app.listen(3000) ``` -------------------------------- ### Install side-channel-list via npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/side-channel-list/README.md This command installs the side-channel-list package as a dependency for your project using npm. It is a prerequisite for using the library in your JavaScript applications. ```sh npm install --save side-channel-list ``` -------------------------------- ### Listen on Port with Engine.IO Server Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md Shows how to start an Engine.IO server that listens on a specified port. This method also creates an http.Server internally and attaches the Engine.IO server to it. Custom options can be provided. ```javascript const engine = require('engine.io'); const server = engine.listen(3000, { pingTimeout: 2000, pingInterval: 10000 }); server.on('connection', /* ... */); ``` -------------------------------- ### Simple Static File Serving with Express Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/serve-static/README.md This example shows a basic setup for serving static files using Express and the 'serve-static' middleware. It serves files from the 'public/ftp' directory and uses a default index file. ```javascript var express = require('express') var serveStatic = require('serve-static') var app = express() app.use(serveStatic('public/ftp', { index: ['default.html', 'default.htm'] })) app.listen(3000) ``` -------------------------------- ### Get proxied request address with custom trust function Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/proxy-addr/README.md This example shows how to use the proxyaddr function to determine the proxied request's address. It employs a custom trust function that validates if an IP address is '127.0.0.1'. The function returns the closest trusted address. ```javascript proxyaddr(req, function (addr) { return addr === '127.0.0.1' }) proxyaddr(req, function (addr, i) { return i < 1 }) ``` -------------------------------- ### Standalone Socket.IO Server Setup Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/socket.io/Readme.md Demonstrates setting up Socket.IO in a standalone mode without explicitly creating an HTTP server first. It handles connections and client events. Requires the 'socket.io' module. ```javascript const io = require('socket.io')(); io.on('connection', client => { ... }); io.listen(3000); ``` -------------------------------- ### CLI UI Initialization Methods (JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/cliui/README.md Provides examples of initializing the cliui library with specific configurations. It covers setting the maximum width of the UI and enabling or disabling text wrapping within columns. These methods allow for fine-tuning the output's appearance. ```javascript cliui = require('cliui') ``` ```javascript cliui({width: integer}) ``` ```javascript cliui({wrap: boolean}) ``` -------------------------------- ### Enable Debug Output via npm Script (Windows) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/socket.io-parser/node_modules/debug/README.md This JavaScript object shows an example of a Windows-specific npm script configuration that enables the DEBUG environment variable using PowerShell before executing a Node.js application. This is useful for CI/CD or local development setups on Windows. ```javascript "windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js" ``` -------------------------------- ### Set Nested Array Elements with mpath.set Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mpath/README.md This example demonstrates how to set values within nested arrays using mpath.set. It shows updating a specific element in a nested structure. The input is an object, and the output is the modified object. ```javascript var obj = { comments: [ { title: ['hilarious', 'fruity'] }, { title: ['hilarious', 'fruity'] } ] }; mpath.set('comments.$.title', ['hilarious', 'fruity'], obj); console.log(obj); ``` -------------------------------- ### Build Documentation with Verb Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/braces/README.md Installs the necessary documentation generation tools globally and then runs the 'verb' command to generate the README file. This process is intended for project maintainers as direct README edits are discouraged. ```bash $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` -------------------------------- ### mquery find() Query Construction Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mquery/README.md Illustrates the basic usage of the `find()` method in mquery to initiate a query. It shows how to call `find()` without arguments to get all documents, or with a match clause to filter documents based on specific criteria. The example also demonstrates awaiting the results. ```javascript const mquery = require('mquery'); // Find all documents in the collection const allDocs = await mquery().find().toArray(); // Find documents matching a specific criteria const matchCriteria = { status: 'published', author: 'John Doe' }; const filteredDocs = await mquery().find(matchCriteria).toArray(); // Example demonstrating awaiting results and checking type const docs = await mquery().find({ category: 'technology' }); console.log(Array.isArray(docs)); // Should output true ``` -------------------------------- ### Install Lodash using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/lodash/README.md Commands to install Lodash globally and as a project dependency using npm. Assumes npm is already installed or installed with the first command. ```shell npm i -g npm npm i --save lodash ``` -------------------------------- ### Socket.IO with Module Syntax (import) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/socket.io/Readme.md Shows how to initialize Socket.IO using ES module syntax. It requires the 'socket.io' Server class and attaches it to an existing server instance. Assumes 'server' is an HTTP server instance. ```javascript import { Server } from "socket.io"; const io = new Server(server); io.listen(3000); ``` -------------------------------- ### Install @types/mime Package Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@types/mime/README.md Installs the @types/mime package, which provides type definitions for the mime library. This is a development dependency used for static type checking in TypeScript projects. No specific inputs or outputs are associated with this command beyond the installation process itself. It requires Node.js and npm to be installed. ```bash npm install --save @types/mime ``` -------------------------------- ### Install SWC Core and Helper Packages Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/ts-node/README.md These commands install the necessary SWC packages for ts-node integration. '@swc/core' is required for transpilation. '@swc/helpers' is needed if 'importHelpers' is enabled. 'regenerator-runtime' is necessary for older targets (pre-ES2015) when using async/await or generators. ```shell npm i -D @swc/core @swc/helpers regenerator-runtime ``` -------------------------------- ### Install tslib using JSPM Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/tslib/README.md Provides JSPM commands for installing the tslib library. It offers version-specific installation commands, allowing users to install the appropriate tslib version according to their TypeScript version. ```Shell # TypeScript 3.9.2 or later jspm install tslib # TypeScript 3.8.4 or earlier jspm install tslib@^1 # TypeScript 2.3.2 or earlier jspm install tslib@1.6.1 ``` -------------------------------- ### Set Nested Array Elements with Mapping Function using mpath.set Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mpath/README.md This example shows how to use mpath.set with a mapping function to transform values while setting them. The mapping function is applied to each value being set, allowing for dynamic updates. The input is an object, and the output is the modified object with transformed values. ```javascript var obj = { comments: [ { title: 'funny' }, { title: 'exciting!' } ] }; mpath.set('comments.title', ['hilarious', 'fruity'], obj, function (val) { return val.length; }); console.log(obj); ``` -------------------------------- ### Get first matching pair of braces (JavaScript) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/balanced-match/README.md This snippet demonstrates how to use the `balanced` function to find the first non-nested matching pair of specified delimiters within a string. It supports both string and regular expression delimiters. The function returns an object containing the start and end indices, preamble, body, and postscript of the match. ```javascript var balanced = require('balanced-match'); console.log(balanced('{', '}', 'pre{in{nested}}post')); console.log(balanced('{', '}', 'pre{first}between{second}post')); console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); ``` -------------------------------- ### Instantiate and Save Mongoose Model Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mongoose/README.md Demonstrates how to create an instance of a Mongoose model, set its properties, and save it to the database using `await instance.save()`. ```javascript const instance = new MyModel(); instance.my.key = 'hello'; await instance.save(); ``` -------------------------------- ### Install @types/cookie with npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@types/cookie/README.md Installs the @types/cookie package, which provides type definitions for the cookie module. This is a development dependency. ```bash npm install --save @types/cookie ``` -------------------------------- ### Installing dotenvx Git Pre-commit Hook Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/dotenv/README.md Demonstrates how to install the dotenvx git pre-commit hook to prevent accidentally committing .env files to code repositories. This involves installing dotenvx via Homebrew and running the installation command. ```bash brew install dotenvx/brew/dotenvx dotenvx precommit --install ``` -------------------------------- ### Set Custom Object Type Properties with mpath.set Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/mpath/README.md This example illustrates how to use mpath.set to update properties within custom object types by specifying an internal data property. This is useful for ODMs or other objects that manage their data internally. The function traverses the specified internal property for setting values. ```javascript var mpath = require('mpath'); var obj = { comments: [ { title: 'exciting!', _doc: { title: 'great!' }} ] }; mpath.set('comments.0.title', 'nov 3rd', obj, '_doc'); console.log(mpath.get('comments.0.title', obj, '_doc')); // 'nov 3rd' console.log(mpath.get('comments.0.title', obj)); // 'exciting' ``` -------------------------------- ### Install Source Map Support (npm) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@cspotcode/source-map-support/README.md Installs the @cspotcode/source-map-support package using npm. This is the initial step for integrating source map capabilities into your project. ```bash npm install @cspotcode/source-map-support ``` -------------------------------- ### Install @types/send using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/@types/send/README.md This command installs the @types/send package as a development dependency. This package provides TypeScript type definitions for the 'send' library, enhancing type safety and autocompletion in TypeScript projects. Ensure you have Node.js and npm installed. ```bash npm install --save @types/send ``` -------------------------------- ### Nodemon Configuration Options Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/nodemon/doc/cli/help.txt Lists common command-line options for nodemon, including configuration file specification, extension monitoring, script execution, watch directories, and ignored files. ```bash nodemon [options] [script.js] [args] Options: --config file ............ alternate nodemon.json config file to use -e, --ext ................ extensions to look for, ie. js,pug,hbs. -x, --exec app ........... execute script with "app", ie. -x "python -v". -w, --watch path ......... watch directory "path" or files. use once for each directory or file to watch. -i, --ignore ............. ignore specific files or directories. -V, --verbose ............ show detail on what is causing restarts. -- ........... to tell nodemon stop slurping arguments. ``` -------------------------------- ### Initialize Server Constructor with Options Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/engine.io/README.md The constructor initializes the server with optional configuration parameters. These parameters control various aspects of the server's behavior, such as timeouts, message size limits, allowed transports, and compression settings. It allows for customization of WebSocket engines and CORS policies. ```javascript const server = new Server(options); // Example options: const options = { pingTimeout: 20000, pingInterval: 25000, upgradeTimeout: 10000, maxHttpBufferSize: 1E6, allowRequest: (req, callback) => { callback(null, true); }, transports: ['polling', 'websocket'], allowUpgrades: true, perMessageDeflate: { threshold: 1024 }, httpCompression: { threshold: 1024 }, cookie: { name: 'sid' }, wsEngine: require('ws'), cors: { origin: "*" }, initialPacket: { type: "greeting", data: "hello" }, allowEIO3: false }; ``` -------------------------------- ### Install http-errors using npm Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/http-errors/README.md Installs the http-errors module from the npm registry. This is a standard Node.js module and requires npm to be installed. ```console $ npm install http-errors ``` -------------------------------- ### Add simple _json-config_ example Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/express/History.md Includes a basic example demonstrating how to use JSON configuration files within an Express application. This illustrates a common pattern for managing application settings. ```javascript // Assuming a config.json file exists: // { // "port": 3000 // } var config = require('./config.json'); app.listen(config.port, function() { console.log('Server listening on port ' + config.port); }); ``` -------------------------------- ### Install and Test Project Dependencies (Bash) Source: https://github.com/sahilchauhan0603/canvas_draw_vs/blob/main/server/node_modules/iconv-lite/README.md Provides bash commands to clone a Git repository, install its Node.js dependencies using npm, and run the project's test suite. It also shows how to view performance metrics and code coverage reports. ```bash git clone git@github.com:ashtuchkin/iconv-lite.git cd iconv-lite npm install npm test # To view performance: node test/performance.js # To view test coverage: npm run coverage open coverage/lcov-report/index.html ```