From f8997e2d254bef1d9c0fc8ead03c7dac86d36641 Mon Sep 17 00:00:00 2001 From: Postbot Date: Sat, 2 Sep 2017 00:34:38 +0800 Subject: [PATCH] Create _benchmarks/native-vs-lodash.md --- _benchmarks/native-vs-lodash.md | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 _benchmarks/native-vs-lodash.md diff --git a/_benchmarks/native-vs-lodash.md b/_benchmarks/native-vs-lodash.md new file mode 100644 index 00000000..b2e379a5 --- /dev/null +++ b/_benchmarks/native-vs-lodash.md @@ -0,0 +1,34 @@ +--- +title: native vs lodash +setup: | + const ANOTHER_RECIPIENT = 'ANOTHER_RECIPIENT'; + const emailType = 'ANOTHER_RECIPIENT'; + const email = { foo: 100, bar: 'baz' }; + const sendEmailOption = [{ key: 'yolo' }]; + + const nativeFn = () => { + const selectedEmail = (emailType === ANOTHER_RECIPIENT) + ? ANOTHER_RECIPIENT + : _.isEmpty(email) + ? sendEmailOption[0].key + : email; + } + + const lodashFn = () => { + const = selectedEmail = _.cond([ + [() => emailType === ANOTHER_RECIPIENT, () => ANOTHER_RECIPIENT], + [() => _.isEmpty(email), () => _.get(_.first(sendEmailOption), 'key')], + [() => true, () => email] + ])(); + } +tests: + - + name: native + code: | + nativeFn(); + - + name: lodash + code: | + lodashFn(); +--- +