Standard JS Built-in Function
TapData Cloud offers you cloud services that are suitable for scenarios requiring rapid deployment and low initial investment, helping you focus more on business development rather than infrastructure management. Free trial with TapData Cloud.TapData Enterprise can be deployed in your local data center, making it suitable for scenarios with strict requirements on data sensitivity or network isolation. It can serve to build real-time data warehouses, enable real-time data exchange, data migration, and more.TapData Community is an open-source data integration platform that provides basic data synchronization and transformation capabilities. This helps you quickly explore and implement data integration projects. As your project or business grows, you can seamlessly upgrade to TapData Cloud or TapData Enterprise to access more advanced features and service support.Standard JS nodes can only process and operate on data records. If you require the usage of system built-in functions for external calls, such as networking or database operations, you can utilize enhanced JS nodes.
For information on how to use and scenarios, see JS processing node.
DateUtilβ
parseβ
Description: Converts date strings in various formats to Date.
Example:
General Usage
var dte = DateUtil.parse('2010-01-01 00:00:00');
Advanced usage:
parse(dateString, timeoffset)
, that is, specify the time zone offset while converting.// UTC+08:00
var dte = DateUtil.parse('2010-01-01 00:00:00', 8);
// UTC+0
var dte = DateUtil.parse('2010-01-01 00:00:00', 0);
determineDateFormatβ
Description: Get the date format.
Example:
var format = DateUtil.determineDateFormat('2010-01-01 00:00:00');
timeStamp2Dateβ
Description: Converts the timestamp to a date string in the specified format.
Example:
var dteStr = DateUtil.timeStamp2Date(1592233019140, 'yyyy-MM-dd HH:mm:ss');
addYears/addMonths/addDays/addHours/addMinutes/addSecondsβ
Description: Adds or subtracts the year/month/day/hour/minute/second of the date.
Example:
var dte = DateUtil.addYears(new Date(), 1);
dte = DateUtil.addYears(dte, -1);
sameYear/sameMonth/sameDay/sameHour/sameMinute/sameSecondβ
Description: Compares the year/month/day/hour/minute/second of the date.
Example:
if ( DataUtil.sameYear(new Date(), new Date()) ) {
...
}
idGen/UUIDGeneratorβ
uuidβ
Description: Generate uuid, if you use var str = uuid();
, you can get a random string.
Example:
// Both methods below are available
var uuid = idGen.uuid();
var uuid = UUIDGenerator.uuid();
objectIdβ
Description: Generate MongoDB ObjectId.
Example:
// Both methods below are available
var oid = idGen.objectId();
var oid = UUIDGenerator.objectId();
objectIdStrβ
Description: Generate MongoDB ObjectId String section.
Example:
// Both methods below are available
var oidStr = idGen.objectIdStr();
var oidStr = UUIDGenerator.objectIdStr();
HashMapβ
put/removeβ
Description: Hash dictionary.
Example:
var map = new HashMap();
map.put(βnameβ, βtestβ);
map.remove(βnameβ);
ArrayListβ
add/removeβ
Description: Array type.
Example:
var list = new ArrayList();
list.add(βtest1β);
list.remove(0);
Dateβ
add/removeβ
Description: Date type.
Example:
var dte = new Date();
var year = dte.getYear()+1900;
JSONUtilβ
json2List/obj2Json/obj2JsonPretty/json2Mapβ
Description: JSON format conversion.
Example:
var d = new Date();
var json = JSONUtil.obj2Json(d)
HanLPUtilβ
hanLPParticipleβ
Description: Chinese word segmentation tool, two parameters need to be set in parentheses, the format is (String inputString, String language)
.
Example:
var d = HanLPUtil.hanLPParticiple('δ½ ε₯½', 'HK_T')
Parameter Description
inputString: A string that requires word segmentation.
language: the type of the language with the word segmentation, support:
CH_S: Simplified Chinese.
CH_T: Traditional Chinese.
HK_T: Traditional Chinese (Hong Kong).
TW_T: Traditional Chinese (Taiwan).
Returns: Array type, that is, the result set after word segmentation.
split_chineseβ
Description: Chinese word segmentation tool, two parameters need to be set in parentheses, the format is (String inputString, String language)
.
Example:
var strs = split_chinese("θΏζ―δΈδΈͺδΈζε₯ε", "CH_S");
Parameter Description
inputString: A string that requires word segmentation.
language: the type of the language with the word segmentation, support:
CH_S: Simplified Chinese.
CH_T: Traditional Chinese.
HK_T: Traditional Chinese (Hong Kong).
TW_T: Traditional Chinese (Taiwan).
Returns: Array type, that is, the result set after word segmentation.
utilβ
strToBase64/base64ToStr/unwindβ
Description: String format conversion.
Example:
// Convert the string to Base64 format
var b = util.strToBase64('aa');
// Split JSON arrays into hierarchy levels
var list = util.unwind(map, 'a.b.c');
MD5Util/MD5β
Description: MD5 encryption tool.
Example:
// Get the MD5 signature of a string, the second parameter indicates whether to convert it to uppercase
var b = MD5Util.crypt('aa', true);
// Or
var b = MD5('aa', true);
Collectionsβ
sort/get/emptySet/emptyListβ
Description: Collection tool classes, such as sorting, getting collections, etc.
Example:
// Sort the List
Collections.sort(list);
// Get an empty collection
var set = Collections.emptySet();
MapUtilβ
getValueByKey/needSplit/removeValueByKey/containsKey/getValuePositionInMap/deepCloneMap/copyToNewMap/putValueInMap/recursiveFlatMap/obj2Mapβ
Description: Dictionary tool class.
Example:
// Get the value of a specified level from a given map
var a = MapUtil.getValueByKey(map, 'a.b.c');
sleepβ
Description: The duration of the program hibernation is specified in milliseconds.
Example:
// Sleep for 10 milliseconds in the program
sleep(10);