Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jan 26, 2025
1 parent 85bd936 commit 0e9024a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
2 changes: 1 addition & 1 deletion src/array/replaceOrAppend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function replaceOrAppend<T, U>(
if (newItem === undefined) {
return [...array]
}
const out = array.slice()
const out = array.slice() as (T | Defined<U>)[]
for (let index = 0; index < array.length; index++) {
if (match(array[index], index)) {
out[index] = newItem
Expand Down
22 changes: 0 additions & 22 deletions tests/object/clone.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import * as _ from 'radashi'

describe('clone', () => {
test('copies the primitives', () => {
const arr = [
1.1,
'How you doing?',
false,
Symbol('key'),
BigInt('1'),
undefined,
null,
]
for (const elm of arr) {
const newElm = _.clone(elm)
expect(elm).toBe(newElm)
}
})
test('copies arrays', () => {
const arr = [{ a: 0 }, 1, 2, 3]
const result = _.clone(arr)
Expand All @@ -25,13 +10,6 @@ describe('clone', () => {
expect(arr[i]).toBe(result[i])
}
})
test('copies functions', () => {
const fa = () => 0
const fb = _.clone(fa)

expect(fa).not.toBe(fb)
expect(fa()).toBe(fb())
})
test('copies objects (class instances) without losing the class type', () => {
class Data {
val = 0
Expand Down
5 changes: 0 additions & 5 deletions tests/object/crush.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import * as _ from 'radashi'

describe('crush', () => {
test('handles bad input', () => {
expect(_.crush({})).toEqual({})
expect(_.crush(null as any)).toEqual({})
expect(_.crush(undefined as any)).toEqual({})
})
test('returns correctly crushed object', () => {
const now = new Date()
const ra = {
Expand Down

0 comments on commit 0e9024a

Please sign in to comment.