{"id":19777448,"url":"https://github.com/ilib-js/ilib-es6","last_synced_at":"2025-02-28T05:50:32.280Z","repository":{"id":33196150,"uuid":"153824715","full_name":"iLib-js/ilib-es6","owner":"iLib-js","description":"ES6 wrappers around the ilib classes so that you can import just what you need and use the classes with promises","archived":false,"fork":false,"pushed_at":"2024-02-26T03:36:08.000Z","size":436,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-11T01:49:47.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iLib-js.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}},"created_at":"2018-10-19T18:21:20.000Z","updated_at":"2021-11-30T02:00:18.000Z","dependencies_parsed_at":"2023-11-22T02:24:24.103Z","dependency_job_id":"26c9b7c8-9968-4a85-862a-78615787e121","html_url":"https://github.com/iLib-js/ilib-es6","commit_stats":{"total_commits":127,"total_committers":3,"mean_commits":"42.333333333333336","dds":0.3385826771653543,"last_synced_commit":"b9f7561b8e3936e9c88d04840d4f987c6da8e1f5"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-es6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-es6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-es6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-es6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iLib-js","download_url":"https://codeload.github.com/iLib-js/ilib-es6/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241107730,"owners_count":19910975,"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-12T05:24:55.689Z","updated_at":"2025-02-28T05:50:32.271Z","avatar_url":"https://github.com/iLib-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003e :warning: **Deprecation Notice** :warning:\n\u003e This repository has been deprecated. Please use the corresponding package from the [iLib-js monorepo](https://github.com/iLib-js/ilib-mono) instead.\n\n# ilib-es6\n\nES6 wrappers around the ilib classes so that you can import just what you need and use\nthe classes with promises.\n\nUsage\n-----\n\nAll classes that ilib contains are echoed here in ilib-es6. You may use these as you\nhad before with the exact same API. However, there are a few additional methods and\nother differences.\n\nIncluding Classes\n-----------------\n\nWith ilib-es6, you import classes instead of requiring them.\n\nold syntax with regular ilib:\n\n```\nvar AddressFmt = require(\"ilib/lib/AddressFmt.js\");\n```\n\n(This old syntax is still supported, though.)\n\nnew syntax with ilib-es6:\n\n```\nimport { AddressFmt } from 'ilib-es6';\n```\n\n\nAsynchronous Calls Using Promises\n--------------\n\nWhen calling classes asynchronously, you can continue to use callbacks as before or\nyou can use the promises returned from the _create_ factory method.\n\nold async call using callbacks:\n\n```javascript\nvar AddressFmt = require(\"ilib/lib/AddressFmt.js\");\n\nnew AddressFmt({\n  sync: false,\n  onLoad: function(af) {\n    // format some addresses using the af formatter\n  }\n});\n```\n\nnew async calls using promises:\n\n```javascript\nimport { AddressFmt } from \"ilib-es6\";\n\nAddressFmt.create().then(af =\u003e {\n  // format some addresses using the af formatter\n});\n```\n\nNote that you can still use either method above. Both are still supported.\n\nPromises with Parameters\n-------------\n\nThe _create_ factory method takes the same parameters that the class's constructor takes. For example,\nto create an address formatter in Switzerland with French, you would do:\n\n```javascript\nimport { AddressFmt } from \"ilib-es6\";\n\nAddressFmt.create({\n  locale: \"fr-CH\"\n}).then(af =\u003e {\n  // format some Swiss addresses using the af formatter\n});\n```\n\nNote that you do not need to pass the _sync_ or _onLoad_ parameters to the _create_ factory method. Calling\nthe create factory method implies asynchronous mode using promises instead of callbacks.\n\nAsynchronous Methods\n-------------\n\nPromises are also supported for some class methods that are asynchronous as well.\nExample:\n\n```javascript\nimport { AddressFmt } from \"ilib-es6\";\n\nAddressFmt.create().then(af =\u003e {\n  // false for \"asynchronous\". getFormatInfo returns a promise as well.\n  return af.getFormatInfo(\"en-US\", false);\n}).then(info =\u003e {\n  // use the info here to create an address input form\n});\n```\n\nSynchronous Classes\n-----------\n\nYou can continue using ilib classes synchronously as you had before.\n\nold:\n\n```javascript\nvar AddressFmt = require(\"ilib/lib/AddressFmt.js\");\n\nvar af = new AddressFmt();\n// now format some addresses using the af formatter\n```\n\nnew:\n\n```javascript\nimport { AddressFmt } from \"ilib-es6\";\n\nconst af = new AddressFmt();\n// now format some addresses using the af formatter\n```\n\nWhen a class is used synchronously, the constructor\nreturns an instance of the class. When an instance of the same class is\nconstructed asynchronously with sync: false, the constructor returns an empty\ndefault instance and calls the callback function given in the onLoad property\nwhen all of the locale data is finished loading.\n\nUsing Factories\n---------------\n\nFactory functions in ilib now have two types: a regular version that returns an\ninstance of the class, and the asynchronous-only version that returns a promise.\nThe async version of the factory always has an \"Async\" suffix at the end of its name.\n\nSynchronous:\n\n```javascript\nimport { CalendarFactory } from 'ilib-es6';\n\nlet cal = CalendarFactory({locale: 'ja-JP'});\n// do something with the new cal calendar.\n```\n\nAsynchronous:\n\n```javascript\nimport { CalendarFactoryAsync } from 'ilib-es6';\n\n\nCalendarFactoryAsync({locale: 'ja-JP'}).then(function(cal) {\n  // do something with the new cal calendar.\n});\n```\n\n## License\n\nCopyright © 2019-2024, JEDLSoft\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nVersions\n--------\n\nStarting with version 14.2.0, the version of ilib-es6 will echo the version of ilib\nthat it goes with. Earlier than that, version 2.0.0 of ilib-es6 went with ilib versions\n14.0.0 to 14.1.2.\n\nYou should not use ilib-es6 with ilib 13.X and earlier, as the async support in ilib\ndidn't work in all cases. Although many of the async calls did work in 13.X, a few\nimportant ones did not. (For example, there were missing callbacks, some classes were\nmissing async mode, some static methods were not able to be called asynchronously,\nand in some cases, it was calling the callback before the async call was done, etc.)\nThese problems were all fixed and tested in 14.X, so it is highly recommended to use\n14.X versions of ilib with ilib-es6.\n\nAs of v14.15.0, ilib-es6 will no longer have transpiled sources in it will be listed\nas an ESM-only project in its package.json. If you need commonjs sources, use ilib\ndirectly. Because of this, this package will no longer work on node versions less\nthan 12.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-es6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filib-js%2Filib-es6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-es6/lists"}