confeta-file
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -6,5 +6,2 @@ 'use strict'; | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
exports.default = createInstance; | ||
@@ -20,2 +17,6 @@ | ||
var _confetaText = require('confeta-text'); | ||
var _confetaText2 = _interopRequireDefault(_confetaText); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -25,81 +26,38 @@ | ||
var $obj = Symbol('obj'); | ||
var $hasNoFile = Symbol('has-no-file'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var ConfetaFile = function () { | ||
function ConfetaFile() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
_classCallCheck(this, ConfetaFile); | ||
var ConfetaFile = function (_ConfetaText) { | ||
_inherits(ConfetaFile, _ConfetaText); | ||
this[$hasNoFile] = false; | ||
function ConfetaFile(filePath) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var parseFn = options.parseFn || JSON.parse; | ||
var obj = undefined; | ||
if (options.content) { | ||
obj = parseFn(options.content); | ||
} else if (options.path) { | ||
var filePath = options.path; | ||
_classCallCheck(this, ConfetaFile); | ||
!_path2.default.isAbsolute(filePath) && (filePath = _path2.default.resolve(process.cwd(), options.path)); | ||
if (!_fs2.default.existsSync(filePath)) { | ||
this[$hasNoFile] = true; | ||
this[$obj] = {}; | ||
if (!_path2.default.isAbsolute(filePath)) { | ||
filePath = _path2.default.resolve(process.cwd(), filePath); | ||
} | ||
return; | ||
} | ||
if (!_fs2.default.existsSync(filePath)) { | ||
var _this, _ret; | ||
obj = parseFn(_fs2.default.readFileSync(filePath, 'utf8')); | ||
return _ret = (_this = _possibleConstructorReturn(this, Object.getPrototypeOf(ConfetaFile).call(this, '{}')), _this), _possibleConstructorReturn(_this, _ret); | ||
} | ||
this[$obj] = obj; | ||
var text = _fs2.default.readFileSync(filePath, 'utf8'); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(ConfetaFile).call(this, text, { parseFn: options.parseFn })); | ||
} | ||
_createClass(ConfetaFile, [{ | ||
key: 'get', | ||
value: function get(segments) { | ||
if (this[$hasNoFile]) { | ||
return; | ||
} | ||
return ConfetaFile; | ||
}(_confetaText2.default); | ||
var value = this[$obj]; | ||
function createInstance() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var segment = _step.value; | ||
value = value[segment]; | ||
if (!value) { | ||
return; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
return value; | ||
} | ||
}]); | ||
return ConfetaFile; | ||
}(); | ||
function createInstance(options) { | ||
return new ConfetaFile(options); | ||
return new (Function.prototype.bind.apply(ConfetaFile, [null].concat(args)))(); | ||
} |
{ | ||
"name": "confeta-file", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Confeta file source", | ||
@@ -20,3 +20,3 @@ "main": "lib/index.js", | ||
"watch": "watch-run -s -p $npm_package_testsGlob,$npm_package_srcGlob -i \"npm run build && npm run test-pretty\" ", | ||
"prepublish": "npm run lint && npm run build && npm run test && npm shrinkwrap" | ||
"prepublish": "npm run lint && npm run build && npm run test && npm shrinkwrap --production" | ||
}, | ||
@@ -42,3 +42,5 @@ "author": "Alex Lapa <deadarius.dendr@gmail.com>", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"confeta-text": "^1.0.3" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4583
1
50
1
+ Addedconfeta-text@^1.0.3
+ Addedconfeta-text@1.0.6(transitive)