{"id":15787148,"url":"https://github.com/luochen1990/lazy-list","last_synced_at":"2026-04-10T10:31:09.079Z","repository":{"id":29106944,"uuid":"32636394","full_name":"luochen1990/lazy-list","owner":"luochen1990","description":"LazyList for Functional Programming","archived":false,"fork":false,"pushed_at":"2017-12-20T08:35:48.000Z","size":411,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-02T19:44:03.341Z","etag":null,"topics":["functional-programming","lazy","lazylist"],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","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/luochen1990.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}},"created_at":"2015-03-21T15:01:41.000Z","updated_at":"2018-11-02T14:20:42.000Z","dependencies_parsed_at":"2022-09-05T10:23:08.286Z","dependency_job_id":null,"html_url":"https://github.com/luochen1990/lazy-list","commit_stats":null,"previous_names":["luochen1990/lazy.coffee"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/luochen1990/lazy-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luochen1990%2Flazy-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luochen1990%2Flazy-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luochen1990%2Flazy-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luochen1990%2Flazy-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luochen1990","download_url":"https://codeload.github.com/luochen1990/lazy-list/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luochen1990%2Flazy-list/sbom","scorecard":{"id":605423,"data":{"date":"2025-08-11","repo":{"name":"github.com/luochen1990/lazy-list","commit":"a69a01215243fec828dbbbbce74d07d232f1a822"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"53 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-8w4h-3cm3-2pm2","Warn: Project is vulnerable to: GHSA-wrw9-m778-g6mc","Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-832h-xg76-4gv6","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-g74r-ffvr-5q9f","Warn: Project is vulnerable to: GHSA-xg47-r67p-vhv5","Warn: Project is vulnerable to: GHSA-xrmp-99wj-p6jc","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f9cm-qmx5-m98h","Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-3mpr-hq3p-49h9","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jv35-xqg7-f92r","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-qg8p-v9q4-gh34","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-34r7-q49f-h37c","Warn: Project is vulnerable to: GHSA-c9f4-xj24-8jqx"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T01:29:25.760Z","repository_id":29106944,"created_at":"2025-08-21T01:29:25.760Z","updated_at":"2025-08-21T01:29:25.760Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31638353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["functional-programming","lazy","lazylist"],"created_at":"2024-10-04T21:05:44.363Z","updated_at":"2026-04-10T10:31:09.065Z","avatar_url":"https://github.com/luochen1990.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Lazy List\n=========\n\nA lazy javascript library for Haskell \u0026 FP(Functional Programming) lovers.\n\n- better performance.\n- well named and designed helper functions.\n- allowing recursive LazyList definition.\n- almost no gap between normal Array and LazyList.\n- includes useful things like random_gen, permutation_gen, cartProd.\n- fully tested.\n- use it without CoffeeScript is also ok.\n- ES6 supported. (you can use the for...of syntax to enumerate an LazyList)\n\nConceptions\n-----------\n\nHere explained the core conceptions of lazy-list. you can find [**APIs' descriptions and demo** here](APIs.md)\n\n### nil, LazyList, Iterator\n\nthese three concepts gives the core definition of LazyList.\n\n- *Iterator* is a function which keeps status in it's closure, everytime you call an Iterator may got different return values.\n- *LazyList* is almost a list except it is lazy evaluated. you can call the `.iter()` method to get a new Iterator of a LazyList.\n- `nil` is both an empty list and the end sign of a LazyList.\n- the function `LazyList` is used to define a LazyList from a without-argument-function which returns an Iterator.\n- the function `Iterator` is used to get an Iterator from a without-argument-function which keeps status in it's closure. the `.next()` method is provided to support ES6 standard.\n\n### constants/producers, decorators/combiners, consumers\n\n- *constants* and *producers* is provided to get most used LazyLists.\n- *decorators* and *combiners* is provided to get new LazyList from existing LazyLists.\n- *consumers* is provided to get some normal value or side effects via enumerating a LazyList.\n\nMost Possible Abuse\n-------------------\n\n### use `map` to do side effect.\n\nyou should **never** do side effect in the argument function of `map` or any other decorators/combiners. if you want to enumerate a LazyList to do something, `foreach` is exactly what you want.\n\nie. lots of people used to do things like this:\n\n```coffeescript\nmap((x) -\u003e\n\tconsole.log x\n) range(10)\n```\n\nit is strongly recommended that you use `foreach` instead:\n\n```coffeescript\nforeach range(10), (x) -\u003e\n\tconsole.log x\n```\n\nThe abuse of `map` will make thing unclear since `map` is designed to return a LazyList and changes nothing else. Actually the `map` one won't work since the mapping function is not called immediately.\n\nAnd `foreach` is designed to enumerate items in a LazyList and do side effects in it's callback function.\n\nDo right things in right way keeps bugs away.\n\n### use recursive definitions of LazyList everywhere\n\nActually this is not mistake of users. But it is still not recommended to use recursive definitions frequently. Since there is neither graph reduction optimization in lazy-list nor tail call optimization in javascript. the performance of recursive programs is a big problem here.\n\nhere is a fibs recursive definition which has an exponential time complexity:\n\n```coffeescript\nfibs = lazy -\u003e do\n\tcons(0) cons(1) (zipWith(plus) fibs, (drop(1) fibs))\n\nconsole.log last take(15) fibs #will finish in 1 second\nconsole.log last take(30) fibs #will finish in much more than 1 second\n```\n\nInstead, you can define fibs like this which has a better performance:\n\n```coffeescript\nfibs = map(([a, b]) -\u003e a) generate [0, 1], ([a, b]) -\u003e [b, a + b]\n\nconsole.log last take(1000) fibs #will finish in 1 second\n```\n\nFAQ\n---\n\n### why not underscore?\n\nlazy-list is a better compromise between expressive ability and performance. underscore considers less on performance.\n\n### why not lazy.js?\n\nlazy.js did almost the same thing like lazy-list. But, if you don't like the \"dot dot dot...\" style, if you don't want to mix things up, if you want better named and designed apis, *lazy-list* is just for you! Moreover, this one works well with ES6, and has a litte [performance advantage](http://luochen1990.me/try_coffee?libs=%5B%22https%3A%2F%2Fcdn.rawgit.com%2Fdtao%2Flazy.js%2F0.4.0%2Flazy.min.js%22%5D#cnVuID0gKGYsIHNpemUgPSAxZTcsIHRpbWVzID0gMSkgLT4KCWZvciBpIGluIFswLi4udGltZXNdCgkJZihzaXplKQoKcGx1cyA9ICh4LCB5KSAtPiB4ICsgeQppbmMgPSAoeCkgLT4geCArIDEKCnRlc3QxID0gKGNhc2Vfc2l6ZSkgLT4KCW5hdGl2ZV9zdHlsZSA9IC0+CgkJciA9IDAKCQlmb3IgaSBpbiBbMC4uLmNhc2Vfc2l6ZV0KCQkJciArPSBpCgkJcmV0dXJuIHIKCWxvZyAtPiBuYXRpdmVfc3R5bGUoKQoJbG9nIC0+IExhenkucmFuZ2UoY2FzZV9zaXplKS5yZWR1Y2UocGx1cywgMCkKCWxvZyAtPiBmb2xkbChwbHVzLCAwKSByYW5nZShjYXNlX3NpemUpCgp0ZXN0MiA9IChjYXNlX3NpemUpIC0+CgluYXRpdmVfc3R5bGUyID0gLT4KCQlyID0gdHJ1ZQoJCW9rID0gZ3JlYXRlckVxdWFsKDApCgkJZm9yIGkgaW4gWzAuLi5jYXNlX3NpemVdCgkJCXggPSBpbmMoaSkKCQkJciA9IHIgYW5kIG9rIHgKCQlyZXR1cm4gcgoJbG9nIC0+IG5hdGl2ZV9zdHlsZTIoKQoJbG9nIC0+IExhenkucmFuZ2UoY2FzZV9zaXplKS5tYXAoaW5jKS5ub25lKGxlc3NUaGFuIDApCglsb2cgLT4gYWxsKGdyZWF0ZXJFcXVhbCAwKSBtYXAoaW5jKSByYW5nZShjYXNlX3NpemUpCgpydW4gdGVzdDEKcnVuIHRlc3QyLCAxZTY=) than lazy.js.\n\n### what is lazy evaluation?\n\nIn short, lazy evaluation records the process of evaluation in some way(called \"thunk\"), but only really evaluate it when you need it. this makes your program use less memory than in strict evaluation. This way, you can also express infinity sequences naturally like `range(2, Infinity)`, `primes`, `randoms` etc.\n\n### why head, tail (or car, cdr for lispers), foldr, id, filp etc. is not provided?\n\nThis library attemts to provides a sort of utils which takes minutes to implement. It will take a lot of names to provide the takes-seconds-to-implement things, which will not be a good practice in javascript(in which it's hard to manage names). if you need them somewhere, implement them yourself like [this](http://luochen1990.me/try_coffee?code=%22car%20%3D%20head%20%3D%20(xs)%20-%3E%20last%20take(1)%20xs%5Cncdr%20%3D%20tail%20%3D%20drop(1)%5Cnid%20%3D%20(x)%20-%3E%20x%5Cnflip%20%3D%20(f)%20-%3E%20(x)%20-%3E%20(y)%20-%3E%20f(y)(x)%5Cn%22).\n\n### why fold is not provided?\n\nIn Haskell, fold is used on Monoids which gives the definition of empty element for the operator. But there is not a similar way to decide what to return when given an empty list. ie. `fold(plus) []` should return `0` but `fold(product) []` should return `1`. So just use foldl and provide an init element like this: `foldl(plus, 0) []`.\n\n### why it is designed like this?\n\nOf course there is many other possible definition about lazylist. But I have to consider about both the design and the performance reason. here is a [comparison](http://luochen1990.me/try_coffee?#cGx1cyA9ICh4LCB5KSAtPiB4ICsgeQpjYXNlX3NpemUgPSAxZTYKCmxvZyAtPiBmb2xkbChwbHVzLCAwKSByYW5nZShjYXNlX3NpemUpCgpjbGFzcyBMYXp5TGlzdAoJY29uc3RydWN0b3I6IChzdGF0dXMsIGl0ZXIpIC0+CgkJQFtTeW1ib2wuaXRlcmF0b3JdID0gLT4KCQkJbmV3IEl0ZXJhdG9yKHN0YXR1cywgaXRlcikKCmNsYXNzIEl0ZXJhdG9yCgljb25zdHJ1Y3RvcjogKHN0YXR1cywgQGl0ZXIpIC0+CgkJQFtrXSA9IHYgZm9yIGssIHYgb2Ygc3RhdHVzCgluZXh0OiAtPgoJCXIgPSBAaXRlcigpCgkJe3ZhbHVlOiByLCBkb25lOiByID09IG5pbH0KCm5pbCA9IG5ldyBMYXp5TGlzdCB7fSwgLT4gbmlsCgpyYW5nZTIgPSAoc3RvcCkgLT4KCW5ldyBMYXp5TGlzdCB7YzogLTF9LCAtPgoJCWlmICsrQGMgPCBzdG9wIHRoZW4gQGMgZWxzZSBuaWwKCQkJCmZvbGRsMiA9IChmLCByKSAtPgoJKHhzKSAtPgoJCWl0ID0geHNbU3ltYm9sLml0ZXJhdG9yXSgpCgkJaXRlciA9IC0+IGl0Lml0ZXIoKQoJCXIgPSBmKHIsIHgpIHdoaWxlICh4ID0gaXRlcigpKSBpc250IG5pbAoJCXJldHVybiByCgpsb2cgLT4gZm9sZGwyKHBsdXMsIDApIHJhbmdlMihjYXNlX3NpemUp) about this implementation and another beautiful(but slow) implementation.\n\nInstall\n-------\n\n#### install \u0026 require in nodejs\n\n- install with npm: `your/repo/\u003e npm install lazy-list`\n- require separately: `{map, filter} = require 'lazy-list'`\n- require globally: `require 'lazy-list/global'`\n\n#### reference in html directly\n\n```html\n\u003cscript src=\"http://rawgit.com/luochen1990/lazy-list/master/build/global.coffee.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\nNOTE: this [*rawgit*](http://rawgit.com/) url is just for test, please don't use it for production.\n\nRun demo\n--------\n\nrun `coffee ./demo.coffee` under directory `lazy-list/` directly after you have `coffee-script` installed.\n\nTodo\n----\n\n- any way to optimize the performance of recursively defined lazylist.\n- the test coverage report.\n- finish the doc in APIs.md: description \u0026 demo for each function.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluochen1990%2Flazy-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluochen1990%2Flazy-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluochen1990%2Flazy-list/lists"}