{"versions":{"1.0.0":{"name":"callable-instance2","version":"1.0.0","description":"Instances of classes which are directly callable as functions.","keywords":["callable","class","function","instance","ts","types","typesctript","object"],"homepage":"https://github.com/bluelovers/node-callable-instance#readme","bugs":{"url":"https://github.com/bluelovers/node-callable-instance/issues"},"repository":{"type":"git","url":"git+https://github.com/bluelovers/node-callable-instance.git"},"license":"MIT","author":{"name":"Ryan Patterson"},"main":"index.js","directories":{"test":"test"},"scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{},"gitHead":"73e28aa11f4ef1c5946c6e61664be7d72a907095","_id":"callable-instance2@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"anonymous","email":"codelovers@users.sourceforge.net"},"dist":{"shasum":"133e723bced5d9d8496729189e13103a6cbbaa04","size":2825,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/callable-instance2/-/callable-instance2-1.0.0.tgz","integrity":"sha512-zHat10GllE4v8+9AmUz6SKHgrrHkaYV7VlsxJiA9bsQwXKhFMbQHZns1ubDhIPyEo2zjyvrum9lc6KLNcLKdxg=="},"maintainers":[{"name":"anonymous","email":"codelovers@users.sourceforge.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/callable-instance2_1.0.0_1537832319197_0.6156430339675871"},"_hasShrinkwrap":false,"publish_time":1537832319398,"_cnpm_publish_time":1537832319398,"_cnpmcore_publish_time":"2021-12-17T00:46:14.582Z","contributors":[]},"2.0.0":{"name":"callable-instance2","version":"2.0.0","description":"Instances of classes which are directly callable as functions.","keywords":["callable","class","function","instance","ts","types","typesctript","object","create-by-yarn-tool","create-by-tsdx"],"homepage":"https://github.com/bluelovers/node-callable-instance#readme","bugs":{"url":"https://github.com/bluelovers/node-callable-instance/issues"},"repository":{"type":"git","url":"git+https://github.com/bluelovers/node-callable-instance.git"},"license":"MIT","author":{"name":"Ryan Patterson"},"sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.esm.mjs"},"./package.json":"./package.json","./src/*":"./src/*"},"main":"dist/index.cjs","unpkg":"dist/index.umd.production.min.cjs","module":"dist/index.esm.mjs","types":"dist/index.d.ts","typings":"dist/index.d.ts","directories":{"test":"test"},"scripts":{"coverage":"yarn run test -- --coverage","pretest":"echo pretest","test":"yarn run test:jest","test:jest":"jest --passWithNoTests","test:jest:clearCache":"jest --clearCache","test:jest:coverage":"yarn run test:jest -- --coverage","test:jest:snapshot":"yarn run test:jest -- -u","test:snapshot":"yarn run test -- -u","test:tsd":"ynpx tsd","posttest":"yarn run build","install:frozenLockfile":"yarn-tool install --frozen-lockfile","install:resetLockfile":"yarn-tool install --reset-lockfile","build":"yarn run build:tsdx && yarn run build:dts:copy","build:dts:bundle":"ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle","build:dts:copy":"copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts","build:dts:tsc":"yarn run build:dts:copy && yarn run build:dts:tsc:emit && yarn run build:dts:copy","build:dts:tsc:emit":"tsc --emitDeclarationOnly --declaration --noEmit false","build:tsdx":"ynpx @bluelovers/tsdx build --target node","ci:install":"yarn install --frozen-lockfile && yarn add -W yarn-tool lerna@6 ynpx ts-node ts-jest jest typescript@next @bluelovers/jest-config tsx","ci:build":"echo ci:build","npm:publish":"npm publish","npm:publish:bump":"yarn run version:bump && npm publish","npm:publish:bump:major":"yarn run version:bump:major && npm publish","npm:publish:bump:minor":"yarn run version:bump:minor && npm publish","npm:publish:bump:patch":"yarn run version:bump:patch && npm publish","npm:publish:bump:prerelease":"yarn run version:bump:prerelease && npm publish","ws:fix-all":"yarn-tool fix-all  --overwriteHostedGitInfo","ws:fix-all:resetStaticFiles":"yarn run ws:fix-all -- --resetStaticFiles","preversion":"echo preversion && yarn run test","version":"echo version","version:bump":"yarn-tool version","version:bump:major":"yarn run version:bump -- --bump major","version:bump:minor":"yarn run version:bump -- --bump minor","version:bump:patch":"yarn run version:bump -- --bump patch","version:bump:prerelease":"yarn run version:bump -- --bump prerelease","postversion":"echo postversion","prepublish":"echo prepublish","prepare":"echo prepare","prepublishOnly":"yarn run preversion","prepublishOnly:check-bin":"ynpx --quiet @yarn-tool/check-pkg-bin","prepack":"echo prepack","pack":"echo pack","postpack":"echo postpack","publish":"echo publish","postpublish":"yarn run postpublish:changelog && yarn run postpublish:git:commit && yarn run postpublish:git:tag && yarn run postpublish:git:push","postpublish:changelog":"ynpx --quiet @yarn-tool/changelog && git add ./CHANGELOG.md","postpublish:git:commit":"git commit -m \"chore(release): publish\" . & echo postpublish:git:commit","postpublish:git:push":"git push --follow-tags","postpublish:git:tag":"ynpx --quiet @yarn-tool/tag","postpublishOnly":"echo postpublishOnly","ncu":"yarn-tool ncu -u","tsc:showConfig":"ynpx get-current-tsconfig -p"},"dependencies":{},"devDependencies":{"@bluelovers/tsconfig":"^1.0.35","@types/jest":"^29.5.12"},"packageManager":"yarn@1.22.19","_id":"callable-instance2@2.0.0","gitHead":"98fc56ef0cb088b9747ad6cc376c5e69a004e716","_nodeVersion":"21.6.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-JnKXOis0hmsygHVe0yVYEO3R6Y+VR1a/Sl7aha7KZHSq7mH4bkw2x1a58VXwzaQcPUZFvayZq2mYRgIFn+Muyw==","shasum":"6de789becd955355ba449b4cb637240e568ce34d","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/callable-instance2/-/callable-instance2-2.0.0.tgz","fileCount":17,"unpackedSize":25148,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFmsOrvo5KNvxj1leRgd1bf4Q0pMaYRamc3NILhyZJ0yAiAxQIKDytp+gCsCcnv3kiw2boptLDLikxoD+6g+Bh0Y6g=="}],"size":6116},"_npmUser":{"name":"anonymous","email":"codelovers@users.sourceforge.net"},"maintainers":[{"name":"anonymous","email":"codelovers@users.sourceforge.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/callable-instance2_2.0.0_1709750345447_0.023600164657725742"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-06T18:39:05.641Z","publish_time":1709750345641,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"2.0.0"},"name":"callable-instance2","time":{"created":"2022-01-28T00:25:37.092Z","modified":"2024-03-06T18:40:55.442Z","1.0.0":"2018-09-24T23:38:39.398Z","2.0.0":"2024-03-06T18:39:05.641Z"},"readme":"# node-callable-instance\n\nThis module allows you to create an ES6 class that is callable as a function. The invocation is sent to one of the object's normal prototype methods.\n\n## Installation\n\n```\nnpm install callable-instance2\n```\n\n## Usage\n\n`ExampleClass` instances have all of the normal properties and methods, but are actually functions as well.\n\n```ts\nimport CallableInstance from 'callable-instance2/import';\nimport { CallableInstance } from 'callable-instance2/import';\nimport CallableInstance = require('callable-instance2');\nconst CallableInstance = require('callable-instance2');\n```\n\n```ts\nimport CallableInstance = require('callable-instance2');\n\nclass ExampleClass extends CallableInstance {\n  constructor() {\n    // CallableInstance accepts the name of the property to use as the callable\n    // method.\n    super('instanceMethod');\n  }\n\n  instanceMethod() {\n    console.log(\"instanceMethod called!\");\n  }\n}\n\nvar test = new ExampleClass();\n// Invoke the method normally\ntest.instanceMethod();\n// Call the instance itself, redirects to instanceMethod\ntest();\n// The instance is actually a closure bound to itself and can be used like a\n// normal function.\ntest.apply(null, [ 1, 2, 3 ]);\n```\n\n### Inherited Properties\n\nAll instances of CallableMethod are also an instances of [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function), and have all of Function's properties.\n\nLibraries that accept functions will expect that they behave as Function objects do. For example, if you alter the semantics of the `call` or `apply` methods, library code may fail to work with your callable instance. In these cases, you can simply bind the instance method to the callable instance and pass that instead (e.g. `test.instanceMethod.bind(test)`).\n\nThis can also cause problems if your derived class wants to have a `name` or `length` property, which are built-in properties and not configurable by default. You can have your class disable the built-in descriptors of these properties to make them available for your use.\n\n```ts\nvar test = new ExampleClass();\ntest.name = \"hello!\"\nconsole.log(test.name); // Will print 'instanceMethod'\n\nclass NameableClass extends CallableInstance {\n  constructor() {\n    super('instanceMethod');\n    Object.defineProperty(this, 'name', {\n      value: void 0,\n      enumerable: true,\n      writeable: true,\n      configurable: true\n    });\n  }\n\n  instanceMethod() {\n    console.log(this.name);\n  }\n}\n\ntest = new NameableClass();\ntest.name = \"hello!\";\nconsole.log(test.name); // Will print 'hello!'\n```\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Credits\n\nInformation for the implementation came from [this StackOverflow answer](http://stackoverflow.com/a/36871498/123899).\n\n## License\n\nDistributed under the MIT license.","users":{}}