@es-git/path-to-object-mixin
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -0,0 +0,0 @@ import { Constructor, Hash } from '@es-git/core'; |
@@ -0,0 +0,0 @@ import { Type, decode } from '@es-git/core'; |
export {}; | ||
//# sourceMappingURL=index.test.d.ts.map |
430
js/index.js
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports["default"] = mixin; | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck")); | ||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _newArrowCheck2 = require("babel-runtime/helpers/newArrowCheck"); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _newArrowCheck3 = _interopRequireDefault(_newArrowCheck2); | ||
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get")); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of"); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _core = require("@es-git/core"); | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
var _createClass2 = require("babel-runtime/helpers/createClass"); | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } | ||
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn"); | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _get2 = require("babel-runtime/helpers/get"); | ||
var _get3 = _interopRequireDefault(_get2); | ||
var _inherits2 = require("babel-runtime/helpers/inherits"); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
exports.default = mixin; | ||
var _core = require("@es-git/core"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function mixin(repo) { | ||
var _this2 = this; | ||
return /*#__PURE__*/function (_repo) { | ||
(0, _inherits2["default"])(PathToObjectRepo, _repo); | ||
return function (_repo) { | ||
(0, _inherits3.default)(PathToObjectRepo, _repo); | ||
var _super = _createSuper(PathToObjectRepo); | ||
function PathToObjectRepo() { | ||
(0, _classCallCheck3.default)(this, PathToObjectRepo); | ||
return (0, _possibleConstructorReturn3.default)(this, (PathToObjectRepo.__proto__ || (0, _getPrototypeOf2.default)(PathToObjectRepo)).apply(this, arguments)); | ||
} | ||
function PathToObjectRepo() { | ||
(0, _classCallCheck2["default"])(this, PathToObjectRepo); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass3.default)(PathToObjectRepo, [{ | ||
key: "loadObjectByPath", | ||
value: function () { | ||
(0, _newArrowCheck3.default)(this, _this2); | ||
(0, _createClass2["default"])(PathToObjectRepo, [{ | ||
key: "loadObjectByPath", | ||
value: function () { | ||
var _loadObjectByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(rootTree, path) { | ||
var _this = this; | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(rootTree, path) { | ||
var hash, parts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, part, object, entry, result; | ||
var hash, parts, _iterator, _step, part, object, entry, result; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
hash = rootTree; | ||
parts = Array.isArray(path) ? path : path.split("/").filter(function (x) { | ||
return x.length > 0; | ||
}); | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context.prev = 5; | ||
_iterator = (0, _getIterator3.default)(parts); | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
hash = rootTree; | ||
parts = Array.isArray(path) ? path : path.split("/").filter(function (x) { | ||
(0, _newArrowCheck2["default"])(this, _this); | ||
return x.length > 0; | ||
}.bind(this)); | ||
_iterator = _createForOfIteratorHelper(parts); | ||
_context.prev = 3; | ||
case 7: | ||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { | ||
_context.next = 31; | ||
break; | ||
} | ||
_iterator.s(); | ||
part = _step.value; | ||
_context.next = 11; | ||
return (0, _get3.default)(PathToObjectRepo.prototype.__proto__ || (0, _getPrototypeOf2.default)(PathToObjectRepo.prototype), "loadObject", this).call(this, hash); | ||
case 5: | ||
if ((_step = _iterator.n()).done) { | ||
_context.next = 28; | ||
break; | ||
} | ||
case 11: | ||
object = _context.sent; | ||
part = _step.value; | ||
_context.next = 9; | ||
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(PathToObjectRepo.prototype), "loadObject", this).call(this, hash); | ||
if (object) { | ||
_context.next = 16; | ||
break; | ||
} | ||
case 9: | ||
object = _context.sent; | ||
throw new Error("Missing object: " + String(hash)); | ||
if (object) { | ||
_context.next = 14; | ||
break; | ||
} | ||
case 16: | ||
if (!(object.type === _core.Type.blob)) { | ||
_context.next = 20; | ||
break; | ||
} | ||
throw new Error("Missing object: ".concat(hash)); | ||
return _context.abrupt("return", undefined); | ||
case 14: | ||
if (!(object.type === _core.Type.blob)) { | ||
_context.next = 18; | ||
break; | ||
} | ||
case 20: | ||
if (!(object.type !== _core.Type.tree)) { | ||
_context.next = 24; | ||
break; | ||
} | ||
return _context.abrupt("return", undefined); | ||
throw new Error("Wrong object: " + String(hash) + ". Expected tree, got " + String(object.type)); | ||
case 18: | ||
if (!(object.type !== _core.Type.tree)) { | ||
_context.next = 22; | ||
break; | ||
} | ||
case 24: | ||
entry = object.body[part]; | ||
throw new Error("Wrong object: ".concat(hash, ". Expected tree, got ").concat(object.type)); | ||
if (entry) { | ||
_context.next = 27; | ||
break; | ||
} | ||
case 22: | ||
entry = object.body[part]; | ||
return _context.abrupt("return", undefined); | ||
if (entry) { | ||
_context.next = 25; | ||
break; | ||
} | ||
case 27: | ||
hash = entry.hash; | ||
return _context.abrupt("return", undefined); | ||
case 28: | ||
_iteratorNormalCompletion = true; | ||
_context.next = 7; | ||
break; | ||
case 25: | ||
hash = entry.hash; | ||
case 31: | ||
_context.next = 37; | ||
break; | ||
case 26: | ||
_context.next = 5; | ||
break; | ||
case 33: | ||
_context.prev = 33; | ||
_context.t0 = _context["catch"](5); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t0; | ||
case 28: | ||
_context.next = 33; | ||
break; | ||
case 37: | ||
_context.prev = 37; | ||
_context.prev = 38; | ||
case 30: | ||
_context.prev = 30; | ||
_context.t0 = _context["catch"](3); | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
_iterator.e(_context.t0); | ||
case 40: | ||
_context.prev = 40; | ||
case 33: | ||
_context.prev = 33; | ||
if (!_didIteratorError) { | ||
_context.next = 43; | ||
break; | ||
} | ||
_iterator.f(); | ||
throw _iteratorError; | ||
return _context.finish(33); | ||
case 43: | ||
return _context.finish(40); | ||
case 36: | ||
_context.next = 38; | ||
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(PathToObjectRepo.prototype), "loadObject", this).call(this, hash); | ||
case 44: | ||
return _context.finish(37); | ||
case 38: | ||
result = _context.sent; | ||
case 45: | ||
_context.next = 47; | ||
return (0, _get3.default)(PathToObjectRepo.prototype.__proto__ || (0, _getPrototypeOf2.default)(PathToObjectRepo.prototype), "loadObject", this).call(this, hash); | ||
if (result) { | ||
_context.next = 41; | ||
break; | ||
} | ||
case 47: | ||
result = _context.sent; | ||
throw new Error("Missing object: ".concat(hash)); | ||
if (result) { | ||
_context.next = 50; | ||
break; | ||
} | ||
case 41: | ||
if (!(result.type != _core.Type.blob && result.type != _core.Type.tree)) { | ||
_context.next = 43; | ||
break; | ||
} | ||
throw new Error("Missing object: " + String(hash)); | ||
throw new Error("Wrong object: ".concat(hash, ". Expected tree or blob, got ").concat(result.type)); | ||
case 50: | ||
if (!(result.type != _core.Type.blob && result.type != _core.Type.tree)) { | ||
_context.next = 52; | ||
break; | ||
} | ||
case 43: | ||
return _context.abrupt("return", result); | ||
throw new Error("Wrong object: " + String(hash) + ". Expected tree or blob, got " + String(result.type)); | ||
case 44: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[3, 30, 33, 36]]); | ||
})); | ||
case 52: | ||
return _context.abrupt("return", result); | ||
function loadObjectByPath(_x, _x2) { | ||
return _loadObjectByPath.apply(this, arguments); | ||
} | ||
case 53: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[5, 33, 37, 45], [38,, 40, 44]]); | ||
})); | ||
return loadObjectByPath; | ||
}() | ||
}, { | ||
key: "loadBlobByPath", | ||
value: function () { | ||
var _loadBlobByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(rootTree, path) { | ||
var object; | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return this.loadObjectByPath(rootTree, path); | ||
function loadObjectByPath(_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
} | ||
case 2: | ||
object = _context2.sent; | ||
return loadObjectByPath; | ||
}.bind(_this2)() | ||
}, { | ||
key: "loadBlobByPath", | ||
value: function () { | ||
(0, _newArrowCheck3.default)(this, _this2); | ||
if (object) { | ||
_context2.next = 5; | ||
break; | ||
} | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(rootTree, path) { | ||
var object; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return this.loadObjectByPath(rootTree, path); | ||
return _context2.abrupt("return", undefined); | ||
case 2: | ||
object = _context2.sent; | ||
case 5: | ||
if (!(object.type !== _core.Type.blob)) { | ||
_context2.next = 7; | ||
break; | ||
} | ||
if (object) { | ||
_context2.next = 5; | ||
break; | ||
} | ||
throw new Error("Wrong object: ".concat(path, ". Expected tree or blob, got ").concat(object.type)); | ||
return _context2.abrupt("return", undefined); | ||
case 7: | ||
return _context2.abrupt("return", object.body); | ||
case 5: | ||
if (!(object.type !== _core.Type.blob)) { | ||
_context2.next = 7; | ||
break; | ||
} | ||
case 8: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
throw new Error("Wrong object: " + String(path) + ". Expected tree or blob, got " + String(object.type)); | ||
function loadBlobByPath(_x3, _x4) { | ||
return _loadBlobByPath.apply(this, arguments); | ||
} | ||
case 7: | ||
return _context2.abrupt("return", object.body); | ||
return loadBlobByPath; | ||
}() | ||
}, { | ||
key: "loadTextByPath", | ||
value: function () { | ||
var _loadTextByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(rootTree, path) { | ||
var blob; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return this.loadBlobByPath(rootTree, path); | ||
case 8: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
case 2: | ||
blob = _context3.sent; | ||
function loadBlobByPath(_x3, _x4) { | ||
return _ref2.apply(this, arguments); | ||
} | ||
if (blob) { | ||
_context3.next = 5; | ||
break; | ||
} | ||
return loadBlobByPath; | ||
}.bind(_this2)() | ||
}, { | ||
key: "loadTextByPath", | ||
value: function () { | ||
(0, _newArrowCheck3.default)(this, _this2); | ||
return _context3.abrupt("return", undefined); | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(rootTree, path) { | ||
var blob; | ||
return _regenerator2.default.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return this.loadBlobByPath(rootTree, path); | ||
case 5: | ||
return _context3.abrupt("return", (0, _core.decode)(blob)); | ||
case 2: | ||
blob = _context3.sent; | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
if (blob) { | ||
_context3.next = 5; | ||
break; | ||
} | ||
function loadTextByPath(_x5, _x6) { | ||
return _loadTextByPath.apply(this, arguments); | ||
} | ||
return _context3.abrupt("return", undefined); | ||
case 5: | ||
return _context3.abrupt("return", (0, _core.decode)(blob)); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function loadTextByPath(_x5, _x6) { | ||
return _ref3.apply(this, arguments); | ||
} | ||
return loadTextByPath; | ||
}.bind(_this2)() | ||
}]); | ||
return PathToObjectRepo; | ||
}(repo); | ||
return loadTextByPath; | ||
}() | ||
}]); | ||
return PathToObjectRepo; | ||
}(repo); | ||
} | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@es-git/path-to-object-mixin", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "", | ||
@@ -9,9 +9,9 @@ "main": "js/index.js", | ||
"scripts": { | ||
"clean": "rm -rf ./es ./js", | ||
"tsc": "../../node_modules/.bin/tsc", | ||
"babel": "../../node_modules/.bin/babel --source-maps -d js es", | ||
"clean": "rimraf ./es ./js", | ||
"tsc": "tsc", | ||
"babel": "babel --root-mode upward --source-maps -d js es", | ||
"compile": "npm run tsc && npm run babel", | ||
"test": "../../node_modules/.bin/ava", | ||
"watch+test": "../../node_modules/.bin/tsc -w & ../../node_modules/.bin/ava -w", | ||
"watch": "../../node_modules/.bin/tsc -w & ../../node_modules/.bin/babel --source-maps -w -d js es", | ||
"test": "jest", | ||
"watch+test": "tsc -w & ava -w", | ||
"watch": "tsc -w & babel --source-maps -w -d js es", | ||
"prepublishOnly": "npm run clean && npm run compile && npm test" | ||
@@ -25,23 +25,10 @@ }, | ||
"license": "MIT", | ||
"ava": { | ||
"files": [ | ||
"es/*.test.js" | ||
], | ||
"source": [ | ||
"es/*.js" | ||
], | ||
"require": [ | ||
"babel-register" | ||
], | ||
"babel": { | ||
"extends": "../../.babelrc" | ||
} | ||
}, | ||
"peerDependencies": { | ||
"babel-runtime": "^6.22.0" | ||
"@babel/runtime": "^7.12.5" | ||
}, | ||
"dependencies": { | ||
"@es-git/core": "^0.9.0", | ||
"@es-git/object-mixin": "^0.9.0" | ||
} | ||
"@es-git/core": "^0.10.0", | ||
"@es-git/object-mixin": "^0.10.0" | ||
}, | ||
"gitHead": "5939f07143e0b8aa67d7464e6ec47754bebab347" | ||
} |
@@ -0,0 +0,0 @@ # path-to-object-mixin |
@@ -0,0 +0,0 @@ import { Type, Constructor, Hash, decode } from '@es-git/core'; |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16
52427
330
+ Added@babel/runtime@7.26.0(transitive)
+ Added@es-git/core@0.10.0(transitive)
+ Added@es-git/mix@0.10.0(transitive)
+ Added@es-git/object-mixin@0.10.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedtext-encoding-utf-8@1.0.2(transitive)
- Removed@es-git/core@0.9.0(transitive)
- Removed@es-git/mix@0.9.0(transitive)
- Removed@es-git/object-mixin@0.9.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedtext-encoding@0.6.4(transitive)
Updated@es-git/core@^0.10.0
Updated@es-git/object-mixin@^0.10.0