at

Aperta
#15 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
50/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
tooling

Direzione di ricerca

Parti dall’entry point at(i, x) e usa gli esempi per seguire i lookup di array, oggetti e strutture annidate. Il lavoro è completo quando la funzione è curried, accetta le forme di chiave elencate, si ferma su null o undefined, restituisce il valore richiesto o nil e non legge dai prototipi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

at(i, x)

Returns value at given key, index or path in an array or object or combination of both.

Where:

  • i is a string, a number or an array of strings or numbers
  • x is either an array or an object

Examples

Value from an array
at(1)([41, 42, 43]);
//=> 42
Value from a object
at('answer')({answer: 42});
//=> 42
Value from a nested array
at([1, 1])([[31, 32], [41, 42]]);
//=> 42
Value from an object in a nested array
at([1, 'answer'])([[{}], [{answer: 42}]]);
//=> 42

Features

  • Function must be curried.
  • When given an array recursively go down x
  • Should avoid null pointer exception by conceding as soon as nil (i.e. either null or undefined) is detected.
  • Return either nil or the value at i.
  • Should not read from the prototype e.g. at('length', [1, 2, 3]) should return undefined not 3.
Lingua principale
JavaScript
Stelle
1
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.