Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

backOpen Source→Examples

All program examples

all-named-html-entities →

  • Quick Take
  • allNamedEntities
  • Decode a named HTML entity
  • entEndsWith
  • Find entity names by a case-insensitive suffix
  • entStartsWith
  • entStartsWithCaseInsensitive
  • Inspect entity-name metadata
  • Test whether a name is a known entity

array-group-str-omit-num-char →

  • Quick Take
  • Use a custom wildcard in grouped patterns
  • Count duplicate strings instead of deduplicating them
  • Preserve numeric chunks that stay constant across a group
  • Keep strings that contain no numeric chunks

array-includes-with-glob →

  • Quick Take
  • opts.arrayVsArrayAllMustBeFound
  • Match glob patterns without matching letter case
  • Handle a glob that matches no array items
  • Match a glob against a single string

array-pull-all-with-glob →

  • Quick Take
  • Match removal patterns without regard to letter case
  • Remove values that match any of several patterns
  • Remove every value with the catch-all glob
  • Pass one removal pattern as a string

arrayiffy-if-string →

  • Quick Take
  • Turn an empty string into an empty array
  • Pass non-string values through untouched

ast-compare →

  • Quick Take
  • Compare Arrays
  • Compare Plain Objects
  • Compare Strings
  • opts.arrayOrder
  • opts.hungryForWhitespace
  • opts.matchStrictly
  • opts.useWildcards
  • opts.verboseWhenMismatches
  • Match each unordered array element only once
  • Compare nested arrays without regard to order
  • Match object keys using wildcards

ast-contains-only-empty-space →

  • Quick Take
  • Non-object values
  • Non-plain objects
  • Various

ast-deep-contains →

  • Quick Take
  • Receive container values as well as leaf values
  • Handle a path that is absent from the reference tree
  • Compare array elements at their exact positions
  • Handle inputs with different container types
  • Match arrays of objects regardless of their order

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.hungryForWhitespace
  • opts.matchKeysStrictly
  • Delete an object that contains additional keys

ast-get-object →

  • Quick Take
  • Find every matching object in a nested AST
  • Match an object by a nested value
  • Replace a match with an object that omits an unwanted property
  • Replace matching objects in traversal order

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 amount with zero, but only under orders
  • 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 →

  • Quick Take
  • Recognise a tree made only from empty strings and containers
  • Return null when the tree contains an unsupported value type
  • Treat whitespace-only strings as content

ast-loose-compare →

  • Quick Take
  • Treat structurally different empty values as equivalent
  • More Examples
  • Compare objects nested inside arrays as subsets
  • Empty Values

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 key instead of val
  • Traverse a tree using the re-exported traverse

ast-monkey-traverse →

  • Quick Take
  • Collect the path of every visited node
  • Compatible With object-path
  • Delete nodes by returning NaN
  • Traverse without mutating the input
  • Inspect each node's parent metadata
  • Stop
  • Transform values while traversing

ast-monkey-traverse-with-lookahead →

  • Quick Take
  • Look ahead by zero nodes by default
  • Inspect a node's metadata and its lookahead
  • Look ahead two nodes at a time
  • Signal a stop from the traversal callback

ast-monkey-util →

  • Quick Take
  • Find the parent segment
  • Move to the next sibling path
  • Move to the previous sibling path
  • Move up one AST level

charcode-is-valid-xml-name-character →

  • Quick Take
  • Allow a combining mark after the first character
  • Check characters against the XML NameChar production
  • Check characters against the XML NameStartChar production
  • Validate a character after the first character in an XML name
  • Validate a whole XML name

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 →

  • Quick Take
  • Preserve CSS references and selectors
  • Nested arrays and objects
  • Pass through unsupported input values

csv-sort →

  • Quick Take
  • Check whether a CSV cell is numeric
  • Handle an empty CSV string
  • Classify CSV cells before sorting
  • Sort a bank statement that has no header row

csv-split-easy →

  • Quick Take
  • Leave single decimal place numbers unpadded
  • Unescape doubled-up double quotes
  • Keep the thousand separators in numbers
  • opts.delimiter
  • Skip blank rows
  • Convert continental number style into UK style

detect-is-it-html-or-xhtml →

  • Quick Take
  • Detect HTML from its doctype
  • Prefer HTML when self-closing and open single tags are tied
  • Return null when the source contains no decisive markup
  • Infer XHTML when most single tags are self-closing
  • Detect XHTML from its doctype

detect-templating-language →

  • Quick Take
  • Detect a Jinja inline conditional expression
  • Detect Jinja namespace syntax
  • Detect Java Server Pages using a JSP Standard Tag Library element
  • Report when no supported template language is present

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
Open detergent playground

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 →

  • Quick Take
  • Tabs and line breaks are allowed
  • Set a custom maximum line length
  • Disable the line length check
  • Report every non-ASCII character found

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 for attributes
  • 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
Open email-comb playground

extract-search-index →

  • Quick Take
  • Keep the first occurrence of each case-insensitive word
  • Strip HTML tags and decode entities
  • Normalise fancy punctuation and omit digits and emoji
  • Exclude code, preformatted text, and CSS from the index
  • Remove URLs and stop words from search-index text

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 →

  • Quick Take
  • Check email-client-specific HTML attributes
  • Inspect the number of known attributes
  • Iterate through the known attributes
  • Distinguish known attributes from application-specific ones

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
Open html-crush playground

html-entities-not-email-friendly →

  • Quick Take
  • Inspect the number of known unsafe named entities
  • Skip impossible entity-name lengths before consulting the sets
  • Check entity names case-insensitively with the lowercase set
  • Look up a safer replacement for a named entity

html-img-alt →

  • Quick Take
  • Preserve original typography in alt text
  • Repair an alt attribute that has no value
  • Normalize typography and surrounding spaces in alt text
  • Add an alt attribute while preserving XHTML closing syntax

html-table-patcher →

  • Quick Take
  • Add inline CSS to inserted table cells
  • Center every inserted table cell
  • Leave table-like markup inside an HTML comment untouched
  • Span inserted table cells across the existing columns
  • Move loose row text into its own cell and row

is-char-suitable-for-html-attr-name →

  • Quick Take
  • Only the first character is checked
  • Characters rejected in attribute names
  • Characters allowed in attribute names

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 →

  • Quick Take
  • Recognise a closing tag
  • Ignore a less-than sign used for comparison
  • opts.allowCustomTagNames
  • opts.skipOpeningBracket
  • Recognise a self-closing tag with attributes

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
Open is-language-code playground

is-media-descriptor →

  • Quick Take
  • Report missing descriptor whitespace
  • Offset reported indexes
  • A valid media descriptor
  • Report surrounding whitespace

is-relative-uri →

  • Quick Take
  • Invalid URI characters
  • URI scheme detection
  • A valid relative URI

js-row-num →

  • Quick Take
  • Custom logging trigger
  • Process already-extracted log contents
  • Override every detected row number
  • Custom line-number padding
  • Inspect the replacement ranges

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 null value 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 →

  • Quick Take
  • Fix SourceHut commit links
  • Preserve CRLF line endings
  • Remove WIP entries and tidy the headings

object-all-values-equal-to →

  • Quick Take
  • Arrays containing the placeholder itself
  • Empty containers
  • Return false when one value differs from the reference
  • Check the values in nested objects and arrays

object-boolean-combinations →

  • Quick Take
  • Generate the one possible combination for an empty key set
  • Hold selected keys constant while varying the others

object-delete-key →

  • Quick Take
  • Deletion by the key only
  • Deletion by the value only
  • Disable the cleanup which would otherwise happen after deletion
  • Delete only when both the key and value match
  • Delete matching object keys without deleting matching array values
  • Wildcards

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 →

  • Quick Take
  • Empty arrays that contain any string value
  • Merge objects in arrays at every nesting level
  • Return a flattened clone without changing the input

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 →

  • Quick Take
  • Compare each input array item with the reference item at the same index
  • Compare every input array item with the first reference item
  • Report each array position when the reference is not an array

object-set-all-values-to →

  • Quick Take
  • Array primitives stay unchanged
  • Set every value to a custom replacement
  • Set every value to undefined
  • Set the values within nested objects and arrays
  • Each replacement container is a separate object

ranges-apply →

  • Quick Take
  • Delete a range by omitting its replacement value
  • Insert text with a zero-width range
  • Apply ranges whose indexes arrive as numeric strings
  • Gather progress while applying multiple ranges

ranges-crop →

  • Quick Take
  • Crop a range that carries a replacement
  • Discard the ranges beyond the string's end
  • Keep an insertion at the string's end
  • Merge and sort the ranges before cropping
  • No ranges to crop

ranges-ent-decode →

  • Quick Take
  • Avoid decoding an ambiguous entity inside an attribute value
  • Return null when no replacement ranges are needed
  • Decode decimal and hexadecimal character references
  • Decode entities that were encoded more than once
  • Reject a malformed entity in strict mode

ranges-invert →

  • Quick Take
  • Merge overlapping ranges before inverting
  • Invert an absent ranges collection
  • Skip validation for already sorted ranges
  • Require two-element ranges

ranges-is-index-within →

  • Quick Take
  • Include both range endpoints in the match
  • Return false when an index is outside every range
  • Return the matched range instead of true

ranges-iterate →

  • Quick Take
  • Skip characters covered by a deletion range
  • Iterate text inserted at the end of a string
  • Iterate the result of multiple replacements
  • Iterate the original string when there are no ranges
  • Start iteration at an existing output offset

ranges-merge →

  • Quick Take
  • Keep the touching ranges separate
  • Merge two overlapping ranges
  • Prefer the latter value with merge type two
  • A null replacement wins over text
  • Remove the ranges that do nothing
  • Report the merging progress

ranges-process-outside →

  • Quick Take
  • Process the whole string when no ranges are supplied
  • Skip range validation in a prevalidated pipeline
  • Skip ahead from inside the callback
  • Process Unicode code points without splitting surrogate pairs

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 →

  • Quick Take
  • Preserve empty range collections
  • Observe sorting progress
  • Require two-element ranges

regex-empty-conditional-comments →

  • Quick Take
  • Extract the first empty conditional comment
  • Find all empty conditional comments
  • Ignore conditional comments that contain markup
  • Collect empty conditional comments but skip populated ones
  • Match the revealed form of an empty conditional comment
  • Remove empty conditional comments

regex-is-jinja-nunjucks →

  • Quick Take
  • Recognise Jinja and Nunjucks delimiter styles
  • Reject HTML without Jinja or Nunjucks delimiters

regex-is-jsp →

  • Quick Take
  • Detect a JSP page directive
  • Detect a JSP action tag
  • Detect an expression that refers to a JSP property
  • Reject HTML without JSP syntax
  • Detect a JSP Standard Tag Library tag

regex-jinja-specific →

  • Quick Take
  • Detect Jinja's inline conditional ordering
  • Detect Jinja namespace assignment syntax
  • Detect Jinja's Python-style number formatting filter

rehype-responsive-tables →

  • Quick Take
  • Find exact text in a HAST tree
  • Customise every generated class name
  • Lift every labelled column with a wildcard
  • Renders markdown tables
  • Find a numbered child element by tag name

remark-conventional-commit-changelog-timeline →

  • Quick Take
  • Arabic dates
  • Convert a linked release heading into timeline markup
  • Add the conventional emoji for each recognised change section

remark-typography →

  • Quick Take
  • Convert a three-dot ellipsis
  • Fix apostrophes following inline code nodes
  • Convert a multiplication marker
  • Convert straight quotes and apostrophes
  • Keep the last two words together
  • Convert a spaced dash

str-indexes-of-plus →

  • Quick Take
  • Search for an empty string
  • Report overlapping matches
  • Start searching from a given index
  • Emoji count as single characters

string-apostrophes →

  • Quick Take
  • Convert one apostrophe into an entity
  • Supply the apostrophe value separately
  • Disable the apostrophe conversion
  • Convert double quotation marks
  • Convert the quotes into HTML entities
  • Convert measurement primes
  • Convert nested quotations
  • Report the index offsets through a callback

string-character-is-astral-surrogate →

  • Quick Take
  • Treat a missing code unit as not being a surrogate
  • Inspect the first UTF-16 code unit of an astral character

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 →

  • Quick Take
  • An ambiguous hyphen is left alone
  • Convert one em dash into an entity
  • Disable the dash conversion
  • Convert a letter range into an en dash
  • Convert a number range into an en dash
  • Convert a maths minus into an en dash
  • Report the index offsets through a callback
  • Supply the dash value separately

string-extract-class-names →

  • Quick Take
  • Supports legacy bracket notation emails used to use
  • Non-parsing algorithm can tackle really dodgy CSS
  • Decode CSS selector escapes
  • Extract raw escaped selectors
  • Read one selector token at an exact index
  • Inspect the source ranges of extracted selectors
  • Processes whole CSS selectors

string-extract-sass-vars →

  • Quick Take
  • Ignore variables inside both Sass comment styles
  • Convert number-only Sass values to JavaScript numbers
  • Convert 3-digit color hex codes to 6-digit
  • Keep semicolons that occur inside a quoted value
  • Raises alarm if variables file has been wiped

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 →

  • Quick Take
  • Offset the reported indexes
  • An exact match is not reported
  • Widen the allowed edit distance
  • Ignore the whitespace between characters
  • Require the characters to be adjacent

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 →

  • Quick Take
  • Process a bounded slice and offset reported indexes
  • Gather chunks without requesting diagnostics
  • Use a custom separator
  • Allow leading and trailing whitespace
  • Configure whitespace inside a chunk
  • Allow one space after a comma

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 →

  • Quick Take
  • Remove a duplicate outer layer with the default markers
  • Remove mixed outer wrappers while preserving inner variables
  • Remove empty marker pairs around meaningful text
  • Leave content intact unless both outer markers match

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 →

  • Quick Take
  • Exclude a template variable range from the returned words
  • Split on line breaks, tabs, and repeated spaces

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 td tags
  • Leave only td tags
  • 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 title package
  • Trim ordinary spaces while preserving tabs and line breaks
  • Orphan removal from text within HTML
  • Wrap a retained link destination with custom markers
Open string-strip-html playground

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

string-uglify →

  • Quick Take
  • Preserve mappings for duplicate names
  • Preserve an empty names array
  • Uglify names without class or ID prefixes
  • Keep existing short names reserved
  • Uglify one name by its array index

string-unfancy →

  • Quick Take
  • Normalise common typographic characters
  • Normalise an HTML-encoded typographic character
  • Convert non-breaking spaces
  • Decode repeatedly encoded HTML

test-mixer →

  • Quick Take
  • Clone nested values in generated variations
  • No defaults means no variations
  • Carry non-boolean values into every variation
  • Pin one option while varying the others

tsd-extract →

  • Quick Take
  • Extract a nested member
  • Extracting function type definitions
  • Join two object types into one
  • List all declarations in the source
  • Report a declaration that was not found
  • Omit the trailing semicolon
  • Require a statement to contain a string
  • Sorting exports
  • Strip the as aliases from an export

util-array-object-or-both →

  • Quick Take
  • Normalise the accepted array aliases
  • Customise the thrown error's context
  • Normalise aliases that allow either arrays or objects
  • Case and surrounding whitespace are normalised
  • Normalise the accepted object aliases

util-nonempty →

  • Quick Take
  • Check whether an array contains a value
  • Treat a deeply nested array as non-empty
  • Treat every number, including zero and NaN, as non-empty
  • Check whether an object contains a property
  • Treat nullish and Boolean values as empty

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab