Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Join the elements of an array into a string. Indicate the regular and the last one separator. Indicate the maximum number of items to concatenate.
join-array
joins the elements of an array into a [String] value, and returns that value. In addition you can specify:
Any bugs found? Give me to know on GitHub
npm install join-array
const join = require('join-array');
const names = ['Rachel','Taylor','Julia','Robert','Jasmine','Lily','Madison'];
const config = {
array: names,
separator: ', ',
last: ' and ',
max: 4,
maxMessage:(missed)=>`(${missed} more...)`
};
const list = join(config); //Rachel, Taylor, Julia, (3 more...) and Madison
const join = require('join-array');
const cars = ['BMW','Tesla','Audi','Honda','Aston Martin','Cadillac','Citroen'];
const list = join(cars, " | ", " | ", 3, "[...]"); //BMW | Tesla | [...] | Citroen
join(array:Array, separator:String, last:String, max:Number, maxMessage:Function|String)
join(config:Object)
where config
contains the following properties: array:Array
, separator:String
, last:String
, max:Number
, maxMessage:Function|String
. The [Object] config
properties can be omitted (if optional). Then the default values are used instead.The
TypeError
is thrown when any argument type is invalid.
Follow theTypeError.message
instructions to configure the module.
array
[Array]Description: Indicates the [Array] object, which items are joined into the [String] value.
separator
[String] (optional)Default: ", "
Description: It separates all but the last one subsequent items of the array
.
last
[String] (optional)Default: " and "
Description: It separates the last and the last but one item of the array
.
max
[Number] (optional)Default: Infinity
Description: If defined, it limits the number of array
items to be joined; eg. if the max
equals 10
and the array
contains 100 items, the first 9 items and the 100th one are joined.
maxMessage
[Function|String] (optional)Default: (missed)=>`(${missed} more...)`
Description: If the number of array
items is bigger than the max
value, the missed items are replaced by the maxMessage
value.
[String]
, it is directly appended into the [String] chain before the last item.[Function]
, it expects the [String] value to be returned. The missed
argument passed through this function equals the number of missed items and can be used in the returned [String] message.FAQs
Join the elements of an array into a string. Indicate the regular and the last one separator. Indicate the maximum number of items to concatenate.
The npm package join-array receives a total of 71 weekly downloads. As such, join-array popularity was classified as not popular.
We found that join-array 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.