{"id":18449986,"url":"https://github.com/alincode/20190520-show-me-the-code","last_synced_at":"2025-04-18T00:22:24.167Z","repository":{"id":81410870,"uuid":"185608278","full_name":"alincode/20190520-show-me-the-code","owner":"alincode","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-20T09:40:46.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T13:44:10.382Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alincode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-08T13:09:43.000Z","updated_at":"2019-05-20T09:40:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1bc5d80-e1e6-41f5-afe4-9fc5aaf6c7e5","html_url":"https://github.com/alincode/20190520-show-me-the-code","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/alincode%2F20190520-show-me-the-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alincode%2F20190520-show-me-the-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alincode%2F20190520-show-me-the-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alincode%2F20190520-show-me-the-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alincode","download_url":"https://codeload.github.com/alincode/20190520-show-me-the-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167444,"owners_count":21223505,"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-06T07:22:57.598Z","updated_at":"2025-04-15T23:00:13.434Z","avatar_url":"https://github.com/alincode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 20190520-show-me-the-code\n\n分享的可以是一個簡單概念、一個小技巧，大啟發。\n\n### what is functional programming?\n\nIn computer science, functional programming is a programming paradigm\na style of building the structure and elements of computer programs—that\ntreats computation as the evaluation of mathematical functions and\navoids changing-state and mutable data.\n\n* paradigm: 是一組獨特的概念或思維模式，包括理論，研究方法\n\n1. avoids changing-state\n2. avoid side effect\n\n### Good For\n\n* more readable\n    * 不 share state，很難寫出一個長 function\n* ease of testing: \n    * 避免使用外部資源，只使用 input 值，很難有 side effect\n    * 每個 function 都會有回傳值，可以被測試驗證。\n\n### how to more functional\n\n* less side effect\n    * use no side effect function\n    * less temporary variables, e.g. get data by query\n* always return data\n* immutable\n  * avoids to modify function parameter\n  * or use lodash.cloneDeep\n* for, while ---\u003e map\n\n### some advice\n\n* skip framework first, just focus on language\n\n### FP libraries for JS\n\n* Immutable.js: \u003chttps://immutable-js.github.io/immutable-js/\u003e\n* Functional Programming With Lodash/FP: \u003chttps://blog.codeminer42.com/functional-programming-with-lodash-fp-8fe0619b3024\u003e\n* Ramda: \u003chttps://ramdajs.com/docs/\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falincode%2F20190520-show-me-the-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falincode%2F20190520-show-me-the-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falincode%2F20190520-show-me-the-code/lists"}