How to use the css-size.numeric function in css-size

To help you get started, we’ve selected a few css-size examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / opticss / test / util / assertSmaller.ts View on Github external
export function assertSmaller(inputCSS: string, result: CascadeTestResult, assertions?: DeltaAssertions): Promise {
  let testedMarkup = result.testedTemplates[0].testedMarkups[0];
  let inputHtml = testedMarkup.originalBody;
  let optimizedHtml = Promise.resolve({css: testedMarkup.optimizedBody});
  const optimizedCss = Promise.resolve({css: result.optimization.output.content.toString()});
  let templatePromise = cssSize.numeric(inputHtml, {}, () => optimizedHtml);
  let cssPromise = cssSize.numeric(inputCSS, {}, () => optimizedCss);
  return Promise.all([cssPromise, templatePromise]).then(([cssDelta, templateDelta]) => {
    assertDelta("uncompressed", cssDelta, templateDelta, assertions);
    assertDelta("gzip", cssDelta, templateDelta, assertions);
    assertDelta("brotli", cssDelta, templateDelta, assertions);
  });
}
github linkedin / opticss / test / util / assertSmaller.ts View on Github external
export function assertSmaller(inputCSS: string, result: CascadeTestResult, assertions?: DeltaAssertions): Promise {
  let testedMarkup = result.testedTemplates[0].testedMarkups[0];
  let inputHtml = testedMarkup.originalBody;
  let optimizedHtml = Promise.resolve({css: testedMarkup.optimizedBody});
  const optimizedCss = Promise.resolve({css: result.optimization.output.content.toString()});
  let templatePromise = cssSize.numeric(inputHtml, {}, () => optimizedHtml);
  let cssPromise = cssSize.numeric(inputCSS, {}, () => optimizedCss);
  return Promise.all([cssPromise, templatePromise]).then(([cssDelta, templateDelta]) => {
    assertDelta("uncompressed", cssDelta, templateDelta, assertions);
    assertDelta("gzip", cssDelta, templateDelta, assertions);
    assertDelta("brotli", cssDelta, templateDelta, assertions);
  });
}

css-size

Compare the compressed and uncompressed sizes of a CSS file before and after processing.

MIT
Latest version published 10 months ago

Package Health Score

80 / 100
Full package analysis

Popular css-size functions