mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-16 09:18:42 +00:00
Create utils
This commit is contained in:
parent
183503f31c
commit
9c0b0c1d9e
39
Utils/ArrayUtils.js
Normal file
39
Utils/ArrayUtils.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
* Standard library
|
||||||
|
*
|
||||||
|
* This library provides useful functionalities for the DOM and other manipulations.
|
||||||
|
*
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
(function (jsOMS)
|
||||||
|
{
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim char from string
|
||||||
|
*
|
||||||
|
* @param {string} path Array path
|
||||||
|
* @param {obj} data Object
|
||||||
|
* @param {string} delim Path delimiter
|
||||||
|
*
|
||||||
|
* @return {mixed}
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
jsOMS.getArray = function(path, data, delim)
|
||||||
|
{
|
||||||
|
const pathParts = path.split(delim);
|
||||||
|
let current = data;
|
||||||
|
|
||||||
|
for(let key in pathParts) {
|
||||||
|
current = current[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
};
|
||||||
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
@ -11,6 +11,31 @@
|
||||||
(function (jsOMS)
|
(function (jsOMS)
|
||||||
{
|
{
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim char from string
|
||||||
|
*
|
||||||
|
* @param {string} path Array path
|
||||||
|
* @param {obj} data Object
|
||||||
|
* @param {string} delim Path delimiter
|
||||||
|
*
|
||||||
|
* @return {mixed}
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
jsOMS.getArray = function(path, data, delim)
|
||||||
|
{
|
||||||
|
const pathParts = path.split(delim);
|
||||||
|
let current = data;
|
||||||
|
|
||||||
|
for(let key in pathParts) {
|
||||||
|
current = current[pathParts[key]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trim char from string
|
* Trim char from string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user