{"id":19250787,"url":"https://github.com/oakfang/libjs","last_synced_at":"2025-02-23T16:37:01.440Z","repository":{"id":18031239,"uuid":"21069511","full_name":"oakfang/libjs","owner":"oakfang","description":"Making scoping better.","archived":false,"fork":false,"pushed_at":"2014-06-21T15:55:21.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-05T06:26:52.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://oakfang.github.io/libjs","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oakfang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-21T13:49:22.000Z","updated_at":"2014-06-21T15:55:21.000Z","dependencies_parsed_at":"2022-08-26T10:11:50.743Z","dependency_job_id":null,"html_url":"https://github.com/oakfang/libjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakfang%2Flibjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakfang%2Flibjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakfang%2Flibjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakfang%2Flibjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oakfang","download_url":"https://codeload.github.com/oakfang/libjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240347573,"owners_count":19787227,"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":"2024-11-09T18:18:41.795Z","updated_at":"2025-02-23T16:37:01.414Z","avatar_url":"https://github.com/oakfang.png","language":"JavaScript","readme":"libjs\n=====\n\nMaking scoping better.\n\n### Welcome to LibJS.\nThis modular library is here to make sure you do not use code you do not need.\n\n### It's all about the modules\nWith LibJS, you divide your code into modules, like so:\n\n```\nlib.module('spam', function(moduleA, moduleB) {\n    var foo = moduleB.thingify('bar' * moduleA.CONST);\n    function poof (obj) {\n        return typeof obj === 'undefined' ? foo : bar;\n    }\n\n    return {poof: poof};\n});\n```\n\nEach module is registered to a global library of modules (obviously, you might as well create a local Lib, if you so desire).\n\nThe module's parameters (i.e. moduleA and moduleB, above) are also modules loaded into the lib. Just make sure they're loaded up.\n\nThen, you simply register your *main*:\n```\nlib.main(function (spam) {\n    // ...\n});\n```\n\nMake sure to call it after loading all modules.\n\n### But what do I do with all other published libraries I have?\nWhat a great question to have! Lets say you wish to use `jQuery.min.js`. Well, first of all, **don't put it as a script tag**. I know, I told you to make sure everything is loaded before using main. I kind of lied. See, you *can* specify a requirement you haven't loaded, but what this will do is search your `libpath` (which you can change prior to your man declaration thus: `lib.modulePath('/static/js').main(...);`) for `moduleName.js` and insert it dynamically into the dom. It will also harvest all changes to the global scope made by the script and move them into the module's scope.\n\n### But, sir, `jQuery.min` is NOT a legal parameter name!\nRight you are. You can use the aliasing syntax for that:\n```\nlib.module('myModule', function(/* jQuery.min */jquery){...});\n```\nThis will load jQuery.min.js as you jquey parameter. Isn't that just neat?\n\n### I just wish you had some better syntax for it\nWell, if you're not above using `sweet.js`, there's some cool features it adds. You should run `libc` from the `compiler` directory (using python2.7) with a single argument that is your directory of .sjs files.\n\nWhat's so great about the sweet support? Well, this:\n```\nmodule spam requires (moduleA, moduleB) {\n   defines {\n       sub moduleB.thingify;\n       subas moduleA.CONST, C;\n       var foo = thingify('bar' * C);\n       function poof (obj) {\n          return typeof obj === 'undefined' ? foo : bar;\n       }\n   }\n   exports {poof: poof}\n}\n```\n\n### What's in it for me?\nWell, not much, yet. Currently, there are a few cool modules that ship with `lib.js` (which you don't have you use, obviously). You can look at the demo page, and see, for example, the uses of `lib-route` and it's `libRoute` module. More features (especially regarding `lib-dom`) are under active development.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foakfang%2Flibjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foakfang%2Flibjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foakfang%2Flibjs/lists"}