import { IPlugin , Parser , Options } from "./plugin" ; import { Root } from "postcss" ; import { optionsParser , extractCSSValue } from "./options-parser" ; const noop = ( target ) : string => target ; export class PostcssRelaxedUnit implements IPlugin { pluginName = "postcss-relaxed-unit" ; run ( options ? ) { const parsers = optionsParser ( options ) ; return ( root ) => root . walkDecls ( declare => { return ( declare . value = declare . value . replace ( /([0-9a-zA-Z.]+)/g , ( _ , cap ) => ( parsers [ extractCSSValue ( cap ) . unit ] || noop ) ( cap ) ) ) ; } ) ; } }