Socket
Book a DemoInstallSign in
Socket

@bemoje/arr-clone

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bemoje/arr-clone

Shallow clone of provided array, 'arr'.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

@bemoje/arr-clone

Shallow clone of provided array, 'arr'.

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

Installation

npm install @bemoje/arr-clone
npm install --save @bemoje/arr-clone
npm install --save-dev @bemoje/arr-clone

Usage

import arrClone from '@bemoje/arr-clone'

/**
 * compares strict equality of each element in a shallow comparison.
 */
function shallowCompareArrays(arr1, arr2) {
	for (let i = 0; i < arr1.length; i++) {
		if (arr1[i] !== arr2[i]) {
			return false
		}
	}
	return true
}

const arr = [1, 2]
const cloned = arrClone(arr)

/**
 * ALL ELEMENTS ARE THE SAME
 */
shallowCompareArrays(arr, cloned)
//=> true

/**
 * DO NOT REFER TO THE SAME OBJECT, IE. A "CLONE"
 */
arr === cloned
//=> false

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

arrClone

Shallow clone of provided array, 'arr'.

Parameters
  • arr Array The array to clone
Returns

Array The cloned array

Keywords

shallow

FAQs

Package last updated on 30 Apr 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.