Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,32 @@
# bind-obj-methods
Bind methods to an object from that object or some other source.
Optionally specify a set of methods to skip over.
Also binds non-enumerable methods, retaining their
non-enumerable-ness.
## API
`bindObjMethods(obj, [source], [omit])`
Bind all the methods from source onto obj, skipping over anything in
the `omit` list. `omit` can be either an array or an object of
boolean values. `source` defaults to `obj` if not specified.
## USAGE
```js
var bindObjMethods = require('bind-obj-methods')
var obj = {
method: () => this.foo,
foo: 'bar'
}
var m = obj.method
m() // undefined
bindObjMethods(obj)
m() // 'bar'
```

View File

@ -0,0 +1,33 @@
module.exports = bindObj
function bindObj (obj, proto, bound) {
bound = bound || Object.create(null)
if (Array.isArray(bound))
bound = bound.reduce(function (set, k) {
set[k] = true
return set
}, Object.create(null))
// don't try to bind constructors, it's weird
bound.constructor = true
proto = proto || obj
Object.keys(proto).forEach(function (k) {
if (typeof obj[k] === 'function' && !bound[k]) {
bound[k] = true
obj[k] = proto[k].bind(obj)
}
})
Object.getOwnPropertyNames(proto).forEach(function (k) {
if (typeof obj[k] === 'function' && !bound[k]) {
bound[k] = true
Object.defineProperty(obj, k, {
value: obj[k].bind(obj),
enumerable: false,
configurable: true,
writable: true
})
}
})
}

View File

@ -0,0 +1,49 @@
{
"_from": "bind-obj-methods@^1.0.0",
"_id": "bind-obj-methods@1.0.0",
"_inBundle": false,
"_integrity": "sha1-T1l5ysFXk633DkiBYeRj4gnKUJw=",
"_location": "/bind-obj-methods",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "bind-obj-methods@^1.0.0",
"name": "bind-obj-methods",
"escapedName": "bind-obj-methods",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/tap"
],
"_resolved": "https://registry.npmjs.org/bind-obj-methods/-/bind-obj-methods-1.0.0.tgz",
"_shasum": "4f5979cac15793adf70e488161e463e209ca509c",
"_spec": "bind-obj-methods@^1.0.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/tap",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/bind-obj-methods/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Bind methods to an object from that object or some other source. Optionally specify a set of methods to skip over.",
"homepage": "https://github.com/isaacs/bind-obj-methods#readme",
"keywords": [],
"license": "ISC",
"main": "bind-obj-methods.js",
"name": "bind-obj-methods",
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/bind-obj-methods.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.0.0"
}

View File

@ -0,0 +1,50 @@
var assert = require('assert')
var bindObj = require('./bind-obj-methods.js')
var obj, m
function makeObj () {
var obj = {
method: function () { return this.foo },
foo: 'bar'
}
Object.defineProperty(obj, 'secretMethod', {
value: function () {
return 'secret' + this.method()
},
enumerable: false,
configurable: true,
writable: true
})
return obj
}
// pretend we already bound secretMethod
obj = makeObj()
bindObj(obj, obj, [ 'secretMethod', 'method' ])
m = obj.method
assert.equal(m(), undefined)
m = obj.secretMethod
assert.throws(m)
obj = makeObj()
bindObj(obj, obj, { secretMethod: true })
m = obj.method
assert.equal(m(), 'bar')
m = obj.secretMethod
assert.throws(m)
obj = makeObj()
bindObj(obj, obj)
m = obj.method
assert.equal(m(), 'bar')
m = obj.secretMethod
assert.equal(m(), 'secretbar')
obj = makeObj()
bindObj(obj, Object.prototype)
m = obj.hasOwnProperty
assert.equal(m('hasOwnProperty'), true)
console.log('TAP version 13\nok\n1..1')