All program examples
all-named-html-entities →
array-group-str-omit-num-char →
array-includes-with-glob →
array-pull-all-with-glob →
arrayiffy-if-string →
ast-compare →
ast-contains-only-empty-space →
ast-deep-contains →
ast-delete-object →
- Quick Take
- Delete empty objects throughout a tree
- Delete every object that contains the requested pair
- Delete a matching object nested under another object
- Delete the root object when it contains the requested key-value pairs
- Keep whitespace-only objects when hungry matching is disabled
opts.hungryForWhitespaceopts.matchKeysStrictly- Delete an object that contains additional keys
ast-get-object →
ast-get-values-by-key →
- Quick Take
- Match keys case-sensitively
- Fetch the values of several keys at once
- Replace all null's in keys
amountwith zero, but only underorders - Replace each match with the next value in the array
- A single replacement value is used only once
- Set the values of keys matched by a wildcard
- Using wildcard patterns
ast-is-empty →
ast-loose-compare →
ast-monkey →
- Quick Take
- Delete matches from arrays only
- Delete every object key of a given name
- Delete nodes by value
- Drop a node by its traversal index
- Find nodes matching both a key and a value
- Find nodes by value alone
- Search array elements only
- Search object properties only
- Get a node by its traversal index
- Keep only the first element of every array
- Set a node's value by its traversal index
- Set a node using
keyinstead ofval - Traverse a tree using the re-exported
traverse
ast-monkey-traverse →
ast-monkey-traverse-with-lookahead →
ast-monkey-util →
charcode-is-valid-xml-name-character →
check-types-mini →
- Quick Take
- Exclude selected paths from array acceptance
- Accept arrays of the reference value's type
- Allow any shape below a schema path
- Customise validation error context
- Ignore a key wherever it occurs
- Ignore only selected nested paths
- Use a nested schema object
- Allow missing and additional keys
- Allow multiple types through a schema
- Validate an options object against defaults
codsen-glob →
- Quick Take
- Abort an asynchronous search
- Return absolute paths
- Brace expansion and extglobs
- Match without case sensitivity
- Configure directory expansion
- Return directories
- Disable symbolic-link traversal
- Include hidden entries
- Veto matches with ignore patterns
- Combine multiple patterns
- Exclude matches with a negative pattern
- Synchronous globbing
- Use a file URL as the working directory
codsen-utils →
- Quick Take
- Classify individual characters
- Parse typed, short and repeatable CLI flags
- Assemble CLI help text
- Deeply clone a cyclic object graph
- Detect and resolve line endings
- Test whether a value exists
- Find overlapping substring occurrences
- Match a string against literal and regular-expression choices
- Intersect arrays in the first array's order
- Reject a character that is not a digit
- Omit keys and clone retained values
- Check own properties safely
- Distinguish plain objects from other object values
- Remove selected array values without mutating the input
- Remove one trailing slash
- Sort strings with the shared comparator
- Replace part of a string
- Reuse shared text symbols and HTML tag sets
- Check common JavaScript value types
- Deduplicate values while preserving order
- Match wildcard allow-lists and deny-lists
color-shorthand-hex-to-six-digit →
csv-sort →
csv-split-easy →
detect-is-it-html-or-xhtml →
detect-templating-language →
detergent →
- Quick Take
- Insert a line break where a selected HTML tag is stripped
- Add missing spaces after sentence punctuation
- Discover which cleanup rules apply to an input
- Transform text outside HTML tags with a callback
- Normalise typographic apostrophes
- Normalise a dash according to the conversion setting
- Convert three dots to an ellipsis entity
- Choose whether to encode HTML entities
- Inspect the exported default options
- Set the end-of-line sequence inserted after HTML break tags
- Fix misspelled named HTML entities
- Choose HTML or XHTML break-tag syntax
- Keep selected tags while stripping the rest
- Preserve or encode non-Latin characters
- Collapse line breaks to spaces
- Keep the last two words together
- Replace line breaks with HTML break tags
- Choose whether to strip HTML tags
edit-package-json →
- Quick Take
- Delete an array item by its dot-path index
- Delete a nested object key
- Minimal example,
del() - Minimal example,
set() - Replace an existing array item by its dot-path index
- Replace an existing nested value with null
- Set a numeric value without changing surrounding formatting
- Replace an object value while preserving outer formatting
email-all-chars-within-ascii →
email-comb →
- Quick Take
- Keep classes inside backend template markers
- Keep HTML comments containing a given string
- Keep CSS comments
- Keep HTML comments
- Keep id's referenced by
forattributes - Minifies and uglifies
- Report progress within a custom range
- Remove media queries left empty
- Returns all extracted and deleted classes and id's
- Works even if
<style>is within<body>and there's no<head> - Whitelist a selector from removal
- Whitelist using wildcards
extract-search-index →
generate-atomic-css →
- Quick Take
- Generate from a separate configuration string
- Wrap generated content in marker comments
- Extract a configured generation range
- Retain the generator configuration
- Access canonical marker names
- Leave CSS without generator placeholders unchanged
- Align generated declarations
- Observe generation progress in a custom interval
html-all-known-attributes →
html-crush →
- Quick Take
- Configure CSS comment removal
- Insert line breaks before selected tokens
- Treat a custom element as inline
- Choose which HTML comments to remove
- Wrap minified HTML at a line-length limit
- Observe progress in a custom interval
- Remove line indentations
- Remove HTML line breaks
- Inspect result metadata and edit ranges
html-entities-not-email-friendly →
html-img-alt →
html-table-patcher →
is-char-suitable-for-html-attr-name →
is-html-attribute-closing →
- Quick Take
- Broken #1
- Broken #2
- Broken #3
- Return false for unusable source indexes
- Recover when spaces replace attribute equals signs
- Recover when an attribute value has no opening quote
- Distinguish quotes inside a value from its closing quote
- Detect the end of a single-quoted attribute value
- Ignore quotes that belong to templating code inside a value
is-html-tag-opening →
is-language-code →
- Quick Take
- Match registered tags without regard to letter case
- Explain a language tag containing two region subtags
- Explain an extended language subtag with the wrong prefix
- Validate an extended language subtag after its registered prefix
- Validate multiple uniquely prefixed extensions
- Accept an IANA-grandfathered language tag
- Reject text that does not resemble a language tag
- Validate a private-use language tag
- Explain why a repeated variant is invalid
- Validate language, script, region, and variant subtags together
- Explain an extension singleton without extension content
- Various examples
is-media-descriptor →
js-row-num →
json-comb-core →
- Quick Take
- Compute a keyset from promises with a custom placeholder
- Enforce a keyset asynchronously, with options
- Mark comment keys with a custom suffix
- Enforce a keyset using a custom placeholder
- Compute a keyset using a custom placeholder
- Find unused keys marked by a custom placeholder
- Leave the chosen placeholder paths unexpanded
- Enforce a keyset computed from many objects
- Asynchronous
enforceKeyset() - Synchronous
enforceKeysetSync() - Expand a
nullvalue into the schema - Synchronous
findUnusedSync()- example #2 - Synchronous
findUnusedSync()- example #1 - Asynchronous
getKeyset() - Synchronous
getKeysetSync() - Synchronous
noNewKeysSync()- example #2 - Synchronous
noNewKeysSync()- example #1 - Sort object keys in semver order
- Synchronous
getKeysetSync()
json-variables →
- Quick Take
- Allow a resolved value to be wrapped twice
- Allow variables that cannot be resolved
- Control how booleans resolve
- Use a custom data container suffix
- Use custom variable markers
- Configure markers that resolve variables without output wrapping
- Resolve variables from a data container
- Switch off all wrapping
- Ignore data containers
- Leave the selected variables unwrapped
- Skip wrapping using alternative markers
- Reject a number inserted into a string
- Reject values containing a lone marker
- Resolve booleans to empty text
- Replace unresolved variables with a fallback
- A whole number keeps its type
- Wrap the resolved values
lerna-clean-changelogs →
object-all-values-equal-to →
object-boolean-combinations →
object-delete-key →
object-fill-missing-keys →
- Quick Take
- Clone a schema array when the input array is empty
- Use true as the placeholder at paths that must remain unfilled
- An option to not fill the paths if they contain placeholders
- Fill missing keys in every existing array item
- Fill null values when null is not an explicit opt-out
- Truncation upon request, to minimize the object footprint
opts.useNullAsExplicitFalse- Using placeholder to cause the value population
object-flatten-all-arrays →
object-flatten-referencing →
- Quick Take
- Wrap an already wrapped value when prevention is disabled
- Insert a break even when the previous line already contains one
- Normalise a string setting to an array
- Avoid adding a break after a line that already ends with one
- Wrap flattened string values with custom markers
- Inspect the exported flattening defaults
- Disable wrapping across the complete input tree
- Skip wrapping for keys that match a glob
- Skip wrapping only at an exact nested path
- Flatten an array with line breaks between rows
- Flatten an object's keys and values to strings
- Use HTML rather than XHTML line-break syntax
- Leave an ignored key and its nested value unchanged
- Merge array rows without inserting line breaks
- Flatten input keys even when the reference has no matching key
- Leave an unmatched input key unchanged
- Throw when an input key is absent from the reference
- Set the separator used by flattenObject
- Keep values that already contain the wrapping markers
- Leave templating statements unwrapped
object-merge-advanced →
- Quick Take
- Override a merge result in the callback
- Deduplicate and sort merged string arrays
- Clear an array merge when either array contains strings
- Concatenate every clashing pair of arrays
- Concatenate arrays on a selected key
- Prefer incoming values for every clash
- Take the incoming value for a selected clashing key
- Keep existing values for every clash
- Merge array values and omit duplicates instead of concatenating positions
- Merge Boolean clashes with AND instead of the default OR
- Merge positioned array objects even when their key sets differ
- Let null explicitly override another value
- Apply one array object to every object in the other array
object-no-new-keys →
object-set-all-values-to →
ranges-apply →
ranges-crop →
ranges-ent-decode →
ranges-invert →
ranges-is-index-within →
ranges-iterate →
ranges-merge →
ranges-process-outside →
ranges-push →
- Quick Take
- Add a complete array of ranges in one call
- Read the most recently gathered range
- Collapse replacement whitespace to one character
- Retain at most two line breaks in replacement whitespace
- Concatenate replacement values when same-start ranges merge
- Keep the later replacement value when same-start ranges merge
- Replace all previously gathered ranges
- Accept the string form of merge type one
- Accept the string form of merge type two
- Clear every gathered range
ranges-regex →
- Quick Take
- Clashing replacement values
- Give deletion precedence with a null replacement
- Require the global flag so every match can be collected safely
- Slice the source text using the returned ranges
- Merge adjacent regex matches into one range
- Nothing was found
- Replacing values
- Advance over a complete Unicode code point after an empty match
- Turn zero-width matches into insertion ranges
ranges-sort →
regex-empty-conditional-comments →
regex-is-jinja-nunjucks →
regex-is-jsp →
regex-jinja-specific →
rehype-responsive-tables →
remark-conventional-commit-changelog-timeline →
remark-typography →
str-indexes-of-plus →
string-apostrophes →
string-character-is-astral-surrogate →
string-collapse-leading-whitespace →
- Quick Take
- Collapse boundary whitespace containing line breaks
- Preserve CRLF line endings
- Keep a chosen number of leading and trailing line breaks
- Preserve non-breaking-space boundaries
- Pass through non-string input
- Leave whitespace inside a multiline string unchanged
- Preserve a string that has no boundary whitespace
- Collapse strings containing only whitespace
string-collapse-white-space →
- Quick Take
- Minify a chunk of CSS selector
- Collapse a run containing tabs
- Replace tabs inside whitespace runs with ordinary spaces
- Keep at most one consecutive empty line
- Collapse but preserve one leading space
- Preserve one space around each line's content
- Collapse but preserve one trailing space
- Remove empty lines from multiline text
- Inspect the ranges used to produce the collapsed result
- Trim whitespace from the start and end of every line
- Trim multiline content whose boundaries contain non-breaking spaces
- Trim raw non-breaking spaces with ordinary whitespace
string-convert-indexes →
- Quick Take
- Convert the indexes within a plain object
- Convert an array of native indexes
- Convert a single native index
- Convert the indexes within a nested structure
- Throw on an out-of-range Unicode index
- Convert the indexes there and back
- Convert Unicode indexes into native ones
- Index a zero-width-joiner emoji sequence
string-dashes →
string-extract-class-names →
string-extract-sass-vars →
string-find-heads-tails →
- Quick Take
- Prefix validation errors with the calling library's name
- Reject an input made only from one opening marker
- Start looking for marker pairs at a selected index
- Return an empty result for unusable marker inputs
- Require each opening marker to use the tail at the same array index
- Return completed pairs without throwing on an unmatched marker
string-find-malformed →
string-fix-broken-named-entities →
- Quick Take
- Apply the returned ranges to repair the source string
- Report healthy named-entity ranges
- Decode healthy named entities
- Decode decimal and hexadecimal numeric entities
- Map findings into custom callback results
- Repair repeatedly encoded entities
- Observe scan progress
- Access the complete public rule-name list
- Sift raw ampersands in a string from broken character references
string-left-right →
- Quick Take
- Match a character sequence without regard to letter case
- Match repeated sequences on the left and include nearby whitespace
- Control how chomp functions include surrounding whitespace
- Match repeated sequences on the right and include nearby whitespace
- Match a whitespace-tolerant character sequence on the left
- Combine optional and repeated sequence flags
- Mark one sequence value as optional with a question mark
- Match one or more repeated sequence values with an asterisk
- Match a whitespace-tolerant character sequence on the right
- Find the nearest non-whitespace character on the right
- Treat a newline as a stopping point in either direction
- Treat a raw non-breaking space as a stopping point
string-match-left-right →
- Quick Take
- Inspect the character and remainder after a match
- Let a callback veto an otherwise successful match
- Match without letter-case sensitivity
- The Callback Use
- Advance to the next string index
- Match the start or end of a string
- Include the indexed character in a left-side match
- Match a value immediately to the left of an index
- Include the indexed character in a right-side match
- Require boundary characters and choose hungry matching
- Tolerate a missing character
- Skip selected characters before matching
- Skip whitespace before matching
string-process-comma-separated →
string-range-expander →
- Quick Take
- Include configured left-side marker characters in the range
- Include a configured right-side marker in the range
- Expand whitespace only on the left side
- Expand whitespace only on the right side
- Request one replacement space when deletion would join words
- Crop tightly when a configured marker appears on the left
- Include all adjacent whitespace on the left
- Include all adjacent whitespace on the right
string-remove-duplicate-heads-tails →
string-remove-thousand-separators →
- Quick Take
- Pad a single decimal digit while removing thousand separators
- Leave a single decimal place unpadded
- Convert a comma decimal separator to a dot
- Remove spaced thousand separators when no decimal separator is present
- Keep thousand separators while still normalising the outer quotes
- Leave a value unchanged when it contains non-numeric text
- Preserve a number whose separators are ambiguous
- Remove spaces used as thousand separators
- Remove apostrophes used as thousand separators
string-remove-widows →
- Quick Take
- Encode the inserted non-breaking space for CSS
- Ignore a custom pair of template markers
- Keep a dash with its neighbouring words when hyphen handling is enabled
- Ignore every built-in template syntax preset
- Ignore Hexo template expressions while processing surrounding text
- Ignore Hugo template expressions while processing surrounding text
- Ignore Jinja tags while processing surrounding text
- Ignore Liquid tags while processing surrounding text
- Ignore Nunjucks tags while processing surrounding text
- Encode the inserted non-breaking space for JavaScript
- Apply widow prevention only after the minimum character count is reached
- Apply widow prevention only after the minimum word count is reached
- Inspect which transformations were applied
- Map progress reports into a caller-owned percentage range
- Insert a raw non-breaking space instead of an encoded entity
- Remove an existing widow-prevention entity
- Keep both halves of a UK postcode together
- Widow word removal from text within HTML
string-split-by-whitespace →
string-strip-html →
- Quick Take
- Ignores code tags and their contents
- A bypass callback and a do-nothing callback
- Strip an entire CDATA section
- Decode HTML entities before recognising and stripping encoded tags
- Keep a link destination next to its label
- Put a retained link destination on a new paragraph
- Extract HTML
<head>contents - Strip an HTML comment and prevent adjacent text from joining
- Preserve selected tags while stripping the rest
- Strip a JSX component tag from surrounding text
- Retain href and link label
- Leave only HTML
- Leave only opening
tdtags - Leave only
tdtags - Minimal example using Ranges
- Preserve indentation while collapsing whitespace around stripped tags
- Leave JSP scriptlets intact while stripping HTML
- Preserve punctuation around removed inline tags
- Preserve literal comparison brackets in plain text
- Insert spaces when removing tags between adjacent text
- Map progress reporting into a custom percentage range
- Remove all HTML from a string
- Strip script tags but retain their text when paired-content removal is disabled
- Strip HTML from a raw JSON string
- Remove a selected tag pair together with its contents
- Preserve custom elements while stripping recognised HTML tags
- Set the title case using
titlepackage - Trim ordinary spaces while preserving tabs and line breaks
- Orphan removal from text within HTML
- Wrap a retained link destination with custom markers
string-trim-spaces-only →
- Quick Take
- Include carriage returns in the configured trim set
- Trim every JavaScript whitespace character
- Trim tabs but preserve ordinary spaces at the edges
- Include line feeds in the configured trim set
- Preserve non-space whitespace at the trimmed boundaries
- Include raw non-breaking spaces in the configured trim set
- Return an empty ranges array when the value needs no trimming
- Include tabs in the configured trim set