Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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
Load the join-array.min.js
file from the dist
folder into your .html
file.
The module is accessible as joinArray
in the window scope.
It is a babel converted and webpack bundled [ES5] module version.
<script src="join-array.min.js"></script>
<script>
var list = joinArray({
array: ['Jasmine', 'Adam', 'Amanda', 'Nicky'],
separator: ', '
});
</script>
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...)`,
each:(value)=>value
};
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|null, last:String|null, max:Number|null, maxMessage:Function|String|null, each:Function|null)
join(config:Object)
where config
contains the following properties: array:Array
, separator:String|null
, last:String|null
, max:Number|null
, maxMessage:Function|String|null
, each:Function|null
.When the
null
is passed as the argument, the default value is used for this parameter. When the [Object]config
property is omitted (if optional) or set tonull
, the default value is used for this property.
The
TypeError
is thrown when any argument type orconfig
property 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|null] (optional)Default: ", "
Description: It separates all but the last one subsequent items of the array
.
last
[String|null] (optional)Default: " and "
Description: It separates the last and the last but one item of the array
.
max
[Number|null] (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|null] (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.each
[Function|null] (optional)Default: null
Description: If the each
is defined, the module loops through each array
item and calls the [Function] each
with the following parameters: each(item, iter, array)
. Use each
function to modify the value. The returned value will be used in the chain.
const join = require('join-array');
const ids = [1,2,3,4,5];
const config = {
array: ids,
each:(value)=>`"id. ${value}"`
};
const list = join(config); //"id. 1", "id. 2", "id. 3", "id. 4" and "id. 5"
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 32 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.