forked from enviPath/enviPy
Current Dev State
This commit is contained in:
19
static/js/ketcher2/node_modules/subscription/LICENSE
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/subscription/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (C) 2016 by Marijn Haverbeke <marijnh@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
101
static/js/ketcher2/node_modules/subscription/README.md
generated
vendored
Normal file
101
static/js/ketcher2/node_modules/subscription/README.md
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
# Subscription
|
||||
|
||||
A subscription is an object that emits events. Rather than overloading
|
||||
objects with other roles to emit events, and having a single object
|
||||
emit several types, as in `.addEventListener` style events, a
|
||||
subscription is a dedicated object representing a single event source.
|
||||
|
||||
// Instead of adding listeners by string type
|
||||
object.addEventListener("message", m => { ... })
|
||||
|
||||
// You create a subscription object when you construct the base
|
||||
// object...
|
||||
class MyObject {
|
||||
constructor() {
|
||||
this.message = new Subscription
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
// ...and add handlers directly to that:
|
||||
myObject.message.add(m => { ... })
|
||||
|
||||
The interface of a subscription is roughly based on
|
||||
[`js-signals`](https://millermedeiros.github.io/js-signals/), but
|
||||
whereas `js-signals` have a fixed dispatch algorithm, subscriptions
|
||||
come in several forms.
|
||||
|
||||
The perceived benefits of subscriptions are that they are easier to
|
||||
check statically (instead of a single method dispatching on a bunch of
|
||||
strings, you have actual objects representing your event types, each
|
||||
of which expects a single type of handler function), and lead to more
|
||||
explicit code.
|
||||
|
||||
## Distribution
|
||||
|
||||
This module is licensed under an MIT license. The recommended way to
|
||||
install it is with [NPM](https://www.npmjs.com/package/subscription).
|
||||
|
||||
## API
|
||||
|
||||
### class `Subscription`
|
||||
|
||||
A subscription is an object that you can add subscribers (functions)
|
||||
to, which will be called every time the subscription is dispatched.
|
||||
|
||||
**`add`**`(f: Function, priority: ?number)`
|
||||
|
||||
Add a function of the appropriate type for this subscription to be
|
||||
called whenever the subscription is dispatched. When `priority` is
|
||||
provided (default is zero), it determines when the function is called
|
||||
relative to other handlers—those with a high priority come first.
|
||||
|
||||
**`addOnce`**`(f: Function, priority: ?number)`
|
||||
|
||||
Add a function to be called once, the next time this subscription is
|
||||
dispatched.
|
||||
|
||||
**`remove`**`(f: Function)`
|
||||
|
||||
Remove the given subscriber from the subscription.
|
||||
|
||||
**`hasHandler`**`() → bool`
|
||||
|
||||
Returns true if there are any functions registered with this
|
||||
subscription.
|
||||
|
||||
**`dispatch`**`(...args: [any])`
|
||||
|
||||
Call all handlers for this subscription with the given arguments.
|
||||
|
||||
### class `PipelineSubscription` extends `Subscription`
|
||||
|
||||
A type of subscription that passes the value it is dispatched with
|
||||
through all its subscribers, feeding the return value from each
|
||||
subcriber to the next one, and finally returning the result.
|
||||
|
||||
**`dispatch`**`(value: any) → any`
|
||||
|
||||
Run all handlers on the given value, returning the result.
|
||||
|
||||
### class `StoppableSubscription` extends `Subscription`
|
||||
|
||||
A stoppable subscription is a subscription that stops calling further
|
||||
subscribers as soon as a subscriber returns a truthy value.
|
||||
|
||||
**`dispatch`**`(...args: [any]) → any`
|
||||
|
||||
Call handlers with the given arguments. When one of them returns a
|
||||
truthy value, immediately return that value.
|
||||
|
||||
### class `DOMSubscription` extends `Subscription`
|
||||
|
||||
A DOM subscription can be used to register intermediate handlers for
|
||||
DOM events. It will call subscribers until one of them returns a
|
||||
truthy value or calls `preventDefault` on the DOM event.
|
||||
|
||||
**`dispatch`**`(event: Event) → bool`
|
||||
|
||||
Run handlers on the given DOM event until one of them returns a truty
|
||||
value or prevents the event's default behavior. Returns true if the
|
||||
event was handled.
|
||||
95
static/js/ketcher2/node_modules/subscription/index.js
generated
vendored
Normal file
95
static/js/ketcher2/node_modules/subscription/index.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
function Handler(f, once, priority) {
|
||||
this.f = f
|
||||
this.once = once
|
||||
this.priority = priority
|
||||
}
|
||||
|
||||
function Subscription() {
|
||||
this.handlers = []
|
||||
}
|
||||
exports.Subscription = Subscription
|
||||
|
||||
function insert(s, handler) {
|
||||
var pos = 0
|
||||
for (; pos < s.handlers.length; pos++)
|
||||
if (s.handlers[pos].priority < handler.priority) break
|
||||
s.handlers = s.handlers.slice(0, pos).concat(handler).concat(s.handlers.slice(pos))
|
||||
}
|
||||
|
||||
Subscription.prototype.handlersForDispatch = function() {
|
||||
var handlers = this.handlers, updated = null
|
||||
for (var i = handlers.length - 1; i >= 0; i--) if (handlers[i].once) {
|
||||
if (!updated) updated = handlers.slice()
|
||||
updated.splice(i, 1)
|
||||
}
|
||||
if (updated) this.handlers = updated
|
||||
return handlers
|
||||
}
|
||||
|
||||
Subscription.prototype.add = function(f, priority) {
|
||||
insert(this, new Handler(f, false, priority || 0))
|
||||
}
|
||||
|
||||
Subscription.prototype.addOnce = function(f, priority) {
|
||||
insert(this, new Handler(f, true, priority || 0))
|
||||
}
|
||||
|
||||
Subscription.prototype.remove = function(f) {
|
||||
for (var i = 0; i < this.handlers.length; i++) if (this.handlers[i].f == f) {
|
||||
this.handlers = this.handlers.slice(0, i).concat(this.handlers.slice(i + 1))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Subscription.prototype.hasHandler = function() {
|
||||
return this.handlers.length > 0
|
||||
}
|
||||
|
||||
Subscription.prototype.dispatch = function() {
|
||||
var handlers = this.handlersForDispatch()
|
||||
for (var i = 0; i < handlers.length; i++)
|
||||
handlers[i].f.apply(null, arguments)
|
||||
}
|
||||
|
||||
function PipelineSubscription() {
|
||||
Subscription.call(this)
|
||||
}
|
||||
exports.PipelineSubscription = PipelineSubscription
|
||||
|
||||
PipelineSubscription.prototype = new Subscription
|
||||
|
||||
PipelineSubscription.prototype.dispatch = function(value) {
|
||||
var handlers = this.handlersForDispatch()
|
||||
for (var i = 0; i < handlers.length; i++)
|
||||
value = handlers[i].f(value)
|
||||
return value
|
||||
}
|
||||
|
||||
function StoppableSubscription() {
|
||||
Subscription.call(this)
|
||||
}
|
||||
exports.StoppableSubscription = StoppableSubscription
|
||||
|
||||
StoppableSubscription.prototype = new Subscription
|
||||
|
||||
StoppableSubscription.prototype.dispatch = function() {
|
||||
var handlers = this.handlersForDispatch()
|
||||
for (var i = 0; i < handlers.length; i++) {
|
||||
var result = handlers[i].f.apply(null, arguments)
|
||||
if (result) return result
|
||||
}
|
||||
}
|
||||
|
||||
function DOMSubscription() {
|
||||
Subscription.call(this)
|
||||
}
|
||||
exports.DOMSubscription = DOMSubscription
|
||||
|
||||
DOMSubscription.prototype = new Subscription
|
||||
|
||||
DOMSubscription.prototype.dispatch = function(event) {
|
||||
var handlers = this.handlersForDispatch()
|
||||
for (var i = 0; i < handlers.length; i++)
|
||||
if (handlers[i].f(event) || event.defaultPrevented) return true
|
||||
return false
|
||||
}
|
||||
50
static/js/ketcher2/node_modules/subscription/package.json
generated
vendored
Normal file
50
static/js/ketcher2/node_modules/subscription/package.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"_from": "subscription@3.0.0",
|
||||
"_id": "subscription@3.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-DjFpJj6piJp9cao0/0Rl8tGsJuI=",
|
||||
"_location": "/subscription",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "subscription@3.0.0",
|
||||
"name": "subscription",
|
||||
"escapedName": "subscription",
|
||||
"rawSpec": "3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/subscription/-/subscription-3.0.0.tgz",
|
||||
"_shasum": "0e3169263ea9889a7d71aa34ff4465f2d1ac26e2",
|
||||
"_spec": "subscription@3.0.0",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher",
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/marijnh/subscription/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Simple abstraction for first-class event emitters",
|
||||
"homepage": "https://github.com/marijnh/subscription#readme",
|
||||
"keywords": [
|
||||
"event",
|
||||
"signal",
|
||||
"listener",
|
||||
"emitter"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "subscription",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/marijnh/subscription.git"
|
||||
},
|
||||
"version": "3.0.0"
|
||||
}
|
||||
Reference in New Issue
Block a user