summaryrefslogtreecommitdiffstats
path: root/src/utils/methods.js
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-11-25 16:21:53 +1300
committerSaivan <savian@me.com>2018-11-25 16:21:53 +1300
commit62de7d0a1b994b69032a759b796b486e6bc382e3 (patch)
tree112b19f2903b4dc5b4cf61ebef0d021c6ca2f14d /src/utils/methods.js
parent2b37d7ba5b4267b39c86f9aba5fb14a1b376e846 (diff)
downloadsvg.js-62de7d0a1b994b69032a759b796b486e6bc382e3.tar.gz
svg.js-62de7d0a1b994b69032a759b796b486e6bc382e3.zip
Changed the esLint rules to avoid silly ternary operators, and to let code breathe!
This commit modifies some of the eslint rules, to allow our code to be a little bit more readable. This came about because we had a particularly pesky problem, where the code was indenting ternary operators. This fixes that, and makes it easy to add new rules to eslint as we please in the future. Changes ======= - Rebuilt the library with new eslint rules - Changed the eslintrc file to a yaml file by default
Diffstat (limited to 'src/utils/methods.js')
-rw-r--r--src/utils/methods.js50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/utils/methods.js b/src/utils/methods.js
index 70f9329..4973d13 100644
--- a/src/utils/methods.js
+++ b/src/utils/methods.js
@@ -2,41 +2,61 @@ const methods = {}
const constructors = {}
const names = []
-export function registerMethods (name, m) {
- if (Array.isArray(name)) {
- for (let _name of name) {
- registerMethods(_name, m)
+export function registerMethods ( name, m ) {
+
+ if ( Array.isArray( name ) ) {
+
+ for ( let _name of name ) {
+
+ registerMethods( _name, m )
+
}
return
+
}
- if (typeof name === 'object') {
- for (let [_name, _m] of Object.entries(name)) {
- registerMethods(_name, _m)
+ if ( typeof name === 'object' ) {
+
+ for ( let [ _name, _m ] of Object.entries( name ) ) {
+
+ registerMethods( _name, _m )
+
}
return
+
}
- addMethodNames(Object.keys(m))
- methods[name] = Object.assign(methods[name] || {}, m)
+ addMethodNames( Object.keys( m ) )
+ methods[name] = Object.assign( methods[name] || {}, m )
+
}
-export function getMethodsFor (name) {
+export function getMethodsFor ( name ) {
+
return methods[name] || {}
+
}
export function getMethodNames () {
- return [...new Set(names)]
+
+ return [ ...new Set( names ) ]
+
}
-export function addMethodNames (_names) {
- names.push(..._names)
+export function addMethodNames ( _names ) {
+
+ names.push( ..._names )
+
}
-export function registerConstructor (name, setup) {
+export function registerConstructor ( name, setup ) {
+
constructors[name] = setup
+
}
-export function getConstructor (name) {
+export function getConstructor ( name ) {
+
return constructors[name] ? { setup: constructors[name], name } : {}
+
}