Skip to main content
Module

x/rambda/source/drop.spec.js

Faster and smaller alternative to Ramda
Latest
File
import assert from 'assert'
import { drop } from './drop.js'
test('with array', () => { expect(drop(2)([ 'foo', 'bar', 'baz' ])).toEqual([ 'baz' ]) expect(drop(3, [ 'foo', 'bar', 'baz' ])).toEqual([]) expect(drop(4, [ 'foo', 'bar', 'baz' ])).toEqual([])})
test('with string', () => { expect(drop(3, 'rambda')).toBe('bda')})
test('with non-positive count', () => { expect(drop(0, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ]) expect(drop(-1, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ]) expect(drop(-Infinity, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])})
test('should return copy', () => { const xs = [ 1, 2, 3 ]
assert.notStrictEqual(drop(0, xs), xs) assert.notStrictEqual(drop(-1, xs), xs)})