From fc3d6a0f8faf979bd6903a8167c56d25cdf319fc Mon Sep 17 00:00:00 2001 From: mohammad ali seif kashani Date: Fri, 18 Dec 2020 21:46:16 +0330 Subject: [PATCH 1/2] transition function implemented #2850 --- modules/_transition.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 modules/_transition.js diff --git a/modules/_transition.js b/modules/_transition.js new file mode 100644 index 000000000..f9c8fa30f --- /dev/null +++ b/modules/_transition.js @@ -0,0 +1,33 @@ +export function getTogglingfunction() { + if (arguments.length == 0) { + function inner(input) { + return !input; + } + return inner; + } else if (arguments.length != 1) { + var args = arguments; + function inner(input){ + let all_arguments = Array.from(args); + all_arguments_length = all_arguments.length; + index = all_arguments.indexOf(input); + return all_arguments[(index + 1) % all_arguments_length]; + } + return inner + } else if (arguments[0] instanceof Array){ + args = arguments[0]; + function inner(input){ + let all_arguments = args; + all_arguments_length = all_arguments.length; + index = all_arguments.indexOf(input); + return all_arguments[(index + 1) % all_arguments_length]; + } + return inner + } else { + obj = arguments[0]; + function inner(input) { + inner_obj = obj; + return inner_obj[input]; + } + return inner + } +} \ No newline at end of file From c3967228dbedea322688e0f7ec7f4eb22083d69a Mon Sep 17 00:00:00 2001 From: mohammad ali seif kashani Date: Sun, 20 Dec 2020 23:58:20 +0330 Subject: [PATCH 2/2] findKeys implemented --- modules/_findkeys.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/_findkeys.js diff --git a/modules/_findkeys.js b/modules/_findkeys.js new file mode 100644 index 000000000..b4221707f --- /dev/null +++ b/modules/_findkeys.js @@ -0,0 +1,16 @@ +import cb from './_cb.js'; +import keys from './keys.js'; + + +function findKeys(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + var arr = []; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) { + arr.push(key); + } + } + return arr; +} \ No newline at end of file