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
Loading items

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
Loading items
Show changes
Commits on Source (4)
<a name="v3.19.0"></a>
## [v3.19.0] - 2023-03-01
### Add Features
- new datetime and currency
<a name="v3.18.0"></a> <a name="v3.18.0"></a>
## [v3.18.0] - 2023-02-28 ## [v3.18.0] - 2023-02-28
### Add Features ### Add Features
...@@ -350,6 +356,7 @@ ...@@ -350,6 +356,7 @@
<a name="1.8.0"></a> <a name="1.8.0"></a>
## 1.8.0 - 2021-08-15 ## 1.8.0 - 2021-08-15
[v3.19.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.18.0...v3.19.0
[v3.18.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.17.0...v3.18.0 [v3.18.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.17.0...v3.18.0
[v3.17.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.16.1...v3.17.0 [v3.17.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.16.1...v3.17.0
[v3.16.1]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.16.0...v3.16.1 [v3.16.1]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.16.0...v3.16.1
......
{ {
"name": "@schukai/monster", "name": "@schukai/monster",
"version": "3.17.0", "version": "3.18.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.", "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [ "keywords": [
"framework", "framework",
......
...@@ -576,6 +576,32 @@ function transform(value) { ...@@ -576,6 +576,32 @@ function transform(value) {
return map.get(value); return map.get(value);
case "money":
case "currency":
try {
locale = getLocaleOfDocument();
} catch (e) {
throw new Error("unsupported locale or missing format (" + e.message + ")");
}
const currency = value.substring(0, 3);
if(!currency) {
throw new Error("missing currency parameter");
}
const maximumFractionDigits = args?.[0] || 2;
const roundingIncrement = args?.[1] || 5;
const nf = new Intl.NumberFormat(locale, {
style: "currency",
currency: currency,
maximumFractionDigits: maximumFractionDigits,
roundingIncrement: roundingIncrement,
});
return nf.format(value.substring(3));
case "timestamp": case "timestamp":
date = new Date(value); date = new Date(value);
timestamp = date.getTime(); timestamp = date.getTime();
...@@ -598,6 +624,34 @@ function transform(value) { ...@@ -598,6 +624,34 @@ function transform(value) {
throw new Error("unsupported locale or missing format (" + e.message + ")"); throw new Error("unsupported locale or missing format (" + e.message + ")");
} }
case "datetime":
date = new Date(value);
if (isNaN(date.getTime())) {
throw new Error("invalid date");
}
try {
locale = getLocaleOfDocument();
return date.toLocaleString(locale);
} catch (e) {
throw new Error("unsupported locale or missing format (" + e.message + ")");
}
case "date":
date = new Date(value);
if (isNaN(date.getTime())) {
throw new Error("invalid date");
}
try {
locale = getLocaleOfDocument();
return date.toLocaleDateString(locale);
} catch (e) {
throw new Error("unsupported locale or missing format (" + e.message + ")");
}
case "year": case "year":
date = new Date(value); date = new Date(value);
...@@ -658,20 +712,6 @@ function transform(value) { ...@@ -658,20 +712,6 @@ function transform(value) {
return date.getSeconds(); return date.getSeconds();
case "date":
date = new Date(value);
if (isNaN(date.getTime())) {
throw new Error("invalid date");
}
try {
locale = getLocaleOfDocument();
return date.toLocaleDateString(locale);
} catch (e) {
throw new Error("unsupported locale or missing format (" + e.message + ")");
}
case "i18n": case "i18n":
case "translation": case "translation":
translations = getDocumentTranslations(); translations = getDocumentTranslations();
......
...@@ -142,7 +142,7 @@ function getMonsterVersion() { ...@@ -142,7 +142,7 @@ function getMonsterVersion() {
} }
/** don't touch, replaced by make with package.json version */ /** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.17.0"); monsterVersion = new Version("3.18.0");
return monsterVersion; return monsterVersion;
} }
{ {
"name": "monster", "name": "monster",
"version": "3.17.0", "version": "3.18.0",
"description": "monster", "description": "monster",
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"esbuild": "^0.17.10", "esbuild": "^0.17.10",
"flow-bin": "^0.200.1", "flow-bin": "^0.200.1",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"glob": "^9.0.1", "glob": "^9.1.0",
"graphviz": "^0.0.9", "graphviz": "^0.0.9",
"jsdoc": "^4.0.2", "jsdoc": "^4.0.2",
"jsdoc-external-example": "github:volker-schukai/jsdoc-external-example", "jsdoc-external-example": "github:volker-schukai/jsdoc-external-example",
......
...@@ -16,7 +16,7 @@ specifiers: ...@@ -16,7 +16,7 @@ specifiers:
esbuild: ^0.17.10 esbuild: ^0.17.10
flow-bin: ^0.200.1 flow-bin: ^0.200.1
fs: 0.0.1-security fs: 0.0.1-security
glob: ^9.0.1 glob: ^9.1.0
graphviz: ^0.0.9 graphviz: ^0.0.9
jsdoc: ^4.0.2 jsdoc: ^4.0.2
jsdoc-external-example: github:volker-schukai/jsdoc-external-example jsdoc-external-example: github:volker-schukai/jsdoc-external-example
...@@ -65,7 +65,7 @@ devDependencies: ...@@ -65,7 +65,7 @@ devDependencies:
esbuild: 0.17.10 esbuild: 0.17.10
flow-bin: 0.200.1 flow-bin: 0.200.1
fs: 0.0.1-security fs: 0.0.1-security
glob: 9.0.1 glob: 9.1.0
graphviz: 0.0.9 graphviz: 0.0.9
jsdoc: 4.0.2 jsdoc: 4.0.2
jsdoc-external-example: github.com/volker-schukai/jsdoc-external-example/e039186b531487bd1b1d5e2e1586a396b910c9d9 jsdoc-external-example: github.com/volker-schukai/jsdoc-external-example/e039186b531487bd1b1d5e2e1586a396b910c9d9
...@@ -791,8 +791,8 @@ packages: ...@@ -791,8 +791,8 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.14 '@jridgewell/sourcemap-codec': 1.4.14
dev: true dev: true
/@jsdoc/salty/0.2.3: /@jsdoc/salty/0.2.4:
resolution: {integrity: sha512-bbtCxCkxcnWhi50I+4Lj6mdz9w3pOXOgEQrID8TCZ/DF51fW7M9GCQW2y45SpBDdHd1Eirm1X/Cf6CkAAe8HPg==} resolution: {integrity: sha512-HRBmslXHM6kpZOfGf0o41NUlGYGER0NoUBcT2Sik4rxzAN7f7+si7ad57SFSFpftvaMVnUaY7YlJuv3v5G80ZA==}
engines: {node: '>=v12.0.0'} engines: {node: '>=v12.0.0'}
dependencies: dependencies:
lodash: 4.17.21 lodash: 4.17.21
...@@ -1454,7 +1454,7 @@ packages: ...@@ -1454,7 +1454,7 @@ packages:
hasBin: true hasBin: true
dependencies: dependencies:
caniuse-lite: 1.0.30001458 caniuse-lite: 1.0.30001458
electron-to-chromium: 1.4.313 electron-to-chromium: 1.4.314
node-releases: 2.0.10 node-releases: 2.0.10
update-browserslist-db: 1.0.10_browserslist@4.21.5 update-browserslist-db: 1.0.10_browserslist@4.21.5
dev: true dev: true
...@@ -1634,7 +1634,7 @@ packages: ...@@ -1634,7 +1634,7 @@ packages:
peerDependencies: peerDependencies:
jsdoc: '>=3.x <=4.x' jsdoc: '>=3.x <=4.x'
dependencies: dependencies:
'@jsdoc/salty': 0.2.3 '@jsdoc/salty': 0.2.4
fs-extra: 10.1.0 fs-extra: 10.1.0
html-minifier: 4.0.0 html-minifier: 4.0.0
jsdoc: 4.0.2 jsdoc: 4.0.2
...@@ -1750,7 +1750,7 @@ packages: ...@@ -1750,7 +1750,7 @@ packages:
execa: 4.1.0 execa: 4.1.0
polyfill-library: 3.111.0 polyfill-library: 3.111.0
semver: 7.3.8 semver: 7.3.8
snyk: 1.1109.0 snyk: 1.1110.0
yargs: 15.4.1 yargs: 15.4.1
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -2012,8 +2012,8 @@ packages: ...@@ -2012,8 +2012,8 @@ packages:
tslib: 2.5.0 tslib: 2.5.0
dev: true dev: true
/electron-to-chromium/1.4.313: /electron-to-chromium/1.4.314:
resolution: {integrity: sha512-QckB9OVqr2oybjIrbMI99uF+b9+iTja5weFe0ePbqLb5BHqXOJUO1SG6kDj/1WtWPRIBr51N153AEq8m7HuIaA==} resolution: {integrity: sha512-+3RmNVx9hZLlc0gW//4yep0K5SYKmIvB5DXg1Yg6varsuAHlHwTeqeygfS8DWwLCsNOWrgj+p9qgM5WYjw1lXQ==}
dev: true dev: true
/emoji-regex/7.0.3: /emoji-regex/7.0.3:
...@@ -2408,12 +2408,12 @@ packages: ...@@ -2408,12 +2408,12 @@ packages:
path-is-absolute: 1.0.1 path-is-absolute: 1.0.1
dev: true dev: true
/glob/9.0.1: /glob/9.1.0:
resolution: {integrity: sha512-psRdn8MI0gRcH0xow0VOhYxXD/6ZaRGmgtfN0oWN/hCgjxpRQBMCl7wE4JRJSAUTdJsW+FmD0EtE0CgJhKqSVw==} resolution: {integrity: sha512-bAnZn/xYN7o43Y97vDipnunJtQOOhJAyt7/zt1HrzFgtIrol4eJTUn8Kd74B1cMyOBuzWUMvBr2F178h0UQuUw==}
engines: {node: '>=16 || 14 >=14.17'} engines: {node: '>=16 || 14 >=14.17'}
dependencies: dependencies:
fs.realpath: 1.0.0 fs.realpath: 1.0.0
minimatch: 7.3.0 minimatch: 7.4.1
minipass: 4.2.4 minipass: 4.2.4
path-scurry: 1.5.0 path-scurry: 1.5.0
dev: true dev: true
...@@ -2751,7 +2751,7 @@ packages: ...@@ -2751,7 +2751,7 @@ packages:
hasBin: true hasBin: true
dependencies: dependencies:
'@babel/parser': 7.21.2 '@babel/parser': 7.21.2
'@jsdoc/salty': 0.2.3 '@jsdoc/salty': 0.2.4
'@types/markdown-it': 12.2.3 '@types/markdown-it': 12.2.3
bluebird: 3.7.2 bluebird: 3.7.2
catharsis: 0.9.0 catharsis: 0.9.0
...@@ -2984,8 +2984,8 @@ packages: ...@@ -2984,8 +2984,8 @@ packages:
yallist: 4.0.0 yallist: 4.0.0
dev: true dev: true
/lru-cache/7.17.0: /lru-cache/7.18.1:
resolution: {integrity: sha512-zSxlVVwOabhVyTi6E8gYv2cr6bXK+8ifYz5/uyJb9feXX6NACVDwY4p5Ut3WC3Ivo/QhpARHU3iujx2xGAYHbQ==} resolution: {integrity: sha512-8/HcIENyQnfUTCDizRu9rrDyG6XG/21M4X7/YEGZeD76ZJilFPAUVb/2zysFf7VVO1LEjCDFyHp8pMMvozIrvg==}
engines: {node: '>=12'} engines: {node: '>=12'}
dev: true dev: true
...@@ -3085,8 +3085,8 @@ packages: ...@@ -3085,8 +3085,8 @@ packages:
brace-expansion: 2.0.1 brace-expansion: 2.0.1
dev: true dev: true
/minimatch/7.3.0: /minimatch/7.4.1:
resolution: {integrity: sha512-WaMDuhKa7a6zKiwplR1AOz+zGvJba24k5VU1Cy6NhEguavT2YRlHxuINUgTas4wiS6fwBpYq4TcA1XIECSntyw==} resolution: {integrity: sha512-Oz1iPEP+MGl7KS3SciLsLLcuZ7VsBfb7Qrz/jYt/s/sYAv272P26HSLz2f77Y6hzTKXiBi6g765fqpEDNc5fJw==}
engines: {node: '>=10'} engines: {node: '>=10'}
dependencies: dependencies:
brace-expansion: 2.0.1 brace-expansion: 2.0.1
...@@ -3406,7 +3406,7 @@ packages: ...@@ -3406,7 +3406,7 @@ packages:
resolution: {integrity: sha512-hJ8rODLI9B2qwsYAd32rrI76gwVUPeu5kq/do6URDj2bJCVH3ilyT978Mv/NLuFMaqzHrn3XtiDLMZHaTTh4vA==} resolution: {integrity: sha512-hJ8rODLI9B2qwsYAd32rrI76gwVUPeu5kq/do6URDj2bJCVH3ilyT978Mv/NLuFMaqzHrn3XtiDLMZHaTTh4vA==}
engines: {node: '>=14'} engines: {node: '>=14'}
dependencies: dependencies:
lru-cache: 7.17.0 lru-cache: 7.18.1
minipass: 4.2.4 minipass: 4.2.4
dev: true dev: true
...@@ -4191,8 +4191,8 @@ packages: ...@@ -4191,8 +4191,8 @@ packages:
supports-color: 7.2.0 supports-color: 7.2.0
dev: true dev: true
/snyk/1.1109.0: /snyk/1.1110.0:
resolution: {integrity: sha512-sBcibkAfcq6nXr6t0GieDjdc8kQfEf429+M1VKavGfLaJPQNIqSjtOhQJ5FcZqaB/mCWa1szektkHeyAiB4m9A==} resolution: {integrity: sha512-rmyaxtEesqEPQOLeWcX7R9duOxNUKfP1ypX6/XaXxQRduvj7S+P6qXCIpZuJIcR3fnnN/jNbvY6WR+sdc2uqxA==}
engines: {node: '>=12'} engines: {node: '>=12'}
hasBin: true hasBin: true
dev: true dev: true
......
...@@ -28,6 +28,10 @@ describe('Transformer', function () { ...@@ -28,6 +28,10 @@ describe('Transformer', function () {
describe('Transformer.run()', function () { describe('Transformer.run()', function () {
[ [
['currency:1:2', "EUR14.25", "14,2 €"],
['currency', "EUR14.25", "14,25 €"],
['datetime', "2023-02-14 14:12:10", "14.2.2023, 14:12:10"],
['datetime', "2023-02-14 08:02:01", "14.2.2023, 08:02:01"],
['has-entries', {}, false], ['has-entries', {}, false],
['has-entries', {a:4}, true], ['has-entries', {a:4}, true],
['has-entries', [], false], ['has-entries', [], false],
......
...@@ -7,7 +7,7 @@ describe('Monster', function () { ...@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion let monsterVersion
/** don´t touch, replaced by make with package.json version */ /** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.17.0") monsterVersion = new Version("3.18.0")
let m = getMonsterVersion(); let m = getMonsterVersion();
......
{"version":"3.18.0"} {"version":"3.19.0"}