1.1.2 • Published 2 months ago

safe-array-concat v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

safe-array-concat Version Badge

github actions coverage License Downloads

npm badge

Array.prototype.concat, but made safe by ignoring Symbol.isConcatSpreadable

Getting started

npm install --save safe-array-concat

Usage/Examples

var safeConcat = require('safe-array-concat');
var assert = require('assert');

assert.deepEqual([].concat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with normal concat');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with safe concat');

String.prototype[Symbol.isConcatSpreadable] = true;
assert.deepEqual([].concat('foo', Object('bar')), ['foo', 'b', 'a', 'r'], 'spreadable String objects are spread with normal concat!!!');
assert.deepEqual(safeConcat('foo', Object('bar')), ['foo', Object('bar')], 'spreadable String objects are not spread with safe concat');

Array.prototype[Symbol.isConcatSpreadable] = false;
assert.deepEqual([].concat([1, 2], 3, [[4]]), [[], [1, 2], 3, [[4]]], 'non-concat-spreadable arrays do not spread with normal concat!!!');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'non-concat-spreadable arrays still spread with safe concat');

Tests

Simply clone the repo, npm install, and run npm test

es-abstractutil.promisifyobject.getownpropertydescriptorseasy-select-rnopea-bootstraapluminos-ui-core@everything-registry/sub-chunk-2700jawwy-sdkjawwy_gamification_release@deepakorg/test@deepak757/testreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-tablemachinebeemrcapsreact-native-jawwy_sample@blusalt-sdk/react-native-blusalt-document-verification@extrieve_technologies/quickcapture_react_native@fabwcie/ckeditor5-preview@hieuquang2212/form@firstday/firstdayteh@juanaraneta/dept-central-lib-client@icetee/react-recaptcha-v3@jockho-gus/jp-geden@joaquinmr99/calculadora@jleiva/signer-jwt@jabatoforever/react-tw-datepickergentogeulis94ginminegeorgeanons12georgejohnfelix29grtaudahgamification-integration-newgassefalsgassefals-2gaskeunnnmamanggaskeunlahcuy20franklampard45framework_test_library_sixdeeframework_test_library_sixdee_newframework_test_library_sixdee_new_newgalangpramono253galihariwanda29enefti-galeries-string-html-methodserlocogonzales08es-arraybuffer-base64es-iterator-helperserikoalametdahsusahestehsusuelviradrop-menu-nav-bardynamics-contracts-xfalcata-appfaturohmanfawaterak-online-paymentfawatrak-online-paymentferlinanons23fernandotorest45fluent.adflow.reactnativesdkfluent.adflow.reactnativesdk-alphafbkocakfixed_form_builderfind-value-locationsflaressshoteahong1-utilshayuatuhhayuulinhalowpoeawimage-storiessipalingerlylembah1leonardsinggihtea46letsgoobraderletherego932slebewjawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwynextjs-storiestest_lib_module_aartea-fairly@gericuz/tea-fairlyanci-react@kazmight331/themarine331@knooks/use-title@lxxtea/teababibikinpusing@idas1/ui-component-lib@max_alieksieiev/react-pdf-viewer-root@mayuriachewad/pickupbiz-npm-package@rizzzzze/baladotongkol@react-native-ui-design/button@npm_fluentco/adflow-react-native-sdk
1.1.1

2 months ago

1.1.2

2 months ago

1.1.0

4 months ago

1.0.1

8 months ago

1.0.0

1 year ago