Immutable-js: Get first key from OrderedMap

Created on 14 Mar 2015  路  4Comments  路  Source: immutable-js/immutable-js

The .first() method returns the first _value_ in an OrderedMap. How do I get the first _key_?

Most helpful comment

still not changed?

All 4 comments

var Immutable = require('immutable');

var m = Immutable.OrderredMap({a:1, b:1});

//get first key
m.keySeq().first(); //a

@hufeng is correct. Get the key sequence and pull the first item from it.

In a future major version update, I will likely change this API to return an entry tuple instead of a value, which adheres to Map's iteration behavior.

still not changed?

Would be great to get firstKey and lastKey options in the API, or have first and last return an entry tuple as discussed above :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jshthornton picture jshthornton  路  3Comments

migueloller picture migueloller  路  3Comments

Haroenv picture Haroenv  路  3Comments

evenstensberg picture evenstensberg  路  4Comments

colbyr picture colbyr  路  3Comments