updated node modules
This commit is contained in:
2
nodejs/node_modules/stylus/lib/functions/current-media.js
generated
vendored
2
nodejs/node_modules/stylus/lib/functions/current-media.js
generated
vendored
@@ -8,10 +8,12 @@ var nodes = require('../nodes');
|
||||
*/
|
||||
|
||||
module.exports = function currentMedia(){
|
||||
var self = this;
|
||||
return new nodes.String(lookForMedia(this.closestBlock.node) || '');
|
||||
|
||||
function lookForMedia(node){
|
||||
if ('media' == node.nodeName) {
|
||||
node.val = self.visit(node.val);
|
||||
return node.toString();
|
||||
} else if (node.block.parent.node) {
|
||||
return lookForMedia(node.block.parent.node);
|
||||
|
6
nodejs/node_modules/stylus/lib/functions/define.js
generated
vendored
6
nodejs/node_modules/stylus/lib/functions/define.js
generated
vendored
@@ -6,13 +6,17 @@ var utils = require('../utils')
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Expression} expr
|
||||
* @param {Boolean} [global]
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function define(name, expr){
|
||||
module.exports = function define(name, expr, global){
|
||||
utils.assertType(name, 'string', 'name');
|
||||
expr = utils.unwrap(expr);
|
||||
var scope = this.currentScope;
|
||||
if (global && global.toBoolean().isTrue) {
|
||||
scope = this.global.scope;
|
||||
}
|
||||
var node = new nodes.Ident(name.val, expr);
|
||||
scope.add(node);
|
||||
return nodes.null;
|
||||
|
1
nodejs/node_modules/stylus/lib/functions/index.js
generated
vendored
1
nodejs/node_modules/stylus/lib/functions/index.js
generated
vendored
@@ -55,6 +55,7 @@ exports.selectors = require('./selectors');
|
||||
exports.shift = require('./shift');
|
||||
exports.split = require('./split');
|
||||
exports.substr = require('./substr');
|
||||
exports.slice = require('./slice');
|
||||
exports.tan = require('./tan');
|
||||
exports.trace = require('./trace');
|
||||
exports.transparentify = require('./transparentify');
|
||||
|
11
nodejs/node_modules/stylus/lib/functions/index.styl
generated
vendored
11
nodejs/node_modules/stylus/lib/functions/index.styl
generated
vendored
@@ -284,3 +284,14 @@ cache()
|
||||
/$cache_placeholder_for_{$id}
|
||||
$stylus_mixin_cache[$key] = $id
|
||||
{block}
|
||||
|
||||
// Percentage function to convert a number, e.g. ".45", into a percentage, e.g. "45%"
|
||||
|
||||
percentage(num)
|
||||
return unit(num * 100, '%')
|
||||
|
||||
// Returns the position of a `value` within a `list`
|
||||
|
||||
index(list, value)
|
||||
for val, i in list
|
||||
return i if val == value
|
||||
|
38
nodejs/node_modules/stylus/lib/functions/match.js
generated
vendored
38
nodejs/node_modules/stylus/lib/functions/match.js
generated
vendored
@@ -1,29 +1,43 @@
|
||||
var utils = require('../utils')
|
||||
, nodes = require('../nodes');
|
||||
|
||||
var VALID_FLAGS = 'igm';
|
||||
|
||||
/**
|
||||
* Test if `val` matches the given `pattern`.
|
||||
* retrieves the matches when matching a `val`(string)
|
||||
* against a `pattern`(regular expression).
|
||||
*
|
||||
* Examples:
|
||||
* $regex = '^(height|width)?([<>=]{1,})(.*)'
|
||||
*
|
||||
* match('^foo(bar)?', foo)
|
||||
* match('^foo(bar)?', foobar)
|
||||
* match('^foo(bar)?', 'foo')
|
||||
* match('^foo(bar)?', 'foobar')
|
||||
* // => true
|
||||
* match($regex,'height>=sm')
|
||||
* // => ('height>=sm' 'height' '>=' 'sm')
|
||||
* // => also truthy
|
||||
*
|
||||
* match('^foo(bar)?', 'bar')
|
||||
* // => false
|
||||
* match($regex, 'lorem ipsum')
|
||||
* // => null
|
||||
*
|
||||
* @param {String} pattern
|
||||
* @param {String|Ident} val
|
||||
* @return {Boolean}
|
||||
* @param {String|Ident} [flags='']
|
||||
* @return {String|Null}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function match(pattern, val){
|
||||
module.exports = function match(pattern, val, flags){
|
||||
utils.assertType(pattern, 'string', 'pattern');
|
||||
utils.assertString(val, 'val');
|
||||
var re = new RegExp(pattern.val);
|
||||
return new nodes.Boolean(re.test(val.string));
|
||||
var re = new RegExp(pattern.val, validateFlags(flags) ? flags.string : '');
|
||||
return val.string.match(re);
|
||||
};
|
||||
|
||||
function validateFlags(flags) {
|
||||
flags = flags && flags.string;
|
||||
|
||||
if (flags) {
|
||||
return flags.split('').every(function(flag) {
|
||||
return ~VALID_FLAGS.indexOf(flag);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
28
nodejs/node_modules/stylus/lib/functions/slice.js
generated
vendored
Normal file
28
nodejs/node_modules/stylus/lib/functions/slice.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var utils = require('../utils'),
|
||||
nodes = require('../nodes');
|
||||
|
||||
/**
|
||||
* This is a heler function for the slice method
|
||||
*
|
||||
* @param {String|Ident} vals
|
||||
* @param {Unit} start [0]
|
||||
* @param {Unit} end [vals.length]
|
||||
* @return {String|Literal|Null}
|
||||
* @api public
|
||||
*/
|
||||
(module.exports = function slice(val, start, end) {
|
||||
start = start && start.nodes[0].val;
|
||||
end = end && end.nodes[0].val;
|
||||
|
||||
val = utils.unwrap(val).nodes;
|
||||
|
||||
if (val.length > 1) {
|
||||
return utils.coerce(val.slice(start, end), true);
|
||||
}
|
||||
|
||||
var result = val[0].string.slice(start, end);
|
||||
|
||||
return val[0] instanceof nodes.Ident
|
||||
? new nodes.Ident(result)
|
||||
: new nodes.String(result);
|
||||
}).raw = true;
|
34
nodejs/node_modules/stylus/lib/functions/url.js
generated
vendored
34
nodejs/node_modules/stylus/lib/functions/url.js
generated
vendored
@@ -34,6 +34,14 @@ var defaultMimes = {
|
||||
, '.woff2': 'application/font-woff2'
|
||||
};
|
||||
|
||||
/**
|
||||
* Supported encoding types
|
||||
*/
|
||||
var encodingTypes = {
|
||||
BASE_64: 'base64',
|
||||
UTF8: 'charset=utf-8'
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a url() function with the given `options`.
|
||||
*
|
||||
@@ -61,9 +69,16 @@ module.exports = function(options) {
|
||||
var sizeLimit = null != options.limit ? options.limit : 30000;
|
||||
var mimes = options.mimes || defaultMimes;
|
||||
|
||||
function fn(url){
|
||||
/**
|
||||
* @param {object} url - The path to the image you want to encode.
|
||||
* @param {object} enc - The encoding for the image. Defaults to base64, the
|
||||
* other valid option is `utf8`.
|
||||
*/
|
||||
function fn(url, enc){
|
||||
// Compile the url
|
||||
var compiler = new Compiler(url);
|
||||
var compiler = new Compiler(url)
|
||||
, encoding = encodingTypes.BASE_64;
|
||||
|
||||
compiler.isURL = true;
|
||||
url = url.nodes.map(function(node){
|
||||
return compiler.visit(node);
|
||||
@@ -76,7 +91,8 @@ module.exports = function(options) {
|
||||
, hash = url.hash || ''
|
||||
, literal = new nodes.Literal('url("' + url.href + '")')
|
||||
, paths = _paths.concat(this.paths)
|
||||
, buf;
|
||||
, buf
|
||||
, result;
|
||||
|
||||
// Not supported
|
||||
if (!mime) return literal;
|
||||
@@ -103,8 +119,18 @@ module.exports = function(options) {
|
||||
// Too large
|
||||
if (false !== sizeLimit && buf.length > sizeLimit) return literal;
|
||||
|
||||
if (enc && 'utf8' == enc.first.val.toLowerCase()) {
|
||||
encoding = encodingTypes.UTF8;
|
||||
result = buf.toString('utf8').replace(/\s+/g, ' ')
|
||||
.replace(/[{}\|\\\^~\[\]`"<>#%]/g, function(match) {
|
||||
return '%' + match[0].charCodeAt(0).toString(16).toUpperCase();
|
||||
}).trim();
|
||||
} else {
|
||||
result = buf.toString(encoding) + hash;
|
||||
}
|
||||
|
||||
// Encode
|
||||
return new nodes.Literal('url("data:' + mime + ';base64,' + buf.toString('base64') + hash + '")');
|
||||
return new nodes.Literal('url("data:' + mime + ';' + encoding + ',' + result + '")');
|
||||
};
|
||||
|
||||
fn.raw = true;
|
||||
|
Reference in New Issue
Block a user