
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
RTNG.js is a lightweight, template driven, and easy to use random text and number generator.
by Michael Kubina
https://github.com/michaelkubina/rtng-js
RTNG.js is a lightweight and easy to use random text and number generator, that requires little programming knowledge. Of course it can be used with other libraries as well.
It's core features are:
It can be used for different tasks, where you rely on varying random text and number output, e.g.:
In order to expand the possibilities further there are planned features like:
Using RTNG.js requires a valid datapack following the RTNG.js specific schema in JSON notation. It can be accessed and used through a variety of functions. The simplest way is described in these three steps.
<head>
<script src="rtng-js/rtng.js"></script>
</head>
async function myScript() {
const example = await rtng.init('https://raw.githubusercontent.com/michaelkubina/rtng-js/main/example.json');
console.log(await example.parseTemplate("number.any-percent"));
console.log(await example.parseTemplate("text.favourite-color"));
}
myScript();
A RTNG.js datapack is for the most part a hierarchical organized tree of templates, that by themselves are constructed from configurable data type primitives. The smallest possible datapack consists of one or more templates not being in any hierarchy at all. A template must have a sequence that should be parsed when called and that indicates, that its actually a template and not part of the hierarchy. A template must not have another hierarchy within it.
{
...
"0-to-100": { <-- a template
"@sequence":[ <-- because it has a @sequence
{
...
}
]
},
...
"number": { <-- a hierarchy, because it does not have a @sequence
"any-percent": { <-- a template within a hierarchy
"@sequence":[ <-- because it has a @sequence
{
...
}
]
},
},
...
}
A "@sequence" is a list of configurable data primitive objects. The @ symbol is required to clearly distinguish it from not being a hierarchy of the name sequence. A sequence must not have any other than the allowed RTNG.js data types.
There are currently four primitive data types that have their own set of attributes, through which the output can be configured. The first two main data types are "number" and "string", where the former allows for one or more random number picks, and the latter one or more random text snippets from a list.
{
...
"0-to-100": {
"title": "A number from 0 to 100",
"@sequence": [
{
"number": {
"min": 0,
"max": 100,
"min_picks": 1
}
}
]
},
"3-colors": {
"title": "Three colors from a list of ten",
"@sequence": [
{
"string": {
"list": [
"red",
"green",
"blue",
"yellow",
"cyan",
"magenta",
"purple",
"pink",
"black",
"white"
],
"min_picks": 2,
"max_picks": 4,
"unique": true,
"punctuation": ",",
"conjunction": "and"
}
}
]
},
The other two data type are "raw", which is used for a direct string output, and most importantly the "template" data type. This allows for parsing another template directly into the template, that is currently being processed.
Adding a template means actually just writing the absolute path in dot.notation to another template within the datapack. The use of dot.notation for the names of your templates or hierarchies is not allowed, as it will break things. For readability benefits the use of kebab-case is encouraged instead.
"number": {
"any-percent": {
"@sequence":[
{
"template": "0-to-100"
},
{
"raw": "%"
}
]
},
},
"text": {
"favourite-color": {
"@sequence":[
{
"raw": "Let me think about it... I am"
},
{
"template": "number.any-percent"
},
{
"raw": "sure that"
},
{
"template": "3-colors"
},
{
"raw": "are my favourite colors!"
}
]
}
}
}
You are allowed to enrich the datapack with your JSON data as long as you follow the notation rules. This way you will not break things and will be able to retrieve the data through some RTNG.js functions as well.
{
"metadata": {
"title": "example.json",
"author": "Michael Kubina",
"description": "a small example datapack for RTNG.js",
...
},
...
}
For a detailed overview of the functions and an in depth view on the data types, please visit the documentation.
FAQs
RTNG.js is a lightweight, template driven, and easy to use random text and number generator.
The npm package rtng receives a total of 0 weekly downloads. As such, rtng popularity was classified as not popular.
We found that rtng demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.