expect(state.things.every('foo', 'bar', 'baz')).toBe(false)
expect(state.things.filter('foo', 'bar', 'baz')).toEqual([foo])
- expect(state.things.find('foo', 'bar', 'baz')).toBe(foo)
+
+ const _foo = state.things.find('foo', 'bar', 'baz')
+ expect(isReactive(_foo)).toBe(true)
+ expect(foo).toStrictEqual(_foo)
+
expect(state.things.findIndex('foo', 'bar', 'baz')).toBe(1)
- expect(state.things.findLast('foo', 'bar', 'baz')).toBe(bar)
+
+ const _bar = state.things.findLast('foo', 'bar', 'baz')
+ expect(isReactive(_bar)).toBe(true)
+ expect(bar).toStrictEqual(_bar)
+
expect(state.things.findLastIndex('foo', 'bar', 'baz')).toBe(1)
expect(state.things.forEach('foo', 'bar', 'baz')).toBeUndefined()
expect(state.things.map('foo', 'bar', 'baz')).toEqual(['1', '2', '3'])
args?: IArguments,
) {
const arr = shallowReadArray(self)
- let methodFn
+ const needsWrap = arr !== self && !isShallow(self)
// @ts-expect-error our code is limited to es2016 but user code is not
- if ((methodFn = arr[method]) !== arrayProto[method]) {
- return methodFn.apply(arr, args)
+ const methodFn = arr[method]
+ // @ts-expect-error
+ if (methodFn !== arrayProto[method]) {
+ const result = methodFn.apply(arr, args)
+ return needsWrap ? toReactive(result) : result
}
- let needsWrap = false
let wrappedFn = fn
if (arr !== self) {
- needsWrap = !isShallow(self)
if (needsWrap) {
wrappedFn = function (this: unknown, item, index) {
return fn.call(this, toReactive(item), index, self)