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

more-css

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

more-css - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

tests/a.css

37

build/More.js

@@ -29,3 +29,4 @@ var fs=require('fs');

suffix: 'css',
root: ''
root: '',
map: null
};

@@ -78,2 +79,11 @@

self.imports().forEach(function(im) {
if(global.map) {
//映射类型可能是回调
if(typeof global.map == 'function') {
im = global.map(im);
}
else if(global.map.hasOwnProperty(im)){
im = global.map[im];
}
}
if(global.suffix != 'css') {

@@ -210,2 +220,21 @@ im = im.replace(/\.\w+$/, '.' + global.suffix);

var str = getVar(token, self.varHash, global.vars);
//map映射url
if(token.import && global.map) {
var quote = /^['"']/.test(str) ? str.charAt(0) : '';
var val = quote ? str.slice(1, str.length - 1) : str;
//映射类型可能是回调
if(typeof global.map == 'function') {
str = global.map(val);
//如有引号,需处理转义
if(quote) {
str = quote + str + quote;
}
}
else if(global.map.hasOwnProperty(token.val())){
str = global.map[val];
if(quote) {
str = quote + str + quote;
}
}
}
//有@import url(xxx.css?xxx)的写法,需忽略

@@ -580,2 +609,8 @@ if(token.import && str.indexOf('.css?') == -1) {

}
More.map=function(data) {
if(typeof data != 'undefined') {
global.map = data;
}
return global.map;
}

@@ -582,0 +617,0 @@

6

package.json
{
"name": "more-css",
"version": "0.9.0",
"version": "0.9.1",
"description": "a css pre-compiler & agressive compressor",

@@ -39,3 +39,3 @@ "maintainers": [

"clean-css": "^3.0.4",
"homunculus": "^0.7.1"
"homunculus": "^0.7.7"
},

@@ -53,3 +53,3 @@ "devDependencies": {

"through2": "^0.6.1",
"jsdc": "^0.5.0"
"jsdc": "^0.5.4"
},

@@ -56,0 +56,0 @@ "main": "./index",

@@ -58,2 +58,3 @@ A css pre-compiler & radical-compressor

* compress(code:String, options:Object = { processImport: false }, radical:Boolean = false):String 同上,增加options选项,传给clean-css
* map(data:Object/Function):Object/Function 全局设置/读取映射表,用以将@import的文件名作匹配替换处理

@@ -60,0 +61,0 @@ ## Demo

@@ -29,3 +29,4 @@ module fs from 'fs';

suffix: 'css',
root: ''
root: '',
map: null
};

@@ -78,2 +79,11 @@

self.imports().forEach(function(im) {
if(global.map) {
//映射类型可能是回调
if(typeof global.map == 'function') {
im = global.map(im);
}
else if(global.map.hasOwnProperty(im)){
im = global.map[im];
}
}
if(global.suffix != 'css') {

@@ -210,2 +220,21 @@ im = im.replace(/\.\w+$/, '.' + global.suffix);

var str = getVar(token, self.varHash, global.vars);
//map映射url
if(token.import && global.map) {
var quote = /^['"']/.test(str) ? str.charAt(0) : '';
var val = quote ? str.slice(1, str.length - 1) : str;
//映射类型可能是回调
if(typeof global.map == 'function') {
str = global.map(val);
//如有引号,需处理转义
if(quote) {
str = quote + str + quote;
}
}
else if(global.map.hasOwnProperty(token.val())){
str = global.map[val];
if(quote) {
str = quote + str + quote;
}
}
}
//有@import url(xxx.css?xxx)的写法,需忽略

@@ -580,2 +609,8 @@ if(token.import && str.indexOf('.css?') == -1) {

}
static map(data) {
if(typeof data != 'undefined') {
global.map = data;
}
return global.map;
}
}

@@ -582,0 +617,0 @@

@@ -903,2 +903,38 @@ var expect = require('expect.js');

});
});
describe('map', function() {
it('hash', function() {
More.map({
'a.css': 'b"\'.css'
});
var more = new More();
var s = '@import url(a.css);';
var res = more.parse(s);
expect(res).to.eql('@import url(b"\'.css);');
});
it('function', function() {
More.map(function(url) {
return '1' + url;
});
var more = new More();
var s = '@import "a.less";';
var res = more.parse(s);
expect(res).to.eql('@import "1a.css";');
});
it('file hash', function() {
More.map({
'x.css': 'b.css'
});
var more = new More();
var res = more.parseFile(path.join(__dirname, './a.css'), true);
expect(res).to.eql('a{}');
});
it('file function', function() {
More.map(function() {
return 'c.css';
});
var more = new More();
var res = more.parseFile(path.join(__dirname, './a.css'), true);
expect(res).to.eql('b{}');
});
});

@@ -29,3 +29,4 @@ define(function(require, exports, module){var fs=require('fs');

suffix: 'css',
root: ''
root: '',
map: null
};

@@ -78,2 +79,11 @@

self.imports().forEach(function(im) {
if(global.map) {
//映射类型可能是回调
if(typeof global.map == 'function') {
im = global.map(im);
}
else if(global.map.hasOwnProperty(im)){
im = global.map[im];
}
}
if(global.suffix != 'css') {

@@ -210,2 +220,21 @@ im = im.replace(/\.\w+$/, '.' + global.suffix);

var str = getVar(token, self.varHash, global.vars);
//map映射url
if(token.import && global.map) {
var quote = /^['"']/.test(str) ? str.charAt(0) : '';
var val = quote ? str.slice(1, str.length - 1) : str;
//映射类型可能是回调
if(typeof global.map == 'function') {
str = global.map(val);
//如有引号,需处理转义
if(quote) {
str = quote + str + quote;
}
}
else if(global.map.hasOwnProperty(token.val())){
str = global.map[val];
if(quote) {
str = quote + str + quote;
}
}
}
//有@import url(xxx.css?xxx)的写法,需忽略

@@ -580,2 +609,8 @@ if(token.import && str.indexOf('.css?') == -1) {

}
More.map=function(data) {
if(typeof data != 'undefined') {
global.map = data;
}
return global.map;
}

@@ -582,0 +617,0 @@

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