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

backOpen Source→Examples

All program examples

Permalink to all-named-html-entitiesall-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

Permalink to array-group-str-omit-num-chararray-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

Permalink to array-includes-with-globarray-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

Permalink to array-pull-all-with-globarray-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

Permalink to arrayiffy-if-stringarrayiffy-if-string →

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

Permalink to ast-compareast-compare →

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

Permalink to ast-contains-only-empty-spaceast-contains-only-empty-space →

  • Quick Take
  • Non-object values
  • Non-plain objects
  • Report completion statistics
  • Compose progress into a caller's range
  • Various

Permalink to ast-deep-containsast-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

Permalink to ast-delete-objectast-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

Permalink to ast-get-objectast-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

Permalink to ast-get-values-by-keyast-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

Permalink to ast-is-emptyast-is-empty →

  • Quick Take
  • Terminate on cycles and reuse completed shared subtrees
  • Recognise a tree made only from empty strings and containers
  • Inspect frozen completion statistics
  • Compose progress reporting into a caller's range
  • Return null when the tree contains an unsupported value type
  • Treat whitespace-only strings as content

Permalink to ast-loose-compareast-loose-compare →

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

Permalink to ast-monkeyast-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
  • Find explicit undefined values
  • 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 value to undefined
  • Set a node using key instead of val
  • Delete during traversal with the collision-free token
  • Traverse a tree using the re-exported traverse

Permalink to ast-monkey-traverseast-monkey-traverse →

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

Permalink to ast-monkey-traverse-with-lookaheadast-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

Permalink to ast-monkey-utilast-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

Permalink to charcode-is-valid-xml-name-charactercharcode-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

Permalink to check-types-minicheck-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
  • Validate a property whose key contains a literal dot
  • Use a nested schema object
  • Compose progress and inspect completion statistics
  • Allow missing and additional keys
  • Allow multiple types through a schema
  • Validate an options object against defaults

Permalink to codsen-format-diagnostic-valuecodsen-format-diagnostic-value →

  • Quick Take

Permalink to codsen-globcodsen-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

Permalink to codsen-utilscodsen-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
  • Trim selected characters from both string edges
  • Check common JavaScript value types
  • Deduplicate values while preserving order
  • Match wildcard allow-lists and deny-lists

Permalink to color-shorthand-hex-to-six-digitcolor-shorthand-hex-to-six-digit →

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

Permalink to csv-sortcsv-sort →

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

Permalink to csv-split-easycsv-split-easy →

  • Quick Take
  • Convert decimal commas while retaining grouping separators
  • Use options created in another JavaScript realm
  • Leave single decimal place numbers unpadded
  • Unescape doubled-up double quotes
  • Keep the thousand separators in numbers
  • Preserve line breaks inside quoted fields
  • opts.delimiter
  • Pad single-digit fractions without changing longer decimal values
  • Read quoted fields after record breaks
  • Skip blank rows
  • Convert continental number style into UK style

Permalink to detect-is-it-html-or-xhtmldetect-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

Permalink to detect-templating-languagedetect-templating-language →

  • Quick Take
  • Detect Jinja namespace syntax
  • Detect Java Server Pages using a JSP Standard Tag Library element
  • Recognize JSP standard actions through a renamed XML namespace prefix
  • Report when no supported template language is present
  • Shared inline conditional syntax keeps the Nunjucks fallback
  • A complete template comment provides shared-family evidence

Permalink to detergentdetergent →

  • 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
  • Preserve CSS in retained HTML
  • 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

Permalink to edit-package-jsonedit-package-json →

  • Quick Take
  • Add a key that is not there yet, at the indentation the file already uses
  • 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

Permalink to email-all-chars-within-asciiemail-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

Permalink to email-combemail-comb →

  • Quick Take
  • Keep classes inside backend template markers
  • Keep HTML comments containing a given string
  • Match decoded HTML class values
  • CSS escapes identify the same class names as their decoded HTML values.
  • Keep CSS comments
  • Keep HTML comments
  • Keep id's referenced by for attributes
  • Minifies and uglifies
  • Preserve CSS comment boundaries
  • Unchanged short names keep the escaping required by their output context.
  • 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>
  • Uglify class and ID selectors with the convenience API
  • Whitelist a selector from removal
  • Whitelist using wildcards
Open email-comb playground

Permalink to extract-search-indexextract-search-index →

  • Quick Take
  • Keep the first occurrence of each case-insensitive word
  • Parse attribute boundaries before decoding retained text
  • Strip HTML tags and decode entities
  • Normalise fancy punctuation and omit digits and astral characters
  • Exclude code, preformatted text, and CSS from the index
  • Remove URLs and stop words from search-index text
  • Preserve BMP letters while separating words around surrogate code units

Permalink to generate-atomic-cssgenerate-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

Permalink to html-all-known-attributeshtml-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

Permalink to html-crushhtml-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
  • Preserve CSS token boundaries when removing comments
  • Preserve whitespace that terminates CSS escapes
  • Preserve encoded inline CSS
  • Observe progress in a custom interval
  • Remove line indentations
  • Remove HTML line breaks
  • Inspect result metadata and edit ranges
Open html-crush playground

Permalink to html-entities-not-email-friendlyhtml-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

Permalink to html-entity-codechtml-entity-codec →

  • Decode HTML character references
  • Decode an attribute value
  • Encode using stable named aliases
  • Escape a quoted attribute value
  • Encode without a named-reference table in bundled output

Permalink to html-img-althtml-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

Permalink to html-table-patcherhtml-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

Permalink to is-char-suitable-for-html-attr-nameis-char-suitable-for-html-attr-name →

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

Permalink to is-html-attribute-closingis-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

Permalink to is-html-tag-openingis-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

Permalink to is-language-codeis-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

Permalink to is-media-descriptoris-media-descriptor →

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

Permalink to is-relative-uriis-relative-uri →

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

Permalink to js-row-numjs-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

Permalink to json-comb-corejson-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()

Permalink to json-variablesjson-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

Permalink to lerna-clean-changelogslerna-clean-changelogs →

  • Quick Take
  • Empty cleaned text is a valid result; retain an existing EOF newline.
  • Fix SourceHut commit links
  • Keep literal examples while removing unfinished changelog entries.
  • Clean CR-only documents while retaining their line-ending style.
  • Preserve CRLF line endings
  • Retain a release heading while published changes remain beneath it.
  • Normalize list markers while keeping the separator between the lists.
  • Remove WIP entries and tidy the headings
  • Keep the full version and date while removing its complete Markdown link.

Permalink to object-all-values-equal-toobject-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

Permalink to object-boolean-combinationsobject-boolean-combinations →

  • Quick Take
  • Generate the one possible combination for an empty key set
  • Hold selected keys constant while varying the others
  • Fixed nested values are shared between generated rows

Permalink to object-delete-keyobject-delete-key →

  • Quick Take
  • Deletion by the key only
  • Deletion by the value only
  • Delete null and undefined object values
  • 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
  • Compose progress and inspect completion statistics
  • Wildcards

Permalink to object-fill-missing-keysobject-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

Permalink to object-flatten-all-arraysobject-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

Permalink to object-flatten-referencingobject-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

Permalink to object-merge-advancedobject-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
  • Reuse caller-owned inputs instead of defensively cloning them

Permalink to object-no-new-keysobject-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

Permalink to object-set-all-values-toobject-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

Permalink to ranges-applyranges-apply →

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

Permalink to ranges-cropranges-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

Permalink to ranges-ent-decoderanges-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

Permalink to ranges-invertranges-invert →

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

Permalink to ranges-is-index-withinranges-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

Permalink to ranges-iterateranges-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

Permalink to ranges-mergeranges-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

Permalink to ranges-process-outsideranges-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

Permalink to ranges-pushranges-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

Permalink to ranges-regexranges-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

Permalink to ranges-sortranges-sort →

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

Permalink to regex-empty-conditional-commentsregex-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
  • Use a fresh regular expression for an independent scan

Permalink to regex-is-jinja-nunjucksregex-is-jinja-nunjucks →

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

Permalink to regex-is-jspregex-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
  • Match a JSP namespace declaration independently of the element prefix

Permalink to regex-jinja-specificregex-jinja-specific →

  • Quick Take
  • Inline conditional ordering is shared by Jinja and Nunjucks
  • Detect Jinja namespace assignment syntax
  • Find Jinja format filter markers, including whitespace around the call

Permalink to rehype-responsive-tablesrehype-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

Permalink to remark-conventional-commit-changelog-timelineremark-conventional-commit-changelog-timeline →

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

Permalink to remark-typographyremark-typography →

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

Permalink to str-indexes-of-plusstr-indexes-of-plus →

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

Permalink to string-apostrophesstring-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

Permalink to string-character-is-astral-surrogatestring-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

Permalink to string-collapse-leading-whitespacestring-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

Permalink to string-collapse-white-spacestring-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

Permalink to string-convert-indexesstring-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

Permalink to string-dashesstring-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

Permalink to string-extract-class-namesstring-extract-class-names →

  • Quick Take
  • Extract selectors from HTML-style attribute selectors
  • Non-parsing algorithm can tackle really dodgy CSS
  • Decode CSS selector escapes
  • Extract raw escaped selectors
  • Isolate a selector prelude before extraction
  • Read lexical tokens from an isolated CSS region, retaining original offsets.
  • Read one selector token at an exact index
  • Inspect the source ranges of extracted selectors
  • Read semantic attribute selectors
  • Processes whole CSS selectors

Permalink to string-extract-sass-varsstring-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

Permalink to string-find-heads-tailsstring-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

Permalink to string-find-malformedstring-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

Permalink to string-fix-broken-named-entitiesstring-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

Permalink to string-left-rightstring-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
  • Match an astral symbol as two UTF-16 code units

Permalink to string-match-left-rightstring-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

Permalink to string-process-comma-separatedstring-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

Permalink to string-range-expanderstring-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
  • Preserve a separator between international 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

Permalink to string-remove-duplicate-heads-tailsstring-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

Permalink to string-remove-thousand-separatorsstring-remove-thousand-separators →

  • Quick Take
  • Convert decimal commas while retaining grouping separators
  • 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
  • Pad one-digit fractions without losing precision
  • Remove spaces used as thousand separators
  • Remove apostrophes used as thousand separators

Permalink to string-remove-widowsstring-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

Permalink to string-split-by-whitespacestring-split-by-whitespace →

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

Permalink to string-strip-htmlstring-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
  • Trim ordinary spaces while preserving tabs and line breaks
  • Prevent widow words while preserving HTML
  • Wrap a retained link destination with custom markers
Open string-strip-html playground

Permalink to string-trim-spaces-onlystring-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

Permalink to string-typo-matchstring-typo-match →

  • Match a contiguous omission
  • Preserve ambiguous suggestions
  • Interpret original UTF-16 spans
  • Supply directional keyboard neighbours
  • Configure long omissions explicitly
  • Reuse a candidate vocabulary
  • Observe preparation and lookup progress

Permalink to string-uglifystring-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

Permalink to string-unfancystring-unfancy →

  • Quick Take
  • Preserve combining marks while simplifying punctuation when requested
  • Normalise common typographic characters
  • Normalise an HTML-encoded typographic character
  • Convert non-breaking spaces
  • Decode repeatedly encoded HTML

Permalink to test-mixertest-mixer →

  • Quick Take
  • Preserve callback values without invoking them
  • Clone nested values for every generated variation
  • Process combinations lazily and stop when enough rows have been handled
  • No defaults means no variations
  • Carry non-boolean values into every variation
  • Pin one option while varying the others

Permalink to tsd-extracttsd-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

Permalink to util-array-object-or-bothutil-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

Permalink to util-nonemptyutil-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