-
Docstring Instructions: Provide JSDoc comment blocks for all methods, properties, and types in code examples, including private ones. Ensure that the docstring comments wrap at no more than 90 columns for readability. Avoid aligning the continuation lines of parameter descriptions in docstrings.
-
Code Examples: Provide complete and detailed implementations in code examples. Include all relevant modifications and enhancements as per the discussion or request. Ensure that the code adheres to good programming practices and is well-documented.
-
General Output Guidelines: Provide detailed and comprehensive answers. Incorporate personal insights where appropriate, while adhering closely to the specifics of your query. In the context of software development, adhere to best practices in coding and documentation.
-
Documentation for Private Entries: Ensure that private properties, functions, types, and interfaces in code examples also include comprehen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NEObject = Object.assign(Object.setPrototypeOf({}, Object), { | |
/** | |
* Applies a custom tag to the string representation of an object. | |
* | |
* This method modifies the passed object by defining a custom tag that | |
* will be returned when calling `Object.prototype.toString` on the object. | |
* This is achieved by defining a getter for `Symbol.toStringTag` which returns | |
* the specified tag name. The property is set as non-enumerable and configurable. | |
* | |
* @example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A custom wrapper around the Reflect API, providing additional utility methods. | |
* It inherits all properties and methods from the Reflect object and adds custom methods. | |
*/ | |
const NEReflect = Object.assign(Object.setPrototypeOf({}, Reflect), { | |
/** | |
* Checks if all specified properties exist on the given object. | |
* | |
* @param {Object} object - The object to check for properties. | |
* @param {...string} props - One or more property names to check for existence. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const { readFile } = require('fs/promises') | |
const { format, parse } = require('path') | |
const expected = { attending: v => /true|1|yes/i.exec(v) ? true : false } | |
const { interpreter, executable, args, flags } = processArgsForFlags(process.argv, expected) | |
console.log(interpreter) | |
console.log(executable) | |
console.log(args) |
This library provides a generic Historical<T>
class for tracking and managing the history of values in JavaScript and TypeScript applications. It is designed to be versatile, supporting undo/redo operations, callback registration for value changes, and serialization/deserialization functionalities. Additionally, the library offers integration with Angular applications through a dedicated service, HistoricalService
, and an example Angular component, MyComponent
, demonstrating its practical use.
(TODO: Add installation steps here once available)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
promptUser() { | |
# Check if no parameters are supplied | |
if [[ $# -eq 0 ]]; then | |
echo "Usage: promptUser <message> [positiveWord] [negativeWord]" | |
return 1 | |
fi | |
local message=$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Type { | |
/** | |
* Creates an instance of the Type class. | |
* | |
* @param {string} typeName - The name of the type. | |
* @param {Object} format - An object representing the format for the type. | |
* @param {Function} constructor - The constructor function for the type. | |
*/ | |
constructor(typeName, format, constructor = null) { | |
this.typeName = typeName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
json() { | |
usage() { | |
echo "Usage: json [property] [file]" | |
echo " property: (optional) The property of the JSON object to retrieve." | |
echo " file: (optional) The file containing the JSON object. Defaults to 'package.json'." | |
echo "" | |
echo "Special values for property:" | |
echo " *: Retrieve the whole object." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
def modify_indentation(code): | |
new_code_lines = [] | |
for line in code.splitlines(): | |
leading_spaces = 0 | |
# Count the leading spaces in increments of 4 | |
while leading_spaces + 4 <= len(line) and line[leading_spaces:leading_spaces + 4] == ' ': |