{"id":24618103,"url":"https://github.com/winkgroup/mega","last_synced_at":"2025-03-18T21:55:40.642Z","repository":{"id":57748922,"uuid":"523449477","full_name":"WINKgroup/mega","owner":"WINKgroup","description":"Wrapper library for mega.nz command line tools","archived":false,"fork":false,"pushed_at":"2024-03-24T18:20:00.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-25T19:22:35.276Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WINKgroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-10T18:10:52.000Z","updated_at":"2023-01-31T20:11:13.000Z","dependencies_parsed_at":"2024-09-25T16:51:59.198Z","dependency_job_id":"499d6eaa-61f6-4408-9376-c25f1545240e","html_url":"https://github.com/WINKgroup/mega","commit_stats":null,"previous_names":["winkgroup/mega-cmd"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WINKgroup%2Fmega","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WINKgroup%2Fmega/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WINKgroup%2Fmega/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WINKgroup%2Fmega/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WINKgroup","download_url":"https://codeload.github.com/WINKgroup/mega/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244313884,"owners_count":20433011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-24T23:49:47.549Z","updated_at":"2025-03-18T21:55:40.618Z","avatar_url":"https://github.com/WINKgroup.png","language":"TypeScript","readme":"# mega\nLibrary for mega.nz. It suppose you have mega-cmd installed and available from any directory.\n\nIt provides two main classes:\n- **MegaCmd**: a wrapper for mega terminal commands\n- **StorageMega**: an abstraction to manage mega repository as a storage\n\n## Install\n```\nnpm install @winkgroup/mega\n```\n\n## MegaCmd\nThis is basically a wrapper for mega-* commands. Mapped commands are:\n- df \n- get\n- login\n- logout\n- ls\n- proxy\n- put\n- rm\n- whoAmI\nfor further explanation you can run mega-help\n\nSince you can be logged only with one account a time, a locking system is provided to avoid to have multiple instances of MegaCmd running at the same time.\nHere an example to get a megaCmd instance:\n```js\n    let megaCmd = await MegaCmd.get('myLockingWord') // returns instance of MegaCmd\n    let megaCmd2 = await MegaCmd.get('someOtherWord') // returns null\n    MegaCmd.unlock('myLockingWord')\n    megaCmd2 = await MegaCmd.get('someOtherWord')// now returns instance of MegaCmd\n\n    const booleanResult = await megaCmd2.login('user@mail.com', 'myPassword')\n    if (booleanResult) {\n        const result = megaCmd2.df()\n        console.log(result) // free bytes, etc...\n    }\n    megaCmd2.unlock('someOtherWord')\n```\n\nYou can also decide to wait until megaCmd is available again and eventually set a timeout (*default 1 hour*).\nIn this example it will return an instance of megaCmd as soon as megaCmd is available or will wait 10 minutes for it:\n```js\n    const megaCmd = await MegaCmd.getOrWait('anyLockingWord', 600)\n```\n**you can avoid the timeout setting the second param to 0**\n\nYou can check by yourself if megaCmd is idle using `MegaCmd.isIdle()`: it will check if you are online and no other megaCmd instance locked the resource.\n\nYou can also subscribe the idle event that will be fired when you will be online and no other megaCmd have locked the resource. This method uses [EventQueue](https://github.com/WINKgroup/event-queue) library, this means you don't need to remove the listener when is fired and any listener is fired in sequence so the is unlikely that when the callback is fired you will need to wait any longer. Here an example:\n```js\n    const handle = MegaCmd.onIdle.add(() =\u003e {\n        console.log('put here some code has to run when MegaCmd is in idle state')\n        ...\n    })\n\n    ...\n    // later on if you need to delete the listener of any reason:\n    MegaCmd.onIdle.remove(handle)\n```\n\n### get and put commands\nThese two commands can manage also the progress during the transfer providing an EventEmitter instance, here and example:\n```js\n\n    const megaCmd = await MegaCmd.get('myLockingWord')\n    const onTransfer = new EventEmitter()\n    onTransfer.on('progress', (data) =\u003e {\n        console.log(`${ data.bytes } of ${ data.totalBytes } (${ data.percentage}%) transferred`)\n    })\n    await megaCmd.login('user@mail.com', 'myPassword')\n    await megaCmd.get('myRemoteFilePath', 'localPath', { onTransfer: onTransfer }) // this will output the progress during the transfer session\n    ...\n```\n\n## Playground as Interactive Integration Test\nunder *playground* folder some extra code is provided to make some interctive integration tests.\nThis is a command line interface to manage the storage of a specific Mega account.\nHere the steps to run this test:\n1. copy *playground/config.template.json* to *playground/config.json*\n1. edit *playground/config.json* setting the credetials of a real mega account\n2. run ```npm run playground``` or ```yarn playground```\n\n## Maintainers\n* [fairsayan](https://github.com/fairsayan)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinkgroup%2Fmega","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinkgroup%2Fmega","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinkgroup%2Fmega/lists"}