Create utils

This commit is contained in:
Dennis Eichhorn 2017-10-21 18:11:42 +02:00
parent 183503f31c
commit 9c0b0c1d9e
2 changed files with 64 additions and 0 deletions

39
Utils/ArrayUtils.js Normal file
View 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 || {}));

View File

@ -11,6 +11,31 @@
(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[pathParts[key]];
}
return current;
};
/**
* Trim char from string