New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

cssnano-utils

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssnano-utils

Utility methods and plugin for cssnano projects

Source
npmnpm
Version
8.2.1
Version published
Weekly downloads
15M
52.23%
Maintainers
4
Weekly downloads
 
Created
Source

cssnano-utils

Utility methods and plugins for cssnano projects.

API

PostCSS Utilities

UtilityDescription
rawCachePostCSS plugin that sets default formatting for generated AST nodes on result.root.rawCache.
sameParentRecursively check whether two PostCSS nodes share the same parent ancestry.

CSS Tokenizer and Value Utilities

UtilityDescription
TokenTypeRe-exported TokenType enum from @csstools/css-tokenizer.
tokensTokenize a CSS string into a CSSToken[] array with trailing EOF tokens stripped.
tokenStartReturn the inclusive start character offset of a token (token[2]).
tokenEndReturn the exclusive end character offset of a token (token[3] + 1) for string slicing.
decodedReturn the decoded string value of a token, falling back to its raw representation.
numericParse a single token into { number, unit }, or false if not a numeric token.
numericSourceCapture a numeric token or multi-token sequence (e.g. 1.em) with exclusive source bounds.
balancedTokensParse CSS into a BalancedTokens index of matching delimiters ((), [], {}), or undefined if unbalanced.
applyEditsApply validated, non-overlapping string edits. Invalid bounds or overlaps fail closed by returning the complete original source.

BalancedTokens Methods

Instances returned by balancedTokens(source) provide:

  • endForOpening(index): Returns the closing token index for an opening delimiter token at index.
  • topLevelSegments(startIndex?, endIndex?, delimiter?): Splits a balanced token range by a top-level delimiter (defaults to comma).

Usage

import cssnanoUtils from 'cssnano-utils';

const { tokens, balancedTokens, applyEdits } = cssnanoUtils;

const structure = balancedTokens('cubic-bezier(0.1, 0.7, 1.0, 0.1)');
if (structure) {
  const segments = structure.topLevelSegments();
  // Process balanced segments
}

Contributors

See CONTRIBUTORS.md.

License

MIT

FAQs

Package last updated on 08 Oct 2026

Related posts