Socket
Socket
Sign inDemoInstall

beezlib

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beezlib - npm Package Compare versions

Comparing version 0.9.17 to 0.9.18

test/json/user.body.js

36

lib/fsys/index.js

@@ -11,2 +11,3 @@ /**

var util = require('util');
var vm = require('vm');

@@ -240,15 +241,38 @@ var _ = require('lodash');

* @method
* @param {String} path load file path
* @param {String} filePath load file path
* @param {String} encode file encode
* @return {Object} load json data
*/
readFileFnJSONSync: function (path, encode) {
readFileFnJSONSync: function (filePath, encode) {
encode = encode || 'utf-8';
if (this.isFileSync(path)) {
var raw = fs.readFileSync(path, encode);
if (this.isFileSync(filePath)) {
var raw = fs.readFileSync(filePath, encode);
var exports = {};
var context = {
process: process,
require: function(name) {
var module;
try {
module = require((function (_module) {
if (_module.charAt(0) !== '.') {
return _module;
}
return path.resolve(path.dirname(filePath), _module);
}(name)));
} catch (e) {
throw e;
}
return module;
},
__filename: __filename,
__dilename: __dirname,
module: {
exports: exports
},
exports: exports
};
try {
var fn = new Function ('process', 'require', '__filename', '__dirname', 'module', 'exports', "return " + raw);
return fn(process, require, __filename, __dirname, module, exports);
return vm.runInNewContext(raw, context);
} catch (e) {

@@ -255,0 +279,0 @@ throw e;

2

package.json
{
"name": "beezlib",
"version": "0.9.17",
"version": "0.9.18",
"description": "The utility library for Node.js using beez projects.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -36,2 +36,8 @@ var path = require('path');

json.hoge.should.equal('foo').be.ok;
var user = beezlib.fsys.readFileFnJSONSync('test/json/user.js');
user.name.should.equal('nickname').be.ok;
var user_body = beezlib.fsys.readFileFnJSONSync('test/json/user.body.js');
user_body.head.should.equal('head1').be.ok;
user.body.should.eql(user_body).be.ok;
});

@@ -38,0 +44,0 @@ it('readFileMultiConfigureSync', function () {

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