Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-value-parser

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-value-parser - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

12

lib/parser.js

@@ -13,3 +13,3 @@ var tokenize = require('./tokenize');

Parser.prototype.walk = function (name, cb, reverse) {
if(typeof name === 'function') {
if (typeof name === 'function') {
reverse = cb;

@@ -28,6 +28,6 @@ cb = name;

for(i = 0, max = nodes.length; i < max; i += 1) {
for (i = 0, max = nodes.length; i < max; i += 1) {
node = nodes[i];
if(!name || node.value === name) {
if(!reverse) {
if (!name || node.value === name) {
if (!reverse) {
result = cb(node, i, nodes);

@@ -37,3 +37,3 @@ }

type = node.type;
if(result !== false && node.nodes && type !== 'string' &&
if (result !== false && node.nodes && type !== 'string' &&
type !== 'space' &&

@@ -45,3 +45,3 @@ type !== 'word' &&

if(reverse) {
if (reverse) {
cb(node, i, nodes);

@@ -48,0 +48,0 @@ }

function stringifyNode(node) {
var type = node.type;
if(type === 'word' || type === 'space') {
if (type === 'word' || type === 'space') {
return node.value;
} else if(type === 'string') {
} else if (type === 'string') {
return (node.quote || '') + node.value + (node.quote || '');
} else if(type === 'div') {
} else if (type === 'div') {
return (node.before || '') + node.value + (node.after || '');
} else if(Array.isArray(node.nodes)) {
if(type === 'function') {
} else if (Array.isArray(node.nodes)) {
if (type === 'function') {
return node.value + '(' + stringify(node.nodes) + ')';

@@ -22,3 +22,3 @@ } else {

function stringify(nodes) {
if(Array.isArray(nodes)) {
if (Array.isArray(nodes)) {
return nodes.map(stringifyNode).join('');

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

@@ -27,7 +27,7 @@ 'use strict';

while(pos < length) {
while (pos < length) {
code = value.charCodeAt(pos);
last = tokens[tokens.length - 1];
switch(code) {
switch (code) {
case newline:

@@ -41,7 +41,7 @@ case space:

next += 1;
if(next === length) {
if (next === length) {
break;
}
code = value.charCodeAt(next);
} while(code === space ||
} while (code === space ||
code === newline ||

@@ -51,3 +51,3 @@ code === tab ||

code === feed);
if(last && last.type === 'div') {
if (last && last.type === 'div') {
last.after = value.slice(pos, next);

@@ -65,13 +65,9 @@ } else {

case slash:
if (last) {
if (last.type === 'space') {
last = tokens.pop();
}
tokens.push({
type: 'div',
value: String.fromCharCode(code),
before: last.type === 'space' ? last.value : '',
after: ''
});
}
last = last && last.type === 'space' ? tokens.pop() : null;
tokens.push({
type: 'div',
value: String.fromCharCode(code),
before: last && last.type === 'space' ? last.value : '',
after: ''
});

@@ -85,3 +81,3 @@ break;

type: 'function',
value: last.type === 'word' ? tokens.pop().value : '',
value: last && last.type === 'word' ? tokens.pop().value : '',
nodes: nodes

@@ -105,3 +101,3 @@ });

next = value.indexOf(quote, next + 1);
if(next === -1) {
if (next === -1) {
value += quote;

@@ -111,7 +107,7 @@ next = value.length - 1;

escapePos = next;
while(value.charCodeAt(escapePos - 1) === backslash) {
while (value.charCodeAt(escapePos - 1) === backslash) {
escapePos -= 1;
escape = !escape;
}
} while(escape);
} while (escape);
tokens.push({

@@ -128,3 +124,3 @@ type: 'string',

escape = true;
while(value.charCodeAt(next + 1) === backslash) {
while (value.charCodeAt(next + 1) === backslash) {
next += 1;

@@ -134,3 +130,3 @@ escape = !escape;

code = value.charCodeAt(next + 1);
if(escape && code !== slash &&
if (escape && code !== slash &&
code !== space &&

@@ -154,7 +150,7 @@ code !== newline &&

next += 1;
if(next === length) {
if (next === length) {
break;
}
code = value.charCodeAt(next);
} while(code !== singleQuote &&
} while (code !== singleQuote &&
code !== doubleQuote &&

@@ -161,0 +157,0 @@ code !== backslash &&

@@ -24,6 +24,6 @@ var minus = '-'.charCodeAt(0);

while(pos < length) {
while (pos < length) {
code = value.charCodeAt(pos);
if(code === zero ||
if (code === zero ||
code === one ||

@@ -40,4 +40,4 @@ code === two ||

containsNumber = true;
} else if(code === dot) {
if(dotted) {
} else if (code === dot) {
if (dotted) {
break;

@@ -47,4 +47,4 @@ }

number += value[pos];
} else if(code === plus || code === minus) {
if(pos !== 0) {
} else if (code === plus || code === minus) {
if (pos !== 0) {
break;

@@ -51,0 +51,0 @@ }

{
"name": "postcss-value-parser",
"version": "1.2.1",
"version": "1.2.2",
"description": "Transforms css values into the tree",

@@ -5,0 +5,0 @@ "main": "lib/parser.js",

@@ -0,0 +0,0 @@ [![Travis CI](https://travis-ci.org/TrySound/postcss-value-parser.svg)](https://travis-ci.org/TrySound/postcss-value-parser)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc