Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pagewang0
Last active October 17, 2018 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pagewang0/26c69f171129e425f2401990b8bf3501 to your computer and use it in GitHub Desktop.
Save pagewang0/26c69f171129e425f2401990b8bf3501 to your computer and use it in GitHub Desktop.
object mapping
transform: {
sfjjr: 'stockbroker',
czdh: 'type'
}
const transform = (res) => {
if (_.isArray(res)) {
res.map(row => transform(row));
}
return _.reduce(_.keys(options.transform), (s, c) => {
s[options.transform[c]] = res[c];
return s;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment