Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

between-join

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

between-join

Join array between expression

  • 1.5.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by9.09%
Maintainers
1
Weekly downloads
 
Created
Source

Between-Join

Join array between expression for NodeJS

What's this?

This is a simple library for generate string (of object or array)

Installation

Between-Join requires Node.js v8+ to run.

Install the dependencies and start the server.

$ cd yourProject
$ npm install between-join --save

Parameters

BetweenJoin must receive 3 parametters (2 required):
1) Object / Array [Required]
2) Expression [Required]
    - Expression must contain '$1' key, and/or $2 if is jsobject
      - Objects:
        - $1 = Object key
        - $2 = Object value
3) Delete [Optional]
    - Numeric param, erase last characters (1, ..., response.length)

Expression

Between-join must receive to parameter, 'expression'. The word '$1' into expression will be replaced by value of array and '$1' and '$2' for object

const exp = '>$1<';

Examples

Array

Code:

// Import
const BetweenJoin = require('between-join');
// Properties
// Array
const array = ['Hola', 'Mundo'];
// Expression
const expression = '[$1]';
// Response
const response = BetweenJoin(array, expression);
// Print
console.log(response);

Output

[Hello][World]

Object

Code:

// Import
const BetweenJoin = require('between-join');
// Properties
// Object
const obj = {
  hola: 'World',
  key: 'Value',
};
// Expression
const expression = '[$1-$2]';
// Response
const response = BetweenJoin(obj, expression);
// Print
console.log(response);

Output

[hola-World][key-Value]

Object and array

Code:

// Import
const BetweenJoin = require('between-join');
// Properties
// Array
const values = {
  array: ['Hello', 'World'],
  obj: {
    print: 'I\'m a js object',
  },
};
// Expression
const expression = '[$1 $2]';
// Response
const response = BetweenJoin(values, expression);
// Print
console.log(response);

Output

[array [Hello][World]][obj[printI'm a js object]]

Deleting last character

// Import
const BetweenJoin = require('between-join');
// Properties
// Array
const array = ['Hello', 'World'];
// Expression
const expression = '[$1]';
// Response
const normal = BetweenJoin(array, expression);
const one = BetweenJoin(array, expression, 1);
const two = BetweenJoin(array, expression, 2);
// Print
console.log(normal);
console.log(one);
console.log(two);

Output

[Hello][World]
[Hello][World
[Hello][Worl

Keywords

FAQs

Package last updated on 07 Mar 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc