Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

choo-expose

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-expose

Expose a choo instance on the window

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

choo-expose stability

npm version build status downloads js-standard-style

Expose a choo instance on the window

Usage

var expose = require('choo-expose')
var choo = require('choo')

var app = choo()
app.use(expose())

console.log(window.choo.state)
window.choo.emit('foo')
window.choo.on('foo', function (data) {
  console.log('foo called', data)
})

window.choo.log
// => table view of history

API

instance = expose()

Create a new choo-expose instance.

window.choo.state

Get the current state.

window.choo.log

window.choo.history

Get an overview of the most recent events.

window.choo.copy

Serialize an object into JSON and copy it to the clipboard. Must be called in response to a user gesture event, like click or keyup.

Example:

copy whole choo state to clipboard
window.addEventListener('keyup', function (e) {
  // press 'c' to copy current state to clipboard
  if (e.keyCode === 67) {
    window.choo.copy()
  }
})
copy choo state at a specific path
window.addEventListener('keyup', function (e) {
  // press 'c' to copy current state at a specific path
  if (e.keyCode === 67) {
    window.choo.copy('state.foo.bar')
  }
})
// also works with nested paths such as:
var object = { hello: { world: { lorem: 'ipsum' } } }
window.choo.copy('hello.world.lorem', object)
// will copy 'ipsum' to clipboard

// and objects:
window.choo.copy({cool: 'hey'})
// will copy {'cool': 'hey'} to clipboard

License

MIT

Keywords

FAQs

Package last updated on 17 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc