esamattis / esamattis/underscore.string

Make JavaScript String wrapper methods null/undefined-safe

Offen
#484 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
3.4k
Forks
367
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

A great benefit of Java String Utils libraries such as Apache Commons StringUtils is their null-safety. You should be able to provide null/undefined-safety to your JavaScript String wrapper functions, e.g.

```
expect(_s(null).toUpperCase().value()).to.be.a('null');
expect(_s(undefined).toUpperCase().value()).to.be.an('undefined');
```

I successfully spiked out this functionality with a couple of tweaks to **index.js**.

You may also want to add explicit null/undefined-safe wrapper functions, so that one can tap into this safety without chaining, e.g.

```
expect(_s.toUpperCase(null)).to.be.a('null');
expect(_s.toUpperCase(undefined)).to.be.an('undefined');
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start in index.js, where the issue reports that the functionality was prototyped, and inspect the existing chained and direct String wrapper methods. Confirm that null remains null and undefined remains undefined for toUpperCase-style calls, both through _s(value).method().value() and the explicit _s.method(value) form; the issue does not name a test file.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.