本页使用了标题或全文手工转换

Lodash

维基百科,自由的百科全书
(重定向自Underscore.js
跳到导航 跳到搜索
Lodash
原作者John-David Dalton
開發者OpenJS 基金會[1]
初始版本2012年4月23日,​10年前​(2012-04-23[2]
穩定版本
4.17.20
(2020年8月13日,​22個月前​(2020-08-13[2]
源代码库 編輯維基數據鏈接
编程语言JavaScript
系統平台跨平臺
类型JavaScript函式庫
许可协议MIT許可證[3]
网站https://lodash.com/

Lodash是一個開放源碼JavaScript函式庫。Lodash的目的是透過函式語言程式設計的模式提供開發者常用的函式。[4]

概覽[编辑]

Lodash是基於Underscore.js分叉,其許多函式與功能與Underscore.js相似。[5]Underscore.js的創辦人是同為CoffeeScript的創辦人Jeremy Ashkenas英语Jeremy Ashkenas。許多Underscore.js的開發人員也對Lodash的開發有所貢獻。[6][7]

Lodash是目前在npm上最多JavaScript軟體使用的開放原始碼軟體套件,每週下載次數三千三百萬次以上。[8][9]Lodash在開源軟體的廣泛使用讓此套件曾經成為依賴注入漏洞攻擊。[10][11]

範例[编辑]

Lodash包含陣列排序算法和過濾、集合的演算法、數學函式、與字符串的變更函式,共包含超過一百個函式。[12]Lodash使用的函式語言程式設計模式允許開發者同時串連英语Method Chaining多數個函式。比如,如果要同時排序和顛倒一個包含數字的陳列,可以使用以下句法[12]

const _ = require('lodash')

const numbers = [2,5,4,3,1]
const sorted_numbers = _(numbers).sortBy().reverse().value();

// 結果: numbers = [5,4,3,2,1]

参考文献[编辑]

  1. ^ OpenJS Foundation Hosted Projects. [2020-07-23]. (原始内容存档于2020-07-19). 
  2. ^ 2.0 2.1 Lodash Releases. GitHub. [2020-07-23]. (原始内容存档于2021-01-25). 
  3. ^ Lodash/LICENSE.md. GitHub. [2020-07-23]. (原始内容存档于2020-12-20). 
  4. ^ Lodash. Lodash Functional Programming Guide. [2020-07-24]. (原始内容存档于2021-01-21). 
  5. ^ Albert Ziegler. Lodash vs Underscore: Dash of the titans. Semmle Official Blog, a Github/Microsoft Company. 2017-10-26 [2020-07-24]. (原始内容存档于2020-07-24). 
  6. ^ Jeremy Ashkenas. Jeremy Ashkenas Biography. New York Times. [2020-07-24]. (原始内容存档于2021-01-12). 
  7. ^ Underdash Github Issues: Lodash, underscore merge and usage discussion. Github. [2020-07-24]. (原始内容存档于2020-10-12). 
  8. ^ npm most depended upon packages. [2020-07-24]. (原始内容存档于2020-12-04). 
  9. ^ lodash on npm. [2020-07-24]. (原始内容存档于2021-02-04). 
  10. ^ Catalin Cimpanu. More than 75% of all vulnerabilities reside in indirect dependencies. ZDNet. 2020-06-20 [2020-07-24]. (原始内容存档于2021-01-19). 
  11. ^ Lodash Github Issues: High severity vulnerability in 4.17.11. Github. 2019-07-02 [2020-07-24]. (原始内容存档于2020-11-11). 
  12. ^ 12.0 12.1 Lodash. Lodash Docs. [2020-07-23]. (原始内容存档于2021-01-23). 

外部链接[编辑]