Created
March 25, 2016 02:29
-
-
Save akm/8576edae2517aa8437e7 to your computer and use it in GitHub Desktop.
環境変数など任意のオブジェクトをキーでソートしたオブジェクトを取得する ref: http://qiita.com/akm/items/1278af3873aa589da154
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = { ... } | |
Object.keys(obj).sort().reduce(function(d, k){ d[k] = obj[k]; return d;}, {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node | |
> var obj = process.env | |
undefined | |
> Object.keys(obj).sort().reduce(function(d, k){ d[k] = obj[k]; return d;}, {}) | |
{ DISABLE_SPRING: '1', | |
EDITOR: '/usr/bin/emacs', | |
LANG: 'ja_JP.UTF-8', | |
... | |
TMPDIR: '/var/folders/70/5yxt0jys7ss_m71y5pz_l_qc0000gn/T/' } | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment