🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

jdists

Package Overview
Dependencies
Maintainers
4
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jdists - npm Package Compare versions

Comparing version
2.0.0
to
2.0.1
+47
processor/processor-extract.js
/**
* 将 JSON 第一级字段导出为变量
*
* @param {string} content 文本内容
* @param {Object} attrs 属性
* @param {Object} scope 作用域
* @param {Function} scope.execExport 导出数据
* @example extract base
```input
<~jdists encoding="extract"~>
{
"name": "extract",
"version": "0.0.1",
"private": true,
"author": {
"name": "zswang",
"url": "http://weibo.com/zswang"
}
}
<~/jdists~>
<~jdists import="#name" /~>
<~jdists import="#version" /~>
<~jdists import="#private" /~>
<~jdists import="#author" /~>
```
```output
extract
0.0.1
true
{"name":"zswang","url":"http://weibo.com/zswang"}
```
*/
module.exports = function processor(content, attrs, scope) {
if (!content) {
return '';
}
var data = new Function(
'return (' + content + ');'
)();
Object.keys(data).forEach(function (key) {
scope.execExport('#' + key, data[key]);
});
return '';
};
+3
-2

@@ -7,4 +7,4 @@ /**

* zswang (http://weibo.com/zswang)
* @version 2.0.0
* @date 2016-11-14
* @version 2.0.1
* @date 2016-11-25
*/

@@ -17,2 +17,3 @@ var fs = require('fs');

"ejs": require('../processor/processor-ejs'),
"extract": require('../processor/processor-extract'),
"fndep": require('../processor/processor-fndep'),

@@ -19,0 +20,0 @@ "glob": require('../processor/processor-glob'),

+7
-2

@@ -7,4 +7,4 @@ /**

* zswang (http://weibo.com/zswang)
* @version 2.0.0
* @date 2016-11-14
* @version 2.0.1
* @date 2016-11-25
*/

@@ -723,2 +723,7 @@ var colors = require('colors');

}
if (typeof value === 'object') {
value = JSON.stringify(value);
} else {
value = String(value);
}
node.content = value;

@@ -725,0 +730,0 @@ if (node.attrs.export && node.attrs.export !== '&') {

{
"name": "jdists",
"version": "2.0.0",
"version": "2.0.1",
"description": "Code block processing tools",

@@ -65,3 +65,3 @@ "main": "lib/jdists.js",

"mocha": "mocha",
"lint": "jshint src/*.js src/**/*.js processor/*.js processor-extend/*.js"
"lint": "jshint src/*.js processor/*.js processor-extend/*.js"
},

@@ -68,0 +68,0 @@ "files": [