mirror of https://github.com/node-red/node-red.git
Feat: add `$dayjs` support to JSONata engine.
parent
c3da827222
commit
21d8e9e20e
|
@ -80,7 +80,8 @@
|
|||
"uglify-js": "3.17.4",
|
||||
"uuid": "9.0.1",
|
||||
"ws": "7.5.10",
|
||||
"xml2js": "0.6.2"
|
||||
"xml2js": "0.6.2",
|
||||
"dayjs": "1.11.13"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@node-rs/bcrypt": "1.10.4"
|
||||
|
|
|
@ -270,5 +270,9 @@
|
|||
"$moment": {
|
||||
"args": "[str]",
|
||||
"desc": "Liefert ein `date` Objekt unter Benutzung der Moment Library."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Erhält ein Datumsobjekt mithilfe der dayjs-Bibliothek."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "value",
|
||||
"desc": "Safely clone an object."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Gets a date object using the dayjs library."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "value",
|
||||
"desc": "Clona un objeto de forma segura."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Obtiene un objeto de fecha utilizando la biblioteca dayjs."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "valeur",
|
||||
"desc": "Cloner un objet en toute sécurité."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Obtient un objet date en utilisant la bibliothèque dayjs."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "value",
|
||||
"desc": "オブジェクトを安全に複製します。"
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "dayjsライブラリを使用して日付オブジェクトを取得します。"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,5 +218,9 @@
|
|||
"$env": {
|
||||
"args": "arg",
|
||||
"desc": "환경변수를 값으로 반환합니다.\n\n 이 함수는 Node-RED 정의 함수입니다."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "dayjs 라이브러리를 사용하여 날짜 객체를 가져옵니다."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,5 +270,9 @@
|
|||
"$moment": {
|
||||
"args": "[str]",
|
||||
"desc": "Obtém um objeto de dados usando a biblioteca 'Moment'."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Obtém um objeto de data usando a biblioteca dayjs."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,5 +270,9 @@
|
|||
"$moment": {
|
||||
"args": "[str]",
|
||||
"desc": "Получает date объект, используя библиотеку Moment."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "Получает объект даты, используя библиотеку dayjs."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "value",
|
||||
"desc": "安全克隆对象."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "使用 dayjs 库获取日期对象。"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,5 +274,9 @@
|
|||
"$clone": {
|
||||
"args": "value",
|
||||
"desc": "安全克隆對象."
|
||||
},
|
||||
"$dayjs": {
|
||||
"args": "",
|
||||
"desc": "使用 dayjs 函式庫獲取日期對象。"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@
|
|||
'$clone': { args:[ 'arg' ]},
|
||||
'$contains':{ args:[ 'str', 'pattern' ]},
|
||||
'$count':{ args:[ 'array' ]},
|
||||
'$dayjs':{ args:[ ]},
|
||||
'$decodeUrl':{ args:[ 'str' ]},
|
||||
'$decodeUrlComponent':{ args:[ 'str' ]},
|
||||
'$distinct':{ args:[ 'array' ]},
|
||||
|
|
|
@ -26,6 +26,14 @@ const safeJSONStringify = require("json-stringify-safe");
|
|||
const util = require("util");
|
||||
const { hasOwnProperty } = Object.prototype;
|
||||
const log = require("./log")
|
||||
|
||||
/* dayjs */
|
||||
const dayjs = require("dayjs");
|
||||
const utc = require("dayjs/plugin/utc");
|
||||
const timezone = require("dayjs/plugin/timezone");
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
/**
|
||||
* Safely returns the object constructor name.
|
||||
* @return {String} the name of the object constructor if it exists, empty string otherwise.
|
||||
|
@ -727,6 +735,9 @@ function prepareJSONataExpression(value,node) {
|
|||
expr.assign('moment', function(arg1, arg2, arg3, arg4) {
|
||||
return moment(arg1, arg2, arg3, arg4);
|
||||
});
|
||||
expr.assign('dayjs', function(arg1, arg2, arg3, arg4) {
|
||||
return dayjs(arg1, arg2, arg3, arg4)
|
||||
});
|
||||
expr.registerFunction('clone', cloneMessage, '<(oa)-:o>');
|
||||
expr._legacyMode = /(^|[^a-zA-Z0-9_'".])msg([^a-zA-Z0-9_'"]|$)/.test(value);
|
||||
expr._node = node;
|
||||
|
|
Loading…
Reference in New Issue