Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1.31
  • master
  • 1.10.0
  • 1.30.1
  • 1.31.0
  • 1.8.0
  • 1.9.0
  • 3.100.0
  • 3.100.1
  • 3.100.10
  • 3.100.11
  • 3.100.12
  • 3.100.13
  • 3.100.14
  • 3.100.15
  • 3.100.16
  • 3.100.17
  • 3.100.18
  • 3.100.19
  • 3.100.2
  • 3.100.20
  • 3.100.3
  • 3.100.4
  • 3.100.5
  • 3.100.6
  • 3.100.7
  • 3.100.8
  • 3.100.9
  • 3.101.0
  • 3.101.1
  • 3.101.2
  • 3.101.3
  • 3.102.0
  • 3.102.1
  • 3.102.2
  • 3.102.3
  • 3.102.4
  • 3.102.5
  • 3.102.6
  • 3.103.0
  • 3.103.1
  • 3.104.0
  • 3.104.1
  • 3.105.0
  • 3.105.1
  • 3.105.2
  • 3.106.0
  • 3.106.1
  • 3.107.0
  • 3.108.0
  • 3.108.1
  • 3.108.2
  • 3.108.3
  • 3.108.4
  • 3.108.5
  • 3.109.0
  • 3.110.0
  • 3.110.1
  • 3.110.2
  • 3.110.3
  • 3.110.4
  • 3.111.0
  • 3.112.0
  • 3.112.1
  • 3.112.2
  • 3.112.3
  • 3.112.4
  • 3.113.0
  • 3.114.0
  • 3.114.1
  • 3.114.2
  • 3.114.3
  • 3.114.4
  • 3.114.5
  • 3.114.6
  • 3.114.7
  • 3.115.0
  • 3.115.1
  • 3.115.2
  • 3.115.3
  • 3.115.4
  • 3.116.0
  • 3.116.1
  • 3.117.0
  • 3.117.1
  • 3.117.2
  • 3.117.3
  • 3.118.0
  • 3.118.1
  • 3.119.0
  • 3.120.0
  • 3.121.0
  • 3.51.5
  • 3.52.0
  • 3.52.1
  • 3.53.0
  • 3.54.0
  • 3.55.0
  • 3.55.1
  • 3.55.2
  • 3.55.3
  • 3.55.4
102 results

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
  • 1.31
  • master
  • 1.10.0
  • 1.30.1
  • 1.31.0
  • 1.8.0
  • 1.9.0
  • 3.100.0
  • 3.100.1
  • 3.100.10
  • 3.100.11
  • 3.100.12
  • 3.100.13
  • 3.100.14
  • 3.100.15
  • 3.100.16
  • 3.100.17
  • 3.100.18
  • 3.100.19
  • 3.100.2
  • 3.100.20
  • 3.100.3
  • 3.100.4
  • 3.100.5
  • 3.100.6
  • 3.100.7
  • 3.100.8
  • 3.100.9
  • 3.101.0
  • 3.101.1
  • 3.101.2
  • 3.101.3
  • 3.102.0
  • 3.102.1
  • 3.102.2
  • 3.102.3
  • 3.102.4
  • 3.102.5
  • 3.102.6
  • 3.103.0
  • 3.103.1
  • 3.104.0
  • 3.104.1
  • 3.105.0
  • 3.105.1
  • 3.105.2
  • 3.106.0
  • 3.106.1
  • 3.107.0
  • 3.108.0
  • 3.108.1
  • 3.108.2
  • 3.108.3
  • 3.108.4
  • 3.108.5
  • 3.109.0
  • 3.110.0
  • 3.110.1
  • 3.110.2
  • 3.110.3
  • 3.110.4
  • 3.111.0
  • 3.112.0
  • 3.112.1
  • 3.112.2
  • 3.112.3
  • 3.112.4
  • 3.113.0
  • 3.114.0
  • 3.114.1
  • 3.114.2
  • 3.114.3
  • 3.114.4
  • 3.114.5
  • 3.114.6
  • 3.114.7
  • 3.115.0
  • 3.115.1
  • 3.115.2
  • 3.115.3
  • 3.115.4
  • 3.116.0
  • 3.116.1
  • 3.117.0
  • 3.117.1
  • 3.117.2
  • 3.117.3
  • 3.118.0
  • 3.118.1
  • 3.119.0
  • 3.120.0
  • 3.121.0
  • 3.51.5
  • 3.52.0
  • 3.52.1
  • 3.53.0
  • 3.54.0
  • 3.55.0
  • 3.55.1
  • 3.55.2
  • 3.55.3
  • 3.55.4
102 results
Show changes
Commits on Source (7)
<a name="v3.8.0"></a>
## [v3.8.0] - 2023-02-01
### Add Features
- pathfinder now works with array
### Changes
- code format (rome)
- doc
- docs
<a name="v3.7.0"></a>
## [v3.7.0] - 2023-01-26
### Bug Fixes
......@@ -218,6 +229,7 @@
<a name="1.8.0"></a>
## 1.8.0 - 2021-08-15
[v3.8.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.7.0...v3.8.0
[v3.7.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.6.0...v3.7.0
[v3.6.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.5.0...v3.6.0
[v3.5.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.4.2...v3.5.0
......
{
"name": "@schukai/monster",
"version": "3.5.0",
"version": "3.7.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......
......@@ -6,9 +6,9 @@
*/
import { Base } from "../types/base.mjs";
import { isArray, isInteger, isObject, isPrimitive } from "../types/is.mjs";
import { isArray, isInteger, isObject, isPrimitive, isString } from "../types/is.mjs";
import { Stack } from "../types/stack.mjs";
import { validateInteger, validateString } from "../types/validate.mjs";
import { validateInteger, validateBoolean, validateString } from "../types/validate.mjs";
export { Pathfinder, DELIMITER, WILDCARD };
......@@ -103,7 +103,7 @@ class Pathfinder extends Base {
/**
*
* @param {string} path
* @param {string|array} path
* @since 1.4.0
* @returns {*}
* @throws {TypeError} unsupported type
......@@ -113,12 +113,12 @@ class Pathfinder extends Base {
* @throws {Error} unsupported action for this data type
*/
getVia(path) {
return getValueViaPath.call(this, this.object, validateString(path));
return getValueViaPath.call(this, this.object, path);
}
/**
*
* @param {string} path
* @param {string|array} path
* @param {*} value
* @returns {Pathfinder}
* @since 1.4.0
......@@ -128,7 +128,6 @@ class Pathfinder extends Base {
* @throws {Error} unsupported action for this data type
*/
setVia(path, value) {
validateString(path);
setValueViaPath.call(this, this.object, path, value);
return this;
}
......@@ -136,7 +135,7 @@ class Pathfinder extends Base {
/**
* Delete Via Path
*
* @param {string} path
* @param {string|array} path
* @returns {Pathfinder}
* @since 1.6.0
* @throws {TypeError} unsupported type
......@@ -145,14 +144,13 @@ class Pathfinder extends Base {
* @throws {Error} unsupported action for this data type
*/
deleteVia(path) {
validateString(path);
deleteValueViaPath.call(this, this.object, path);
return this;
}
/**
*
* @param {string} path
* @param {string|array} path
* @return {bool}
* @throws {TypeError} unsupported type
* @throws {TypeError} value is not a string
......@@ -160,7 +158,6 @@ class Pathfinder extends Base {
* @since 1.4.0
*/
exists(path) {
validateString(path);
try {
getValueViaPath.call(this, this.object, path, true);
return true;
......@@ -173,8 +170,8 @@ class Pathfinder extends Base {
/**
*
* @param {*} subject
* @param {string} path
* @param {string} check
* @param {string|array} path
* @param {boolean} check
* @return {Map}
* @throws {TypeError} unsupported type
* @throws {Error} the journey is not at its end
......@@ -182,8 +179,17 @@ class Pathfinder extends Base {
* @private
*/
function iterate(subject, path, check) {
if (check === undefined) {
check = false;
}
validateBoolean(check);
const result = new Map();
if (isArray(path)) {
path = path.join(DELIMITER);
}
if (isObject(subject) || isArray(subject)) {
for (const [key, value] of Object.entries(subject)) {
result.set(key, getValueViaPath.call(this, value, path, check));
......@@ -199,7 +205,7 @@ function iterate(subject, path, check) {
/**
*
* @param {*} subject
* @param [string} path
* @param [string|array} path
* @param [boolean} check
* @returns {*}
* @throws {TypeError} unsupported type
......@@ -208,11 +214,24 @@ function iterate(subject, path, check) {
* @private
*/
function getValueViaPath(subject, path, check) {
if (check === undefined) {
check = false;
}
validateBoolean(check);
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
}
let parts;
if (isString(path)) {
if (path === "") {
return subject;
}
let parts = path.split(DELIMITER);
parts = path.split(DELIMITER);
}
let current = parts.shift();
if (current === this.wildCard) {
......@@ -261,9 +280,9 @@ function getValueViaPath(subject, path, check) {
/**
*
* @param object
* @param path
* @param value
* @param {object} subject
* @param {string|array} path
* @param {*} value
* @returns {void}
* @throws {TypeError} unsupported type
* @throws {TypeError} unsupported type
......@@ -271,10 +290,22 @@ function getValueViaPath(subject, path, check) {
* @throws {Error} unsupported action for this data type
* @private
*/
function setValueViaPath(object, path, value) {
validateString(path);
function setValueViaPath(subject, path, value) {
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
}
let parts;
if (isArray(path)) {
if (path.length === 0) {
return subject;
}
parts = path;
} else {
parts = path.split(DELIMITER);
}
let parts = path.split(DELIMITER);
let last = parts.pop();
let subpath = parts.join(DELIMITER);
......@@ -282,7 +313,7 @@ function setValueViaPath(object, path, value) {
let current = subpath;
while (true) {
try {
getValueViaPath.call(this, object, current, true);
getValueViaPath.call(this, subject, current, true);
break;
} catch (e) {}
......@@ -304,13 +335,13 @@ function setValueViaPath(object, path, value) {
}
}
setValueViaPath.call(this, object, current, obj);
setValueViaPath.call(this, subject, current, obj);
}
let anchor = getValueViaPath.call(this, object, subpath);
let anchor = getValueViaPath.call(this, subject, subpath);
if (!(isObject(object) || isArray(object))) {
throw TypeError(`unsupported type: ${typeof object}`);
if (!(isObject(subject) || isArray(subject))) {
throw TypeError(`unsupported type: ${typeof subject}`);
}
if (anchor instanceof Map || anchor instanceof WeakMap) {
......@@ -349,8 +380,8 @@ function assignProperty(object, key, value) {
/**
*
* @param object
* @param path
* @param {object} subject
* @param {string} path
* @returns {void}
* @throws {TypeError} unsupported type
* @throws {TypeError} unsupported type
......@@ -360,12 +391,26 @@ function assignProperty(object, key, value) {
* @since 1.6.0
* @private
*/
function deleteValueViaPath(object, path) {
const parts = path.split(DELIMITER);
function deleteValueViaPath(subject, path) {
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
}
let parts;
if (isArray(path)) {
if (path.length === 0) {
return subject;
}
parts = path;
} else {
parts = path.split(DELIMITER);
}
let last = parts.pop();
const subpath = parts.join(DELIMITER);
const anchor = getValueViaPath.call(this, object, subpath);
const anchor = getValueViaPath.call(this, subject, subpath);
if (anchor instanceof Map) {
anchor.delete(last);
......
......@@ -20,12 +20,13 @@ const DEFAULT_LANGUAGE = "en";
/**
* With this function you can read the language version set by the document.
* For this the attribute `lang` in the html tag is read. If no attribute is set, `en` is used as default.
* Alternatively, the language version of the browser is used.
*
* ```html
* <html lang="en">
* ```
*
* You can call the function via the monster namespace `new Monster.DOM.getLocaleOfDocument()`.
* You can call the function via `getLocaleOfDocument()`.
*
* @license AGPLv3
* @since 1.13.0
......
......@@ -182,22 +182,11 @@ class Locale extends Base {
*
* Limitations: The regex cannot handle multiple variants or private.
*
* You can call the method via the monster namespace `Monster.I18n.createLocale()`.
* You can call the method via this function individually:
*
* ```
* <script type="module">
* import {Monster} from '@schukai/monster/source/monster.mjs';
* new Monster.I18n.createLocale()
* </script>
* ```
*
* Alternatively, you can also integrate this function individually.
*
* ```
* <script type="module">
* ```javascript
* import {createLocale} from '@schukai/monster/source/i18n/locale.mjs';
* createLocale()
* </script>
* ```
*
* RFC
......
......@@ -112,9 +112,9 @@ class Translations extends Base {
* Set a text for a key
*
* ```
* translations.setText("text1": "Make my day!");
* translations.setText("text1", "Make my day!");
* // plural rules
* translations.setText("text6": {
* translations.setText("text6", {
* "zero": "There are no files on Disk.",
* "one": "There is one file on Disk.",
* "other": "There are files on Disk."
......
......@@ -142,7 +142,7 @@ function getMonsterVersion() {
}
/** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.5.0");
monsterVersion = new Version("3.7.0");
return monsterVersion;
}
{
"name": "monster",
"version": "3.5.0",
"version": "3.7.0",
"description": "monster",
"repository": {
"type": "git",
......
......@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion
/** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.5.0")
monsterVersion = new Version("3.7.0")
let m = getMonsterVersion();
......
{"version":"3.7.0"}
{"version":"3.8.0"}