Skip to content

Commit

Permalink
fix: updated eslint config, rollup and npm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kouts committed Nov 7, 2022
1 parent 4c9a7a4 commit 21eb6c1
Show file tree
Hide file tree
Showing 18 changed files with 2,480 additions and 2,367 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-kouts/vue2']
extends: ['@kouts/eslint-config/vue2']
}
10 changes: 10 additions & 0 deletions PACKAGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## NPM packages version information

- `@vue/test-utils ^1.3.3 → ^2.2.1`
Needed for Vue 2 compatibility

- `@vue/vue2-jest ^27.0.0 → ^29.2.0`
Needed for @vue/test-utils 1 compatibility

- `vue ^2.6.14 → ^3.2.41`
Needed for IE11 compatibility
4 changes: 1 addition & 3 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var utils = require('./utils-5fd5ff73.js');
var utils = require('./utils-56af9919.js');
var vueSetPath = require('./vueSetPath.js');
require('vue');

Expand Down
5 changes: 0 additions & 5 deletions dist/cjs/utils-5fd5ff73.js → dist/cjs/utils-56af9919.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,24 @@ function splitPath(str) {
var regex = /([\w\s-]+)|\[([^\]]+)\]/g;
var result = [];
var path;

while (path = regex.exec(str || '')) {
if (str[path.index] === '[') {
result.push(path[2]);
} else {
result.push(path[1]);
}
}

return result;
}
function getByPath(obj, path) {
var parts = isArray(path) ? path : splitPath(path);
var length = parts.length;

for (var i = 0; i < length; i++) {
if (typeof obj[parts[i]] === 'undefined') {
return undefined;
}

obj = obj[parts[i]];
}

return obj;
}

Expand Down
4 changes: 1 addition & 3 deletions dist/cjs/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var utils = require('./utils-5fd5ff73.js');
var utils = require('./utils-56af9919.js');



Expand Down
35 changes: 14 additions & 21 deletions dist/cjs/vueSetPath.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,45 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var utils = require('./utils-5fd5ff73.js');
var utils = require('./utils-56af9919.js');
var Vue = require('vue');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

var setOne = function setOne(obj, pathStr, value) {
var path = utils.splitPath(pathStr);
var length = path.length;
var lastIndex = length - 1;

for (var index = 0; index < length; index++) {
var prop = path[index]; // If we are not on the last index
// we start building the data object from the path
var prop = path[index];

// If we are not on the last index
// we start building the data object from the path
if (index !== lastIndex) {
var objValue = obj[prop]; // If objValue exists, is not primitive and is not observable, then make it so using Vue.set
var objValue = obj[prop];

// If objValue exists, is not primitive and is not observable, then make it so using Vue.set
if (objValue && utils._typeof(objValue) === 'object') {
// eslint-disable-next-line no-prototype-builtins
if (!objValue.hasOwnProperty('__ob__')) {
Vue__default["default"].set(obj, prop, objValue);
} // Array to object transformation
Vue.set(obj, prop, objValue);
}
// Array to object transformation
// Check if parent path is an array, we are not on the last item
// and the next key in the path is not a number


if (utils.isArray(objValue) && !utils.isNumeric(path[index + 1])) {
Vue__default["default"].set(obj, prop, {});
Vue.set(obj, prop, {});
}
} else {
// Create an empty object or an empty array based on the next path entry
if (utils.isNumeric(path[index + 1])) {
Vue__default["default"].set(obj, prop, []);
Vue.set(obj, prop, []);
} else {
Vue__default["default"].set(obj, prop, {});
Vue.set(obj, prop, {});
}
}
} else {
// If we are on the last index then we just assign the the value to the data object
// Note: If we used obj[prop] = value; arrays wouldn't be updated.
Vue__default["default"].set(obj, prop, value);
Vue.set(obj, prop, value);
}

obj = obj[prop];
}
};
Expand All @@ -64,7 +57,7 @@ var setMany = function setMany(obj, path, value) {
var deleteOne = function deleteOne(obj, pathStr) {
var path = utils.splitPath(pathStr);
var prop = path.pop();
Vue__default["default"]["delete"](utils.getByPath(obj, path), prop);
Vue["delete"](utils.getByPath(obj, path), prop);
};
var deleteMany = function deleteMany(obj, path) {
if (typeof path === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion dist/es/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { g as getByPath, b as isArray, a as isNumeric, i as isObject, s as splitPath } from './utils-037a2bb8.js';
export { g as getByPath, b as isArray, a as isNumeric, i as isObject, s as splitPath } from './utils-9cb6ed77.js';
export { deleteMany, deleteOne, setMany, setOne } from './vueSetPath.js';
import 'vue';
5 changes: 0 additions & 5 deletions dist/es/utils-037a2bb8.js → dist/es/utils-9cb6ed77.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,24 @@ function splitPath(str) {
var regex = /([\w\s-]+)|\[([^\]]+)\]/g;
var result = [];
var path;

while (path = regex.exec(str || '')) {
if (str[path.index] === '[') {
result.push(path[2]);
} else {
result.push(path[1]);
}
}

return result;
}
function getByPath(obj, path) {
var parts = isArray(path) ? path : splitPath(path);
var length = parts.length;

for (var i = 0; i < length; i++) {
if (typeof obj[parts[i]] === 'undefined') {
return undefined;
}

obj = obj[parts[i]];
}

return obj;
}

Expand Down
2 changes: 1 addition & 1 deletion dist/es/utils.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { g as getByPath, b as isArray, a as isNumeric, i as isObject, s as splitPath } from './utils-037a2bb8.js';
export { g as getByPath, b as isArray, a as isNumeric, i as isObject, s as splitPath } from './utils-9cb6ed77.js';
17 changes: 8 additions & 9 deletions dist/es/vueSetPath.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { s as splitPath, _ as _typeof, b as isArray, a as isNumeric, i as isObject, g as getByPath } from './utils-037a2bb8.js';
import { s as splitPath, _ as _typeof, b as isArray, a as isNumeric, i as isObject, g as getByPath } from './utils-9cb6ed77.js';
import Vue from 'vue';

var setOne = function setOne(obj, pathStr, value) {
var path = splitPath(pathStr);
var length = path.length;
var lastIndex = length - 1;

for (var index = 0; index < length; index++) {
var prop = path[index]; // If we are not on the last index
// we start building the data object from the path
var prop = path[index];

// If we are not on the last index
// we start building the data object from the path
if (index !== lastIndex) {
var objValue = obj[prop]; // If objValue exists, is not primitive and is not observable, then make it so using Vue.set
var objValue = obj[prop];

// If objValue exists, is not primitive and is not observable, then make it so using Vue.set
if (objValue && _typeof(objValue) === 'object') {
// eslint-disable-next-line no-prototype-builtins
if (!objValue.hasOwnProperty('__ob__')) {
Vue.set(obj, prop, objValue);
} // Array to object transformation
}
// Array to object transformation
// Check if parent path is an array, we are not on the last item
// and the next key in the path is not a number


if (isArray(objValue) && !isNumeric(path[index + 1])) {
Vue.set(obj, prop, {});
}
Expand All @@ -38,7 +38,6 @@ var setOne = function setOne(obj, pathStr, value) {
// Note: If we used obj[prop] = value; arrays wouldn't be updated.
Vue.set(obj, prop, value);
}

obj = obj[prop];
}
};
Expand Down
7 changes: 0 additions & 7 deletions dist/umd/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,24 @@
var regex = /([\w\s-]+)|\[([^\]]+)\]/g;
var result = [];
var path;

while (path = regex.exec(str || '')) {
if (str[path.index] === '[') {
result.push(path[2]);
} else {
result.push(path[1]);
}
}

return result;
}
function getByPath(obj, path) {
var parts = isArray(path) ? path : splitPath(path);
var length = parts.length;

for (var i = 0; i < length; i++) {
if (typeof obj[parts[i]] === 'undefined') {
return undefined;
}

obj = obj[parts[i]];
}

return obj;
}

Expand All @@ -59,6 +54,4 @@
exports.isObject = isObject;
exports.splitPath = splitPath;

Object.defineProperty(exports, '__esModule', { value: true });

}));
2 changes: 1 addition & 1 deletion dist/umd/utils.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 13 additions & 25 deletions dist/umd/vueSetPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vueSetPath = {}, global.Vue));
})(this, (function (exports, Vue) { 'use strict';

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

function _typeof(obj) {
"@babel/helpers - typeof";

Expand All @@ -31,70 +27,64 @@
var regex = /([\w\s-]+)|\[([^\]]+)\]/g;
var result = [];
var path;

while (path = regex.exec(str || '')) {
if (str[path.index] === '[') {
result.push(path[2]);
} else {
result.push(path[1]);
}
}

return result;
}
function getByPath(obj, path) {
var parts = isArray(path) ? path : splitPath(path);
var length = parts.length;

for (var i = 0; i < length; i++) {
if (typeof obj[parts[i]] === 'undefined') {
return undefined;
}

obj = obj[parts[i]];
}

return obj;
}

var setOne = function setOne(obj, pathStr, value) {
var path = splitPath(pathStr);
var length = path.length;
var lastIndex = length - 1;

for (var index = 0; index < length; index++) {
var prop = path[index]; // If we are not on the last index
// we start building the data object from the path
var prop = path[index];

// If we are not on the last index
// we start building the data object from the path
if (index !== lastIndex) {
var objValue = obj[prop]; // If objValue exists, is not primitive and is not observable, then make it so using Vue.set
var objValue = obj[prop];

// If objValue exists, is not primitive and is not observable, then make it so using Vue.set
if (objValue && _typeof(objValue) === 'object') {
// eslint-disable-next-line no-prototype-builtins
if (!objValue.hasOwnProperty('__ob__')) {
Vue__default["default"].set(obj, prop, objValue);
} // Array to object transformation
Vue.set(obj, prop, objValue);
}
// Array to object transformation
// Check if parent path is an array, we are not on the last item
// and the next key in the path is not a number


if (isArray(objValue) && !isNumeric(path[index + 1])) {
Vue__default["default"].set(obj, prop, {});
Vue.set(obj, prop, {});
}
} else {
// Create an empty object or an empty array based on the next path entry
if (isNumeric(path[index + 1])) {
Vue__default["default"].set(obj, prop, []);
Vue.set(obj, prop, []);
} else {
Vue__default["default"].set(obj, prop, {});
Vue.set(obj, prop, {});
}
}
} else {
// If we are on the last index then we just assign the the value to the data object
// Note: If we used obj[prop] = value; arrays wouldn't be updated.
Vue__default["default"].set(obj, prop, value);
Vue.set(obj, prop, value);
}

obj = obj[prop];
}
};
Expand All @@ -112,7 +102,7 @@
var deleteOne = function deleteOne(obj, pathStr) {
var path = splitPath(pathStr);
var prop = path.pop();
Vue__default["default"]["delete"](getByPath(obj, path), prop);
Vue["delete"](getByPath(obj, path), prop);
};
var deleteMany = function deleteMany(obj, path) {
if (typeof path === 'string') {
Expand All @@ -131,6 +121,4 @@
exports.setMany = setMany;
exports.setOne = setOne;

Object.defineProperty(exports, '__esModule', { value: true });

}));
2 changes: 1 addition & 1 deletion dist/umd/vueSetPath.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 21eb6c1

Please sign in to comment.