🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

css-list

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-list - npm Package Compare versions

Comparing version

to
0.0.3

.travis.yml

10

index.js

@@ -0,5 +1,9 @@

var each = require('./lib/each'),
map = require('./lib/map'),
split = require('./lib/split');
module.exports = {
each: require('./lib/each'),
map: require('./lib/map'),
split: require('./lib/split')
each: each,
map: map,
split: split
};

@@ -45,3 +45,3 @@ /**

if (current !== '') {
cb(current.trim(), type);
cb(current, type);
current = '';

@@ -58,4 +58,4 @@ type = null;

if(current !== '') {
cb(current.trim(), type);
cb(current, type);
}
};

@@ -15,3 +15,4 @@ var each = require('./each');

each(string, separators, function (value, type) {
var result;
var result,
trimmed = value.trim();

@@ -21,8 +22,11 @@ if(type === 'separator') {

} else {
result = cb(value, type, prev, prevType);
array.push(result !== undefined ? result : value);
result = cb(trimmed, type, prev, prevType);
if(result !== undefined) {
value = value.replace(trimmed, result);
}
array.push(value);
}
if(type !== 'separator') {
prev = value;
prev = trimmed;
prevType = type;

@@ -29,0 +33,0 @@ }

@@ -15,3 +15,3 @@ var each = require('./each');

if(type !== 'separator') {
array.push(value);
array.push(value.trim());
isLastSep = false;

@@ -18,0 +18,0 @@ } else {

{
"name": "css-list",
"version": "0.0.2",
"version": "0.0.3",
"description": "css parsing helpers",

@@ -26,4 +26,5 @@ "main": "index.js",

"devDependencies": {
"tap-spec": "^3.0.0",
"tape": "^4.0.0"
}
}

@@ -1,2 +0,2 @@

# css-list
# css-list [![Build Status](https://travis-ci.org/TrySound/css-list.svg)](https://travis-ci.org/TrySound/css-list)
css parsing helpers

@@ -6,6 +6,36 @@

`list.each(input, separators, cb(value, type))`
### list.each(input, separators, cb)
`list.map(input, separators, cb(value, type, prev, prevType))`
```js
list.each('"50%" 50%/100% calc(100% + 20%)', [' ', '/'], function (value, type) {
// "50%" quote
// 50% null
// 100% null
// calc(100% + 20%) func
});
```
`list.split(input, separators, last)`
### list.map(input, separators, cb)
```js
list.map('"50%" 50%/100% calc(100% + 20%)', [' ', '/'], function (value, type, prevValue, prevType) {
if(type === 'func' || type === 'quote') {
return type;
}
});
// quote 50%/100% func
```
### list.split(input, separators, last)
```js
// space
list.split('10px 20px 5px 15px')', ['\n', '\t', ' '])
// ['10px', '20px', '5px', '15px']
```
```js
// comma
list.split('10px, 20px, 5px, ')', [','], true)
// ['10px', '20px', '5px', '']
```

@@ -41,2 +41,13 @@ var test = require('tape'),

]
}, {
message: 'splits list by comma with spaces',
fixtures: ' a, "hello, world!",\t b ',
separators: [','],
result: [
[' a', null],
[',', 'separator'],
[' "hello, world!"', 'quote'],
[',', 'separator'],
['\t b ', null],
]
}];

@@ -43,0 +54,0 @@

@@ -20,3 +20,7 @@ var test = require('tape'),

t.equal(map('\t\t&:hover , &:active ', [','], function (val) {
return 'hello';
}), '\t\thello , hello ')
t.end();
});