import { createRule , StyleObject , Rule } from './Rule' ; import { Indexable , Nullable } from './utils/types' ; import generateId from './utils/generateId' ; const rules = { } ; /**
 * Retrieves a rule for a given id.
 */ export function getRule ( ruleId ) { const rule = rules [ ruleId ] ; return typeof rule === 'function' ? rule ( ) : rule ; } param id param style returns export function registerRule ( ruleId , style ) { if ( ruleId && rules [ ruleId ] ) { throw new Error ( `you are trying to register 2 rules with the same id: '${ ruleId }'` ) ; } const id = ruleId || generateId ( style ) ; rules [ id ] = rules [ id ] || ( ( ) => ( rules [ id ] = createRule ( id , style ) ) ) ; return id ; }