Skip to content

Instantly share code, notes, and snippets.

@igorshubovych
Created December 8, 2015 16:15
Show Gist options
  • Save igorshubovych/bf43e15424fff5420afd to your computer and use it in GitHub Desktop.
Save igorshubovych/bf43e15424fff5420afd to your computer and use it in GitHub Desktop.
Short index for TLDR project
{
"commands": [
{
"name": "ab",
"platform": [
"common"
]
},
{
"name": "ack",
"platform": [
"common"
]
},
{
"name": "ag",
"platform": [
"common"
]
},
{
"name": "airport",
"platform": [
"osx"
]
},
{
"name": "alias",
"platform": [
"common"
]
},
{
"name": "apropos",
"platform": [
"common"
]
},
{
"name": "apt-get",
"platform": [
"linux"
]
},
{
"name": "aptitude",
"platform": [
"linux"
]
}
]
}
{
"ab": [
"common"
],
"ack": [
"common"
],
"ag": [
"common"
],
"airport": [
"osx"
],
"alias": [
"common"
],
"apropos": [
"common"
],
"apt-get": [
"linux"
],
"aptitude": [
"linux"
]
}
var _ = require('lodash');
var fs = require('fs');
var indexContent = fs.readFileSync('assets/index.json');
var index = JSON.parse(indexContent).commands;
var shortIndex = _.zipObject(
_.map(index, 'name'),
_.map(index, 'platform'));
console.log(JSON.stringify(shortIndex));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment