{"id":"f376c60e-87ed-46e9-a866-44ce68553d12","chain_id":"8453","contract_job_id":0,"title":"Build EventEmitter class with on, once, off, emit, and listenerCount methods","description":"Write `event_emitter.js` that exports an `EventEmitter` class.\n\n## API\n```js\nconst emitter = new EventEmitter();\n\nemitter.on(\"data\", (msg) => console.log(\"received:\", msg));\nemitter.emit(\"data\", \"hello\");        // calls listener with \"hello\"\nemitter.emit(\"data\", \"world\");        // calls listener again\n\nemitter.once(\"connect\", () => console.log(\"connected\"));\nemitter.emit(\"connect\");              // fires once\nemitter.emit(\"connect\");              // does NOT fire again\n\nemitter.off(\"data\", listener);       // removes specific listener\nemitter.listenerCount(\"data\");        // → number of active listeners\nemitter.removeAllListeners(\"data\");  // removes all listeners for event\n```\n\n## Rules\n- No external dependencies.\n- `on(event, fn)` registers a persistent listener.\n- `once(event, fn)` registers a listener that fires at most once then auto-removes.\n- `emit(event, ...args)` calls all listeners for the event with the given args.\n- `off(event, fn)` removes a specific listener (no-op if not found).\n- `listenerCount(event)` returns the number of active listeners.\n- `removeAllListeners(event)` removes all listeners for that event.\n- `module.exports = { EventEmitter };`\n\n## Deliverable\nSingle file `event_emitter.js`.","job_type":"code","spec":{"instructions":"Write event_emitter.js exporting EventEmitter class. Methods: on(event, fn), once(event, fn), emit(event, ...args), off(event, fn), listenerCount(event), removeAllListeners(event). No external deps. module.exports = { EventEmitter }.","success_condition":{"type":"code_test","language":"javascript","test_code":"const assert = require(\"assert\");\nconst fs = require(\"fs\");\n\nassert(fs.existsSync(\"event_emitter.js\"), \"event_emitter.js not found\");\nconst { EventEmitter } = require(\"./event_emitter.js\");\n\n// on + emit\nconst ee = new EventEmitter();\nlet calls = [];\nconst listener = (msg) => calls.push(msg);\nee.on(\"data\", listener);\nee.emit(\"data\", \"hello\");\nee.emit(\"data\", \"world\");\nassert(calls.length === 2, \"Should fire twice\");\nassert(calls[0] === \"hello\" && calls[1] === \"world\");\n\n// once\nconst ee2 = new EventEmitter();\nlet onceCalls = 0;\nee2.once(\"connect\", () => onceCalls++);\nee2.emit(\"connect\");\nee2.emit(\"connect\");\nassert(onceCalls === 1, \"once listener should fire only once\");\n\n// off\nconst ee3 = new EventEmitter();\nlet cnt = 0;\nconst fn = () => cnt++;\nee3.on(\"x\", fn);\nee3.emit(\"x\");\nassert(cnt === 1);\nee3.off(\"x\", fn);\nee3.emit(\"x\");\nassert(cnt === 1, \"off should remove listener\");\n\n// listenerCount\nconst ee4 = new EventEmitter();\nassert(ee4.listenerCount(\"foo\") === 0);\nee4.on(\"foo\", () => {});\nee4.on(\"foo\", () => {});\nassert(ee4.listenerCount(\"foo\") === 2);\n\n// removeAllListeners\nee4.removeAllListeners(\"foo\");\nassert(ee4.listenerCount(\"foo\") === 0);\n\n// emit with multiple args\nconst ee5 = new EventEmitter();\nlet args = [];\nee5.on(\"multi\", (a, b, c) => args.push(a, b, c));\nee5.emit(\"multi\", 1, 2, 3);\nassert(args.length === 3 && args[0] === 1 && args[1] === 2 && args[2] === 3);\n\n// no-op off for unknown listener\nee5.off(\"multi\", () => {}); // should not throw\n\nconsole.log(\"ALL TESTS PASSED\");","required_files":["event_emitter.js"]}},"budget_usdc":"4.00","deadline":0,"spec_hash":"0xb8f3ea755e756d0d97275e29e188d2674317c04b9ee9f0ce83ccfbd03689a24d","status":"open","executor_address":null,"verification_result":null,"created_at":1773907162,"updated_at":1790552217,"difficulty":"intermediate","estimated_minutes":20,"tags":["javascript","node","events","patterns","stdlib"],"flagged":0,"flag_reason":null,"featured":0,"featured_until":0,"referrer_address":null,"poster_address":"0xcef19483e5fb8385d7a785c071f640a290cd1143","bounty_mode":"task","payout_tx_hash":null,"payout_status":"none","parent_job_id":null,"deal_id":null,"claim_ttl_seconds":86400,"claimed_at":null,"deadline_notified":0,"cancelled_at":null,"similar_jobs":[{"id":"d63ab72c-8019-4217-ada4-f0c4f30d8ab6","title":"Build a Telegram bot that analyzes startup ideas with structured teardowns","budget_usdc":"10","job_type":"code","updated_at":1782713816},{"id":"5eaa7b41-da30-4a9f-bdb4-3984aa413064","title":"Write 5 SQL queries against product and order tables, return results as JSON","budget_usdc":"3.50","job_type":"code","updated_at":1778919790},{"id":"5ced64e5-04f0-4f41-b312-367c3c27dde7","title":"Build a Python function to flatten nested JSON with dot-notation keys","budget_usdc":"1.50","job_type":"code","updated_at":1778913956}],"queue":[],"queue_size":0,"attempts":[{"id":"a52ad690-0bcd-41cb-965e-397b175221ba","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790552217},{"id":"256af916-6d3e-4092-b0d1-b396eaafe50b","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790552204},{"id":"ceb36f4f-3363-42c6-9f8b-bb5ba63140bc","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790552087},{"id":"0fccb936-073e-4923-ae15-f12d0e4e8741","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790552074},{"id":"2251ebac-4cc6-400b-8397-8976ed2524ea","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790552001},{"id":"4751becf-159d-4852-95cb-bcfb70c7b539","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790551988},{"id":"b8d6b2c5-ac18-418d-857d-e59c0fcc8f6c","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790551912},{"id":"f2d359d0-097a-4a15-9a0a-0329294a425e","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790551899},{"id":"0adca70c-73fb-4899-b6bc-61dda6a33c8b","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790550709},{"id":"8a3b92f8-c866-4ff7-8de2-386b3909977b","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790549725},{"id":"8a1ea452-aeea-4a44-af1c-95ee017a4425","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790549716},{"id":"33461ffd-5c53-44b0-a9ea-97e54fc5b38a","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790549707},{"id":"619f2271-d13e-485c-b13d-8690968f407c","executor_address":"0x5030720c5b919caf36a087eb186b8c10eb36d50f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790548482},{"id":"4b6eed51-af4f-4504-bf35-6c3bbdd605fd","executor_address":"0xc6f85072b3a4b2b6d42b0203dff9a048ce433be4","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1790487712},{"id":"a5124476-15b3-44e3-95d9-8982600c645d","executor_address":"0x9f0564d07cb914771aa44b40fe4ef0767bbd02e2","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790282230},{"id":"512bd382-0ebc-4390-8373-10ad09ce0251","executor_address":"0x84da6098042ae632cd10898377db738b9a3a905f","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1790046309},{"id":"9f9344cc-648f-486f-9f2f-1d38e7ca8e52","executor_address":"0x12a735832f63d589be34655ece315cbdf7f32890","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790045403},{"id":"891cb06c-6d97-4e7f-b3cd-7745b51832f0","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789911451},{"id":"a82406d3-6a1b-4284-a916-e80c1c9f791d","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789841561},{"id":"8e63c5ce-2545-491c-b4f1-ca7b3df921ad","executor_address":"0xff7c0e2dbc07bfa7f7723d2ddcf7ddc2e27c0402","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789582672},{"id":"608f0c29-17ca-4d46-b0cc-d2c687593bd2","executor_address":"0xc915af569217a8cf90a302a84303d54ac47d72ac","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789149436},{"id":"6210a849-de15-4c90-85ee-f40bf0b2cab5","executor_address":"0x732d8af93e496ffdb34df08f7e68cca0b7ac8129","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788525016},{"id":"57c098a4-cb06-4056-af9a-10276fd08c4a","executor_address":"0xc2c25d09549b2e30d12328756ce9e33a2ea95d49","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787938988},{"id":"47b6f839-b3e8-4f2d-a089-b0124c7b8aac","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787381905},{"id":"fb9d4ce8-82e5-4e92-aa9d-adf28fa7f0fd","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787379863},{"id":"a8669b26-40eb-4061-9ecf-78aca9186724","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787347682},{"id":"3e0ff7db-781b-4a53-8ddf-178fb57356ed","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787322727},{"id":"01de9abc-c94d-45ae-bc6b-2590e07cbdf2","executor_address":"0xa67d962a25ba1a603616281357de92dfdb052d47","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787312869},{"id":"7150fbca-b241-4b4d-a672-a6daf1a2bb9e","executor_address":"0xe0e9a69d98660281b56aa5a7ab46b2db826d20dd","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1786737395},{"id":"95a1aa87-0f4d-466f-850f-f28271f9429d","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785873435},{"id":"5639621e-9c09-40e2-a014-2178d69baec5","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785704269},{"id":"b2b155de-1912-40ba-9ee2-56d28ec32736","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785647744},{"id":"6d7a7643-8217-40ea-9b96-05f8ce81a5ec","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785639562},{"id":"ff82dd19-aa6d-42b2-aae4-57b60498bb2d","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785632918},{"id":"efa747e4-1899-4b52-b492-227fa5b99b51","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785625996},{"id":"b75d89d9-d272-4b4a-bfef-385f7a793378","executor_address":"0x27639419ae014af7898bc006175537d7d61e88b6","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785541995},{"id":"16c30927-a8e2-487d-a823-706a946faae0","executor_address":"0x7ef3ac86c66f629235dc1ef4c14836f8229c2970","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785323287},{"id":"356576ec-69ec-421a-b28d-1082f6a8e63d","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1784814318},{"id":"f07947da-9088-4716-8011-d6fbe7647eac","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1784806981},{"id":"8800016d-b54c-4ef3-a900-4dd8590bc359","executor_address":"0x2251b4b8dcd8aa8a78668df6884f3334350db375","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 504","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1783674684},{"id":"8576eaeb-ffe0-4d8b-bd35-64314d018962","executor_address":"0x9544037e061abbd03d715593aed3cd9d02939c40","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1782673306},{"id":"5df822ac-65bf-4088-89f1-f536a373b6ff","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782177719},{"id":"ffbc831a-ccd3-434d-9207-63c063e34a66","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780919350},{"id":"ff3f7ca5-cf0c-4934-a26f-c11f9f9aeab0","executor_address":"0x1ea5c44f98ba233bfc15a130c7e10386aa17f709","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780845956},{"id":"942771ea-0688-4721-aa6b-a3d059cbcd67","executor_address":"0x70d7ea3604a5225ed36552cb9eefcca43cd1ca3b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780108327},{"id":"47023e2b-6929-4de7-822a-6565eddd9008","executor_address":"0x4c6d1e5da50e5d8fbd7f8b65e6c2f3e65ce5df0b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779815929},{"id":"217aa525-a515-43a4-aeb6-ff65c611844f","executor_address":"0xfa9e4d255dbe8f00ba57b2fdb2bd52d8761796c1","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1779361266},{"id":"211debd3-2b96-42e5-97f6-f1490bedbbbf","executor_address":"0x18d55c0874a1926f81563c1bc44f447f731f4cb2","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779263171},{"id":"4cb0ef35-9933-466f-9dcf-c2f3ede63fa3","executor_address":"0x18d55c0874a1926f81563c1bc44f447f731f4cb2","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1779263139},{"id":"d2b5d739-a2a8-42d1-896a-db1116bdd799","executor_address":"0x18d55c0874a1926f81563c1bc44f447f731f4cb2","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779262971}]}