cc @staltz have you considered doing something similar for Manyverse? I think it might be important ... I notice I already have trouble in Signal where I'm part of a group with Diacritics in the name and I cannot search it up because I don't know how to easily type those diacritics.
screen-shot showing that a simple "word" regex absolutely fails in Te Reo Maori
@cherese just spotted a but with flumeview-search
which uses the the regexp \w+
or similar which means "any number of 'word characters'".
Guess who is excluded from word characters....
Fuck me, this is the worst.
So now we're "normalizing" all our searches by dropping diacritics...
str.normalize("NFD").replace(/\p{Diacritic}/gu, "")
src: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
There is sometimes a convention to have the outer next
function use abort
as the variable name instead of end
.
e.g. the following from pull-stream-examples:
function map (mapper) {
//a sink function: accept a source
return function (read) {
//but return another source!
return function (abort, cb) {
read(abort, function (err, data) {
//if the stream has ended, pass that on.
if(err) return cb(err)
//apply a mapping to that data
cb(null, mapper(data))
})
}
}
}
or this from patchfoo
:
function catchTextError() {
return function (read) {
var ended
return function (abort, cb) {
if (ended) return cb(ended)
read(abort, function (end, data) {
if (!end || end === true) return cb(end, data)
ended = true
cb(null, end.stack + '\n')
})
}
}
}
Part of what makes the referenced code from pull-stream/throughts/filter
harder to follow I think is that it includes protection against stack growth and callbacks potentially being called synchronously. Related: dezalgo - and the package looper
mentioned by @dominic in %sBL+I3p... - or pull-looper
. That is why there is a while
loop in there when it could otherwise apparently be written more simply.
Show whole feed