{"_id":"@ansi-art/async-context","_rev":"1-f8d855bfd0fd6a45ea5d509c6fb2a8c0","name":"@ansi-art/async-context","dist-tags":{"latest":"3.0.0-alpha4"},"versions":{"1.0.1":{"name":"@ansi-art/async-context","version":"1.0.1","keywords":[],"author":{"url":"http://abbeyhawksparrow.com","name":"Abbey Hawk Sparrow","email":"khrome"},"license":"MIT","_id":"@ansi-art/async-context@1.0.1","maintainers":[{"name":"khrome","email":"abbey@khrome.net"}],"contributors":[],"homepage":"https://github.com/ansi-art/async-context","bugs":{"url":"https://github.com/ansi-art/async-context/issues"},"dist":{"shasum":"5872818602eb136aba9d39a5f1b38acba7403e95","tarball":"https://registry.npmjs.org/@ansi-art/async-context/-/async-context-1.0.1.tgz","fileCount":17,"integrity":"sha512-pexiAFVaW0eDmI7lJXcS/HgvWZTvrU0Xpw0wZbGFAnX6umNplnF633j4bj2L9h6E/XlXhhFx8SqSfJiILOvRxQ==","signatures":[{"sig":"MEUCIQDRtRSXKIUgUVPZ1n7LyeqJtxzzGRynR/cYfoa3LbPskwIgIMsVJkFitHu2nKu1Azou28iiJWPjrToPi12NkrNDZDs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29506},"main":"dist/index.mjs","moka":{"stub":"node_modules/@open-automaton/moka/src/stub.mjs","shims":{"chai":"node_modules/chai/chai.js","browser-or-node":"node_modules/browser-or-node/src/index.js"},"stubs":["express","module","path"],"chrome":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"chromium"}},"safari":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"webkit"}},"firefox":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"firefox"}}},"type":"module","module":"src/index.mjs","exports":{".":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./kitchen-sync":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"},"./src/index.mjs":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./dist/index.cjs":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./src/kitchen-sync.mjs":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"},"./dist/kitchen-sync.cjs":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"}},"gitHead":"897e379c147a8350a69543c7c151ffaa61adea07","scripts":{"lint":"eslint src/*.mjs test/*.mjs","test":"npm run import-test; npm run browser-test; npm run require-test","prepare":"husky install","build-docs":"build-jsdoc docs","build-types":"build-jsdoc types","import-test":"mocha test/test.mjs","browser-test":"moka --server . --local-browser --relaxed --prefix ../ test/test.mjs","local-server":"open 'http://localhost:8085/' ; npx http-server -p 8085","require-test":"mocha test/test.cjs","build-commonjs":"./node_modules/@environment-safe/commonjs-builder/bin/build.mjs","container-test":"docker build . -t environment-safe-package.json -f ./containers/test.dockerfile; docker logs --follow \"$(docker run -d environment-safe-package.json)\"","headless-chrome-test":"moka --server . --browser chrome --relaxed --prefix ../ test/test.mjs","headless-safari-test":"moka --server . --browser safari --relaxed --prefix ../ test/test.mjs","headless-browser-test":"npm run headless-chrome-test; npm run headless-firefox-test; npm run headless-safari-test","headless-firefox-test":"moka --server . --browser firefox --relaxed --prefix ../ test/test.mjs","add-generated-files-to-commit":"git add docs/*.md; git add src/*.d.ts; git add dist/*.cjs"},"_npmUser":{"name":"khrome","email":"abbey@khrome.net"},"commonjs":"dist/index.cjs","repository":{"url":"git+https://github.com/ansi-art/async-context.git","type":"git"},"_npmVersion":"9.5.1","description":"A construct for chainable contexts","directories":{},"_nodeVersion":"18.16.0","dependencies":{"browser-or-node":"^2.1.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.7","husky":"^8.0.3","mocha":"^10.2.0","eslint":"^8.43.0","@babel/cli":"^7.22.5","@babel/core":"^7.22.5","@open-automaton/moka":"^0.0.4","@environment-safe/chai":"^0.1.0","@environment-safe/jsdoc-builder":"^0.0.2","babel-plugin-search-and-replace":"^1.1.1","@environment-safe/commonjs-builder":"^0.0.3","babel-plugin-transform-import-meta":"^2.2.0","@babel/plugin-transform-modules-commonjs":"^7.22.5"},"_npmOperationalInternal":{"tmp":"tmp/async-context_1.0.1_1693792865182_0.7255858831005677","host":"s3://npm-registry-packages"}},"3.0.0-alpha4":{"name":"@ansi-art/async-context","version":"3.0.0-alpha4","type":"module","main":"dist/index.mjs","module":"src/index.mjs","commonjs":"dist/index.cjs","exports":{".":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./src/index.mjs":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./dist/index.cjs":{"import":"./src/index.mjs","require":"./dist/index.cjs"},"./src/kitchen-sync.mjs":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"},"./dist/kitchen-sync.cjs":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"},"./kitchen-sync":{"import":"./src/kitchen-sync.mjs","require":"./dist/kitchen-sync.cjs"}},"homepage":"https://github.com/ansi-art/async-context","description":"A construct for chainable contexts","keywords":[],"author":{"name":"Abbey Hawk Sparrow","email":"khrome","url":"http://abbeyhawksparrow.com"},"contributors":[],"repository":{"type":"git","url":"git+https://github.com/ansi-art/async-context.git"},"bugs":{"url":"https://github.com/ansi-art/async-context/issues"},"moka":{"firefox":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"firefox"}},"chrome":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"chromium"}},"safari":{"engine":"@open-automaton/playwright-mining-engine","options":{"type":"webkit"}},"stub":"node_modules/@open-automaton/moka/src/stub.mjs","stubs":["express","module","path"],"shims":{"chai":"node_modules/chai/chai.js","browser-or-node":"node_modules/browser-or-node/src/index.js"}},"license":"MIT","devDependencies":{"@babel/cli":"^7.22.5","@babel/core":"^7.22.5","@babel/plugin-transform-modules-commonjs":"^7.22.5","@environment-safe/chai":"^0.1.0","@environment-safe/commonjs-builder":"^0.0.3","@environment-safe/jsdoc-builder":"^0.0.2","@open-automaton/moka":"^0.0.4","babel-plugin-search-and-replace":"^1.1.1","babel-plugin-transform-import-meta":"^2.2.0","chai":"^4.3.7","eslint":"^8.43.0","husky":"^8.0.3","mocha":"^10.2.0"},"scripts":{"lint":"eslint src/*.mjs test/*.mjs","test":"npm run import-test; npm run browser-test; npm run require-test","import-test":"mocha test/test.mjs","require-test":"mocha test/test.cjs","build-commonjs":"./node_modules/@environment-safe/commonjs-builder/bin/build.mjs","local-server":"open 'http://localhost:8085/' ; npx http-server -p 8085","headless-browser-test":"npm run headless-chrome-test; npm run headless-firefox-test; npm run headless-safari-test","headless-chrome-test":"moka --server . --browser chrome --relaxed --prefix ../ test/test.mjs","headless-firefox-test":"moka --server . --browser firefox --relaxed --prefix ../ test/test.mjs","headless-safari-test":"moka --server . --browser safari --relaxed --prefix ../ test/test.mjs","browser-test":"moka --server . --local-browser --relaxed --prefix ../ test/test.mjs","container-test":"docker build . -t environment-safe-package.json -f ./containers/test.dockerfile; docker logs --follow \"$(docker run -d environment-safe-package.json)\"","build-docs":"build-jsdoc docs","build-types":"build-jsdoc types","add-generated-files-to-commit":"git add docs/*.md; git add src/*.d.ts; git add dist/*.cjs","prepare":"husky install"},"dependencies":{"browser-or-node":"^2.1.1"},"_id":"@ansi-art/async-context@3.0.0-alpha4","gitHead":"b4ce77da68161bffe09062a8514aa711e2671285","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-Knqn32RvuEQGQujSzUsCQEaunaNOPr+oxBuzrJvQSnRwV3eSGIF81EDWtVHBuXC5b2XZvZHz62SlaLfcZzq5gQ==","shasum":"a928a83086b5169852377e86ed53b009b0ab5030","tarball":"https://registry.npmjs.org/@ansi-art/async-context/-/async-context-3.0.0-alpha4.tgz","fileCount":17,"unpackedSize":29513,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD4vXmrrvcfpPp1GGEGH5oC071e0xNOR3gqx5I27MLbfwIhAKgyR9/akn4fU6RmFbAx7qLnD/oyFoAi2PUqFeE15d5U"}]},"_npmUser":{"name":"khrome","email":"abbey@khrome.net"},"directories":{},"maintainers":[{"name":"khrome","email":"abbey@khrome.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-context_3.0.0-alpha4_1728099779784_0.13464287771860506"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-04T02:01:05.054Z","modified":"2024-10-05T03:43:00.238Z","1.0.1":"2023-09-04T02:01:05.383Z","3.0.0-alpha4":"2024-10-05T03:42:59.996Z"},"bugs":{"url":"https://github.com/ansi-art/async-context/issues"},"author":{"name":"Abbey Hawk Sparrow","email":"khrome","url":"http://abbeyhawksparrow.com"},"license":"MIT","homepage":"https://github.com/ansi-art/async-context","keywords":[],"repository":{"type":"git","url":"git+https://github.com/ansi-art/async-context.git"},"description":"A construct for chainable contexts","contributors":[],"maintainers":[{"name":"khrome","email":"abbey@khrome.net"}],"readme":"@ansi-art/async-context\n=======================\nA construct for chainable contexts which use async functions compatible with callbacks or promises.\n\nUsage\n-----\n\n### Making a context\n\nAssuming we have an object with a function that takes an object and returns a transformed version of that object:\n\n```javascript\nlet str ='';\nconst myObject = {\n    foo: (item, callback)=>{\n        str += `foo ${str}`\n        callback(null, str);\n    }\n};\n```\n\nTake that object and make a context using it:\n\n```javascript\nimport { asyncContext } from '@ansi-art/async-context';\nconst context = asyncContext(myObject);\nconst value = await context.foo().foo().foo();\n// value === \"foo foo foo\"\n```\n\n### Using `kitchen-sync`\n\n`kitchen-sync` allows you to support both callbacks and promises with *no* stack fragmentation in the event callbacks are used, allowing for simpler debugging internally to a set of libraries, for example, but allowing external use of more modern idioms.\n\n```javascript\nimport { kitchenSync } from `@ansi-art/async-context/kitchen-sync`;\n(async ()=>{\n    const fn = (arg, cb){\n        const callback = kitchenSync(cb);\n        someFunctionThatTakesCallbacks(callback);\n        return callback.return;\n    }\n    const result = await fn(someArgValue);\n})();\n```\n\nThat's all.\n\nTesting\n-------\n\nRun the es module tests to test the root modules\n```bash\nnpm run import-test\n```\nto run the same test inside the browser:\n\n```bash\nnpm run browser-test\n```\nto run the same test headless in chrome, firefox and safari:\n```bash\nnpm run headless-browser-test\n```\n\nto run the same test inside docker:\n```bash\nnpm run container-test\n```\n\nRun the commonjs tests against the `/dist` commonjs source (generated with the `build-commonjs` target).\n```bash\nnpm run require-test\n```\n\nDevelopment\n-----------\nAll work is done in the .mjs files and will be transpiled on commit to commonjs and tested.\n\nIf the above tests pass, then attempt a commit which will generate .d.ts files alongside the `src` files and commonjs classes in `dist`\n\n","readmeFilename":"README.md"}