-
-
Notifications
You must be signed in to change notification settings - Fork 913
Closed
Labels
BugSomething isn't working.Something isn't working.
Description
Description
iterUniqueBy
calls the "uniqueness" predicate function on the iterator's return value. This is wrong, the return value is not part of the sequence, and cannot be skipped. A yield* ...
expression doesn't distinguish between missing value
and undefined
.
Related Issues
Haven't found any related to iter-unique
Questions
No.
Demo
No response
Reproduction
import iterUniqueBy from "@stdlib/iter-unique-by"
function notSameLength(a, b) {
return a.length !== b.length
}
const filtered = iterUniqueBy(["baba", "yaga"].values(), notSameLength)
console.log(Array.from(filtered))
Expected Results
// output
[ 'baba' ]
Actual Results
file:///tmp/bug/repro.js:4
return a.length !== b.length
^
TypeError: Cannot read properties of undefined (reading 'length')
at notSameLength (file:///tmp/bug/repro.js:4:25)
at isUnique (/tmp/bug/node_modules/.pnpm/@[email protected]/node_modules/@stdlib/iter-unique-by/lib/main.js:59:19)
at Object.next (/tmp/bug/node_modules/.pnpm/@[email protected]/node_modules/@stdlib/iter-unique-by/lib/main.js:142:38)
at Function.from (<anonymous>)
at file:///tmp/bug/repro.js:9:19
Version
@stdlib/iter-unique-by 0.0.6
Environments
Node.js
Browser Version
No response
Node.js / npm Version
Node.js v17.2.0 / pnpm 6.23.6
Platform
No response
Checklist
- Read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
Metadata
Metadata
Assignees
Labels
BugSomething isn't working.Something isn't working.