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

icss-utils

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icss-utils - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

LICENSE.md

40

lib/createICSSRules.js

@@ -13,14 +13,10 @@ "use strict";

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var createImports = function createImports(imports) {
return Object.keys(imports).map(function (path) {
var aliases = imports[path];
var declarations = Object.keys(aliases).map(function (key) {
return _postcss2.default.decl({
prop: key,
value: aliases[key],
raws: { before: "\n " }
});
});
const createImports = imports => {
return Object.keys(imports).map(path => {
const aliases = imports[path];
const declarations = Object.keys(aliases).map(key => _postcss2.default.decl({
prop: key,
value: aliases[key],
raws: { before: "\n " }
}));
return _postcss2.default.rule({

@@ -33,14 +29,12 @@ selector: `:import('${path}')`,

var createExports = function createExports(exports) {
var declarations = Object.keys(exports).map(function (key) {
return _postcss2.default.decl({
prop: key,
value: exports[key],
raws: { before: "\n " }
});
});
const createExports = exports => {
const declarations = Object.keys(exports).map(key => _postcss2.default.decl({
prop: key,
value: exports[key],
raws: { before: "\n " }
}));
if (declarations.length === 0) {
return [];
}
var rule = _postcss2.default.rule({
const rule = _postcss2.default.rule({
selector: `:export`,

@@ -52,6 +46,4 @@ raws: { after: "\n" }

var createICSSRules = function createICSSRules(imports, exports) {
return [].concat(_toConsumableArray(createImports(imports)), _toConsumableArray(createExports(exports)));
};
const createICSSRules = (imports, exports) => [...createImports(imports), ...createExports(exports)];
exports.default = createICSSRules;

24

lib/extractICSS.js

@@ -6,7 +6,7 @@ "use strict";

});
var importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
var getDeclsObject = function getDeclsObject(rule) {
var object = {};
rule.walkDecls(function (decl) {
const getDeclsObject = rule => {
const object = {};
rule.walkDecls(decl => {
object[decl.raws.before.trim() + decl.prop] = decl.value;

@@ -17,14 +17,12 @@ });

var extractICSS = function extractICSS(css) {
var removeRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var icssImports = {};
var icssExports = {};
css.each(function (node) {
const extractICSS = (css, removeRules = true) => {
const icssImports = {};
const icssExports = {};
css.each(node => {
if (node.type === "rule") {
if (node.selector.slice(0, 7) === ":import") {
var matches = importPattern.exec(node.selector);
const matches = importPattern.exec(node.selector);
if (matches) {
var path = matches[1].replace(/'|"/g, "");
var aliases = Object.assign(icssImports[path] || {}, getDeclsObject(node));
const path = matches[1].replace(/'|"/g, "");
const aliases = Object.assign(icssImports[path] || {}, getDeclsObject(node));
icssImports[path] = aliases;

@@ -31,0 +29,0 @@ if (removeRules) {

@@ -13,4 +13,4 @@ "use strict";

var replaceSymbols = function replaceSymbols(css, replacements) {
css.walk(function (node) {
const replaceSymbols = (css, replacements) => {
css.walk(node => {
if (node.type === "decl") {

@@ -17,0 +17,0 @@ node.value = (0, _replaceValueSymbols2.default)(node.value, replacements);

@@ -6,8 +6,8 @@ "use strict";

});
var matchValueName = /[$]?[\w-]+/g;
const matchValueName = /[$]?[\w-]+/g;
var replaceValueSymbols = function replaceValueSymbols(value, replacements) {
var matches = void 0;
const replaceValueSymbols = (value, replacements) => {
let matches;
while (matches = matchValueName.exec(value)) {
var replacement = replacements[matches[0]];
const replacement = replacements[matches[0]];
if (replacement) {

@@ -14,0 +14,0 @@ value = value.slice(0, matches.index) + replacement + value.slice(matchValueName.lastIndex);

{
"name": "icss-utils",
"version": "3.0.1",
"version": "4.0.0",
"description": "ICSS utils for postcss ast",
"main": "lib/index.js",
"engines": {
"node": ">= 6"
},
"files": [

@@ -37,3 +40,3 @@ "lib"

"targets": {
"node": 4
"node": 6
}

@@ -61,3 +64,3 @@ }

"dependencies": {
"postcss": "^6.0.2"
"postcss": "^7.0.5"
},

@@ -64,0 +67,0 @@ "devDependencies": {

@@ -0,0 +0,0 @@ [![Build Status](https://travis-ci.org/css-modules/icss-utils.svg)](https://travis-ci.org/css-modules/icss-utils)

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