Socket
Socket
Sign inDemoInstall

doiuse

Package Overview
Dependencies
3
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

doiuse


Version published
Weekly downloads
277K
decreased by-8.7%
Maintainers
1
Created
Weekly downloads
 

Package description

What is doiuse?

The doiuse npm package is a tool for checking your CSS against browser support. It helps developers ensure that their CSS is compatible with the browsers they intend to support by identifying unsupported or partially supported CSS features.

What are doiuse's main functionalities?

Check CSS for browser support

This feature allows you to check your CSS code against a list of browsers to see if any features are not supported. The code sample demonstrates how to use doiuse with PostCSS to process a CSS string and log any warnings about unsupported features.

const doiuse = require('doiuse');
const postcss = require('postcss');

const css = 'a { display: flex; }';

postcss([doiuse({ browsers: ['> 1%', 'last 2 versions'] })])
  .process(css)
  .then(result => {
    result.warnings().forEach(warn => {
      console.warn(warn.toString());
    });
  });

Custom browser support configuration

This feature allows you to specify custom browser support configurations. The code sample shows how to configure doiuse to check CSS against Internet Explorer 10 and the last two versions of all other browsers.

const doiuse = require('doiuse');
const postcss = require('postcss');

const css = 'a { display: grid; }';

postcss([doiuse({ browsers: ['ie >= 10', 'last 2 versions'] })])
  .process(css)
  .then(result => {
    result.warnings().forEach(warn => {
      console.warn(warn.toString());
    });
  });

Other packages similar to doiuse

Changelog

Source

0.0.5 (2014-11-17)

  • add readable message to callback parameter

Readme

Source

doiuse

Lint CSS for browser support against caniuse database.

NOTE: This is a very, very initial release. Feedback or contributions are quite welcome!

TL;DR

var postcss = require('postcss');
var doiuse = require('doiuse');

postcss(doiuse({
  browsers:['ie >= 6', '> 1%'],
  onUnsupportedFeatureUse: function(usageInfo) {
    console.log(usageInfo.message);
  }
})).process("a { background-size: cover; }")

How it works

In particular, the approach to detecting features usage is currently quite naive.

Refer to the data in /src/data/features.coffee.

  • If a feature in that dataset only specifies properties, we just use those properties for substring matches against the properties used in the input CSS.
  • If a feature also specifies values, then we also require that the associated value matches one of those values (again, with a substring match).

TODO:

  • Selectors and @-rules
  • Allow each feature to have multiple instances of the match criteria laid out above, so that different, disjoint (property, value) combinations can be used to detect a feature.
  • Subfeatures, in to allow a slightly looser coupling with caniuse-db's structure (I'm thinking about the different versions of flexbox.)
  • Prefix-aware testing: i.e., pass along a list of prefixes used with a given feature. (This is low priority: just use autoprefixer.)

API Details:

postcss(doiuse(opts)).process(css), where opts is:

{
  browsers: ['ie >= 8', '> 1%'] // an autoprefixer-like array of browsers.
  onUnsupportedFeatureUse: function(usageInfo) { } // a callback for usages of features not supported by the selected browsers
}

And usageInfo looks like this:

{
  feature: 'css-gradients', //slug identifying a caniuse-db feature
  featureData:{
    missing: {
      // subset of selected browsers that are missing support for this
      // particular feature, mapped to the version and (lack of)support code
      ie: { '8': 'n' }
    },
    caniuseData: { // data from caniuse-db/features-json/[feature].json }
  },
  usage: //the postcss node where that feature is being used.
}
Called once for each usage of each css feature not supported by the selected
browsers.

License

MIT

NOTE: The files in test/cases are from autoprefixer-core, Copyright 2013 Andrey Sitnik andrey@sitnik.ru. Please see https://github.com/postcss/autoprefixer-core.

Keywords

FAQs

Last updated on 17 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc