.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / state-toggle / index.js
1 'use strict'
2
3 module.exports = factory
4
5 // Construct a state `toggler`: a function which inverses `property` in context
6 // based on its current value.
7 // The by `toggler` returned function restores that value.
8 function factory(key, state, ctx) {
9   return enter
10
11   function enter() {
12     var context = ctx || this
13     var current = context[key]
14
15     context[key] = !state
16
17     return exit
18
19     function exit() {
20       context[key] = current
21     }
22   }
23 }