Have ideas to improve npm?Join in the discussion! »

sort-media-queries

0.2.2 • Public • Published

sort-media-queries

Sort media queries.

Installation

npm install sort-media-queries --save

API

smq(list, [propertyName])

Returns: Array

Sorts media queries, either as list of strings or objects. Property argument is used when sorting list of objects.

list

Type: Array

List of media queries to sort. Can be list with strings and list with objects.

If array is passed and nothing can be sorted, it will return original array. Otherwise, if passed argument is not array, it will return empty array.

propertyName

Type: String

Property used to sort objects inside media queries list.

Examples

var smq = require('sort-media-queries');
 
smq(["screen and (min-width:1278px)","screen and (min-width:100px)","screen and (min-width:99px)"]);
// ["screen and (min-width:99px)","screen and (min-width:100px)","screen and (min-width:1278px)"]
 
smq([{"media":"screen and (min-width:1278px)","bar":2},{"media":"screen and (min-width:100px)"},{"media":"screen and (min-width:99px)","foo":1}], 'media');
// [{"media":"screen and (min-width:99px)","foo":1},{"media":"screen and (min-width:100px)"},{"media":"screen and (min-width:1278px)","bar":2}]

Browser support

Tested in IE8+ and all modern browsers.

Acknowledgements

Algorithm for media queries sorting is taken from buildingblocks/grunt-combine-media-queries (original project license). This repo serves only as separate module which can be included in other projects.

License

MIT © Ivan Nikolić

Install

npm i sort-media-queries

DownloadsWeekly Downloads

29,020

Version

0.2.2

License

MIT

Last publish

Collaborators

  • avatar