UNPKG

districts-nepal

Version:

contains all the districts of nepal along with the states

33 lines (28 loc) 666 B
//read from the file districts.json var fs = require('fs'); const districts = JSON.parse(fs.readFileSync('districts.json', 'utf8')); const result=[] function listByState(state) { districts.map(function(district) { if(district.stateno == state) { result.push(district); } } ) return result; } function findState(name){ districts.map(function(district) { if(district.title == name) { // console.log(district.stateno); result.push(district); } } ) return result; } //export the function module.exports = { listByState: listByState, findState: findState }