### Quick Start with Mime Module Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/mime/README.md A quick example demonstrating how to use the `getType` and `getExtension` methods of the Mime module. ```javascript const mime = require('mime'); mime.getType('txt'); // 'text/plain' mime.getExtension('text/plain'); // 'txt' ``` -------------------------------- ### Initialize and Start Vagrant VM Source: https://github.com/mit-cml/appinventor-sources/blob/master/README.md Install the Vagrant plugin and bring up the virtual machine for development. This initializes the VM with App Inventor dependencies. ```bash vagrant plugin install vagrant-vbguest vagrant up ``` -------------------------------- ### AES-256 Encryption Example (Key and IV Setup) Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/Pods/CryptoSwift/README.md Demonstrates setting up an AES-256 cryptor with a derived key and a random IV. ```swift let password: [UInt8] = Array("s33krit".utf8) let salt: [UInt8] = Array("nacllcan".utf8) /* Generate a key from a `password`. Optional if you already have a key */ let key = try PKCS5.PBKDF2( password: password, salt: salt, iterations: 4096, keyLength: 32, /* AES-256 */ variant: .sha256 ).calculate() /* Generate random IV value. IV is public value. Either need to generate, or get it from elsewhere */ let iv = AES.randomIV(AES.blockSize) /* AES cryptor instance */ let aes = try AES(key: key, blockMode: CBC(iv: iv), padding: .pkcs7) /* Encrypt Data */ let inputData = Data() let encryptedBytes = try aes.encrypt(inputData.bytes) let encryptedData = Data(encryptedBytes) /* Decrypt Data */ let decryptedBytes = try aes.decrypt(encryptedData.bytes) let decryptedData = Data(decryptedBytes) ``` -------------------------------- ### Deno/ESM CLI UI Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/node_modules/cliui/README.md Shows how to use cliui with Deno and ESM modules, including basic layout setup. ```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()) ``` -------------------------------- ### Basic qjobs Usage Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/qjobs/Readme.md Demonstrates how to initialize qjobs, add multiple jobs, and handle various queue events like start, end, jobStart, jobEnd, pause, and unpause. This example shows dynamic job addition and pausing the queue. ```javascript var qjobs = new require('./qjobs'); // My non blocking main job var myjob = function(args,next) { setTimeout(function() { console.log('Do something interesting here',args); next(); },1000); } var q = new qjobs({maxConcurrency:10}); // Let's add 30 job to the queue for (var i = 0; i<30; i++) { q.add(myjob,[i,'test '+i]); } q.on('start',function() { console.log('Starting ...'); }); q.on('end',function() { console.log('... All jobs done'); }); q.on('jobStart',function(args) { console.log('jobStart',args); }); q.on('jobEnd',function(args) { console.log('jobend',args); // If i'm jobId 10, then make a pause of 5 sec if (args._jobId == 10) { q.pause(true); setTimeout(function() { q.pause(false); },5000); } }); q.on('pause',function(since) { console.log('in pause since '+since+' milliseconds'); }); q.on('unpause',function() { console.log('pause end, continu ..'); }); q.run(); //q.abort() will empty jobs list ``` -------------------------------- ### OS X Swift 'Hello World' HTTP Server Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/Pods/GCDWebServer/README.md A Swift command-line tool example for OS X that sets up an HTTP server using GCDWebServer. It handles GET requests and serves a 'Hello World' HTML page. Requires a bridging header for Objective-C imports. ```swift import Foundation import GCDWebServer func initWebServer() { let webServer = GCDWebServer() webServer.addDefaultHandlerForMethod("GET", requestClass: GCDWebServerRequest.self, processBlock: {request in return GCDWebServerDataResponse(HTML:"
Hello World
") }) webServer.runWithPort(8080, bonjourName: "GCD Web Server") print("Visit \(webServer.serverURL) in your web browser") } ``` ```objectivec #importHello World
"]; }]; // Use convenience method that runs server on port 8080 // until SIGINT (Ctrl-C in Terminal) or SIGTERM is received [webServer runWithPort:8080 bonjourName:nil]; NSLog(@"Visit %@ in your web browser", webServer.serverURL); } return 0; } ``` -------------------------------- ### Install p-limit Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/p-limit/readme.md Install the p-limit package using npm. ```bash $ npm install p-limit ``` -------------------------------- ### Install universalify Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/streamroller/node_modules/universalify/README.md Install the universalify package using npm. ```bash npm install universalify ``` -------------------------------- ### Install is-binary-path Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/is-binary-path/readme.md Install the is-binary-path module using npm. ```bash $ npm install is-binary-path ``` -------------------------------- ### Install isbinaryfile Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/isbinaryfile/README.md Install the isbinaryfile package using npm. ```bash npm install isbinaryfile ``` -------------------------------- ### Install CORS Type Definitions Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/@types/cors/README.md Install the @types/cors package as a development dependency to get TypeScript support for the cors middleware. ```bash npm install --save @types/cors ``` -------------------------------- ### Build Documentation Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/normalize-path/README.md Install global dependencies and run the verb command to generate the README.md file. ```sh npm install -g verbose/verb#dev verb-generate-readme && verb ``` -------------------------------- ### Install GCDWebServer using Carthage Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/Pods/GCDWebServer/README.md Add this line to your Cartfile to install GCDWebServer using Carthage. Note that Carthage support started with version 3.2.5. ```ruby github "swisspol/GCDWebServer" ~> 3.2.5 ``` -------------------------------- ### VideoPlayer Methods Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/html/reference/components/media.html Methods for controlling video playback, including getting duration, pausing, seeking, starting, and stopping. ```APIDOC ## GetDuration() ### Description Returns duration of the video in milliseconds. ### Method GetDuration ### Parameters None ### Response - **duration** (number) - The duration of the video in milliseconds. ``` ```APIDOC ## Pause() ### Description Pauses playback of the video. Playback can be resumed at the same location by calling the [`Start`](#VideoPlayer.Start) method. ### Method Pause ### Parameters None ``` ```APIDOC ## SeekTo(_ms_) ### Description Seeks to the requested time (specified in milliseconds) in the video. If the video is paused, the frame shown will not be updated by the seek. The player can jump only to key frames in the video, so seeking to times that differ by short intervals may not actually move to different frames. ### Method SeekTo ### Parameters #### Path Parameters - **ms** (number) - Required - The time in milliseconds to seek to. ``` ```APIDOC ## Start() ### Description Plays the media specified by the [`Source`](#VideoPlayer.Source). ### Method Start ### Parameters None ``` ```APIDOC ## Stop() ### Description Resets to start of video and pauses it if video was playing. ### Method Stop ### Parameters None ``` -------------------------------- ### Example CLI Execution and Output Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/yargs-parser/README.md Demonstrates how to run a script with arguments and the expected parsed output. ```sh node example.js --foo=33 --bar hello { _: [], foo: 33, bar: 'hello' } ``` -------------------------------- ### Basic CLI UI Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/node_modules/cliui/README.md Demonstrates creating a multi-column layout with text, descriptions, and alignment using cliui. ```javascript const ui = require('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] }, { text: "the file to load." + chalk.green("(if this description is long it wraps).") , width: 20 }, { text: chalk.red("[required]"), align: 'right' } ) console.log(ui.toString()) ``` -------------------------------- ### Usage Examples for call-bind and callBound Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/call-bind/README.md Demonstrates how to use `callBind` to create a bound function and `callBound` to get a bound version of a built-in method like `Array.prototype.slice`. This example also shows the behavior after `Function.prototype.call` and `bind` are deleted. ```js const assert = require('assert'); const callBind = require('call-bind'); const callBound = require('call-bind/callBound'); function f(a, b) { assert.equal(this, 1); assert.equal(a, 2); assert.equal(b, 3); assert.equal(arguments.length, 2); } const fBound = callBind(f); const slice = callBound('Array.prototype.slice'); delete Function.prototype.call; delete Function.prototype.bind; fBound(1, 2, 3); assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]); ``` -------------------------------- ### Simple Yargs Example Usage Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/yargs/README.md Demonstrates how to run the simple Yargs example with different arguments. ```bash $ ./plunder.js --ships=4 --distance=22 Plunder more riffiwobbles! $ ./plunder.js --ships 12 --distance 98.7 Retreat from the xupptumblers! ``` -------------------------------- ### Manual Installation Steps Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/Pods/SQLite.swift/README.md Steps for integrating SQLite.swift as an Xcode sub-project. This involves dragging the project file and linking the framework. ```text 1. Drag the **SQLite.xcodeproj** file into your own project. ([Submodule][], clone, or [download][] the project first.)  2. In your target’s **General** tab, click the **+** button under **Linked Frameworks and Libraries**. 3. Select the appropriate **SQLite.framework** for your platform. 4. **Add**. Some additional steps are required to install the application on an actual device: 5. In the **General** tab, click the **+** button under **Embedded Binaries**. 6. Select the appropriate **SQLite.framework** for your platform. 7. **Add**. ``` -------------------------------- ### Create and Initialize Connect App Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/connect/README.md Demonstrates how to require the connect module and create a new Connect application instance. ```javascript var connect = require('connect') var app = connect() ``` -------------------------------- ### App Inventor Blocks for Failed Web API Get Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/markdown/reference/other/json-web-apis.md This example demonstrates App Inventor blocks to handle a failed web API GET request. It checks for a 404 response code and displays an error message. ```App Inventor Blocks when Button1.Click do set Web1.Url to "https://jsonplaceholder.typicode.com/posts/101" call Web1.Get when Web1.GotText parameter responseCode parameter responseContent do if responseCode = 200 then set Label1.Text to Web.JsonTextDecodeWithDictionaries(responseContent).title set Label2.Text to Web.JsonTextDecodeWithDictionaries(responseContent).body else set Label1.Text to "Error" set Label2.Text to "Request failed: " .. responseCode ``` -------------------------------- ### Example: Using object-keys with an Object Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/object-keys/README.md Demonstrates how to import and use the object-keys shim to get an array of an object's own enumerable property names. ```javascript var keys = require('object-keys'); var assert = require('assert'); var obj = { a: true, b: true, c: true }; assert.deepEqual(keys(obj), ['a', 'b', 'c']); ``` -------------------------------- ### Starting Karma Server with New API Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/CHANGELOG.md Demonstrates the recommended way to start a Karma server instance using the new API, replacing deprecated methods. ```javascript const { Server } = require('karma'); const server = new Server(); server.start(); ``` -------------------------------- ### Enable All CORS Requests Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/cors/README.md Use the cors middleware to enable CORS for all requests to your Express application. This is the simplest way to get started with CORS. ```javascript var express = require('express') var cors = require('cors') var app = express() app.use(cors()) app.get('/products/:id', function (req, res, next) { res.json({msg: 'This is CORS-enabled for all origins!'}) }) app.listen(80, function () { console.log('CORS-enabled web server listening on port 80') }) ``` -------------------------------- ### Example Output 1 Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/minimist/README.md Demonstrates the output of basic argument parsing with simple key-value pairs. ```bash $ node example/parse.js -a beep -b boop { _: [], a: 'beep', b: 'boop' } ``` -------------------------------- ### balanced.range API Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/balanced-match/README.md Shows how the `balanced.range` function returns an array containing the start and end indices of the first non-nested matching pair. ```javascript var balanced = require('balanced-match'); console.log(balanced.range('{', '}', 'pre{in{nested}}post')); console.log(balanced.range('{', '}', 'pre{first}between{second}post')); console.log(balanced.range(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); ``` -------------------------------- ### Get Value at Key Path Example 1 Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/html/reference/blocks/dictionaries.html Demonstrates retrieving a nested value from a JSON-like dictionary using a key path. ```App Inventor Blocks get value at key path key path: ["school", "name"] dictionary: { "id": 1, "name": "Tim the Beaver", "school": { "name": "Massachusetts Institute of Technology" }, "enrolled": true, "classes": ["6.001", "18.01", "8.01"] } ``` -------------------------------- ### balanced-match API Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/balanced-match/README.md Illustrates the output format of the `balanced` function, showing the start, end, pre, body, and post properties of a match object. ```bash $ node example.js { start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } { start: 3, end: 9, pre: 'pre', body: 'first', post: 'between{second}post' } { start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' } ``` -------------------------------- ### Install ws Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/engine.io/node_modules/ws/README.md Install the ws library using npm. ```bash npm install ws ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/cors/CONTRIBUTING.md Run these commands to install project dependencies and execute the test suite. ```bash $ npm install $ npm test ``` -------------------------------- ### App Inventor Blocks for Successful Web API Get Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/markdown/reference/other/json-web-apis.md This example shows App Inventor blocks to make a GET request to a web API, parse the JSON response, and display the 'title' and 'body' in labels. It assumes a successful response with a 200 status code. ```App Inventor Blocks when Button1.Click do set Web1.Url to "https://jsonplaceholder.typicode.com/posts/1" call Web1.Get when Web1.GotText parameter responseCode parameter responseContent do if responseCode = 200 then set Label1.Text to Web.JsonTextDecodeWithDictionaries(responseContent).title set Label2.Text to Web.JsonTextDecodeWithDictionaries(responseContent).body else set Label1.Text to "Error" set Label2.Text to "Request failed: " .. responseCode ``` -------------------------------- ### Get Value at Key Path Example 2 Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/html/reference/blocks/dictionaries.html Illustrates retrieving an element from a list nested within a dictionary using a key path that includes an index. ```App Inventor Blocks get value at key path key path: ["classes", 2] dictionary: { "id": 1, "name": "Tim the Beaver", "school": { "name": "Massachusetts Institute of Technology" }, "enrolled": true, "classes": ["6.001", "18.01", "8.01"] } ``` -------------------------------- ### Install ee-first Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/ee-first/README.md Install the ee-first module using npm. ```sh $ npm install ee-first ``` -------------------------------- ### Install on-finished Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/finalhandler/node_modules/on-finished/README.md Install the on-finished module using npm. ```sh $ npm install on-finished ``` -------------------------------- ### Run App Inventor Emulator Command Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/docs/html/reference/other/emulator.html This command is used to start the App Inventor emulator from the command line. Ensure you are in the 'commands-for-appinventor' directory within your App Inventor Extras installation. ```bash run-emulator ``` -------------------------------- ### Chai Assertion Examples in Karma Tests Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma-chai/README.md Demonstrates how to use Chai's 'assert', 'expect', and 'should' assertion styles within Karma tests. Ensure Chai is configured in your Karma setup. ```coffee describe 'karma tests with chai', -> it 'should expose the Chai assert method', -> assert.ok('everything', 'everything is ok'); it 'should expose the Chai expect method', -> expect('foo').to.not.equal 'bar' it 'should expose the Chai should property', -> 1.should.not.equal 2 should.exist 123 ``` -------------------------------- ### app.listen([...]) Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/connect/README.md Starts the Connect application, internally creating a Node.js HTTP server and listening for incoming requests. ```APIDOC ## app.listen([...]) ### Description Initiates the Connect application to listen for incoming HTTP requests. This method internally sets up a Node.js HTTP server and calls its `listen()` method. Refer to the Node.js documentation for specific signature variations. ### Example ```javascript // Listen on the default port (80) app.listen() // Listen on a specific port app.listen(3000) ``` ### See Also - [Node.js http.Server.listen() documentation](https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_server_listen_port_hostname_backlog_callback) ``` -------------------------------- ### Async Usage Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/escalade/readme.md Demonstrates how to use the asynchronous version of escalade to find a 'package.json' file starting from a given input path. The callback logs the current directory and names, and returns the target filename when found. ```javascript //~> demo.js import { join } from 'path'; import escalade from 'escalade'; const input = join(__dirname, 'demo.js'); // or: const input = __dirname; const pkg = await escalade(input, (dir, names) => { console.log('~> dir:', dir); console.log('~> names:', names); console.log('---'); if (names.includes('package.json')) { // will be resolved into absolute return 'package.json'; } }); //~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar //~> names: ['demo.js'] //--- //~> dir: /Users/lukeed/oss/escalade/test/fixtures //~> names: ['index.js', 'foobar'] //--- //~> dir: /Users/lukeed/oss/escalade/test //~> names: ['fixtures'] //--- //~> dir: /Users/lukeed/oss/escalade //~> names: ['package.json', 'test'] //--- console.log(pkg); //=> /Users/lukeed/oss/escalade/package.json // Now search for "missing123.txt" // (Assume it doesn't exist anywhere!) const missing = await escalade(input, (dir, names) => { console.log('~> dir:', dir); return names.includes('missing123.txt') && 'missing123.txt'; }); //~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar //~> dir: /Users/lukeed/oss/escalade/test/fixtures //~> dir: /Users/lukeed/oss/escalade/test //~> dir: /Users/lukeed/oss/escalade //~> dir: /Users/lukeed/oss //~> dir: /Users/lukeed //~> dir: /Users //~> dir: / console.log(missing); //=> undefined ``` -------------------------------- ### Install find-up Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/find-up/readme.md Install the find-up module using npm. ```bash $ npm install find-up ``` -------------------------------- ### iOS 'Hello World' HTTP Server Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/Pods/GCDWebServer/README.md An iOS application delegate example that initializes and starts a basic HTTP server on port 8080. It serves a 'Hello World' HTML page. Requires GCDWebServer to be linked. ```objectivec #import "GCDWebServer.h" #import "GCDWebServerDataResponse.h" @interface AppDelegate : NSObjectHello World
"]; }]; // Start server on port 8080 [_webServer startWithPort:8080 bonjourName:nil]; NSLog(@"Visit %@ in your web browser", _webServer.serverURL); return YES; } @end ``` -------------------------------- ### Installing brace-expansion with npm Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/brace-expansion/README.md Instructions for installing the brace-expansion package using npm. ```bash npm install brace-expansion ``` -------------------------------- ### Run App Inventor Main Server Source: https://github.com/mit-cml/appinventor-sources/blob/master/README.md Starts the main App Inventor server, which handles project information. Ensure you replace 'your-google-cloud-SDK-folder' with the actual path to your Google Cloud SDK. ```bash your-google-cloud-SDK-folder/bin/java_dev_appserver.sh --port=8888 --address=0.0.0.0 appengine/build/war/ ``` -------------------------------- ### Install Dependencies for Development Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/engine.io-parser/Readme.md Commands to navigate into the cloned repository and install development dependencies. ```shell cd engine.io-parser npm ci ``` -------------------------------- ### Create a Connect App Instance Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/connect/README.md Initializes a new Connect application instance. ```javascript var app = connect(); ``` -------------------------------- ### Install ideviceinstaller Source: https://github.com/mit-cml/appinventor-sources/blob/master/README.ios.md Installs the ideviceinstaller and libimobiledevice tools for companion app installation on iOS devices. Ensure you have Homebrew installed. ```shell brew uninstall ideviceinstaller brew uninstall libimobiledevice brew install --HEAD libimobiledevice brew link --overwrite libimobiledevice brew install --HEAD ideviceinstaller brew link --overwrite ideviceinstaller sudo chmod -R 777 /var/db/lockdown/ ``` -------------------------------- ### Start App Inventor Server Source: https://github.com/mit-cml/appinventor-sources/blob/master/README.md Launch the App Inventor application server. Press Ctrl+C to quit. ```bash start_appinventor ``` -------------------------------- ### Install encodeurl with npm Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/encodeurl/README.md Install the encodeurl module using the npm install command. ```sh npm install encodeurl ``` -------------------------------- ### CLI Usage Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/which/README.md Illustrates the command-line interface for the 'node-which' binary, similar to the BSD 'which(1)' utility. ```bash usage: node-which [-as] program ... ``` -------------------------------- ### Asynchronous Directory Creation Example Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/mkdirp/readme.markdown Demonstrates how to recursively create a directory structure asynchronously. The callback function is invoked upon completion or if an error occurs. ```javascript var mkdirp = require('mkdirp'); mkdirp('/tmp/foo/bar/baz', function (err) { if (err) console.error(err) else console.log('pow!') }); ``` -------------------------------- ### Install depd Module Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/depd/Readme.md Install the depd module using npm. This command downloads and installs the package into your project's node_modules directory. ```sh $ npm install depd ``` -------------------------------- ### Install decamelize with npm Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/decamelize/readme.md Install the decamelize package using npm. This command downloads and installs the package into your project's node_modules directory. ```bash $ npm install --save decamelize ``` -------------------------------- ### Usage Example: Find Existing File Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/p-locate/readme.md Demonstrates how to use p-locate with path-exists to find the first file that exists on disk from a list. This example shows a common use case for finding a resource asynchronously. ```javascript const pathExists = require('path-exists'); const pLocate = require('p-locate'); const files = [ 'unicorn.png', 'rainbow.png', // Only this one actually exists on disk 'pony.png' ]; (async () => { const foundPath = await pLocate(files, file => pathExists(file)); console.log(foundPath); //=> 'rainbow' })(); ``` -------------------------------- ### Basic Chokidar Watcher Initialization and Event Handling Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/node_modules/chokidar/README.md Demonstrates how to initialize a Chokidar watcher for multiple file types and set up event listeners for file additions, changes, and removals. Also shows how to handle directory events and watcher errors. ```javascript const watcher = chokidar.watch('file, dir, glob, or array', { ignored: /(^|[\]{2})./, // ignore dotfiles persistent: true }); const log = console.log.bind(console); watcher .on('add', path => log(`File ${path} has been added`)) .on('change', path => log(`File ${path} has been changed`)) .on('unlink', path => log(`File ${path} has been removed`)); watcher .on('addDir', path => log(`Directory ${path} has been added`)) .on('unlinkDir', path => log(`Directory ${path} has been removed`)) .on('error', error => log(`Watcher error: ${error}`)) .on('ready', () => log('Initial scan complete. Ready for changes')) .on('raw', (event, path, details) => { // internal log('Raw event info:', event, path, details); }); watcher.on('change', (path, stats) => { if (stats) console.log(`File ${path} changed size to ${stats.size}`); }); ``` -------------------------------- ### Install yargs-parser Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/node_modules/yargs-parser/README.md Install yargs-parser using npm. ```sh npm i yargs-parser --save ``` -------------------------------- ### Perform simple action Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/finalhandler/README.md Example of an HTTP server that reads and serves an index.html file using finalhandler. ```javascript var finalhandler = require('finalhandler') var fs = require('fs') var http = require('http') var server = http.createServer(function (req, res) { var done = finalhandler(req, res) fs.readFile('index.html', function (err, buf) { if (err) return done(err) res.setHeader('Content-Type', 'text/html') res.end(buf) }) }) server.listen(3000) ``` -------------------------------- ### Install readdirp Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/karma/node_modules/readdirp/README.md Install readdirp using npm. ```sh npm install readdirp ``` -------------------------------- ### Install Development Dependencies and Run Benchmarks Source: https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/node_modules/braces/README.md Command to install development dependencies and run benchmark tests for the braces library. ```bash npm i -d && npm benchmark ```