lodash 中文文档 lodash 中文文档
英文官网 (opens new window)
GitHub (opens new window)
英文官网 (opens new window)
GitHub (opens new window)
  • 简介
  • 数组
  • 集合
  • 函数
  • 语言
  • 数学
  • 数字
  • 对象
  • Seq
  • 字符串
  • 实用函数
  • Properties

Lodash


Installation


This package can be installed as:

Add lodash to your list of dependencies in mix.exs :

  1. ``` sh
  2. ```elixir
def deps do
  [{:lodash, "~> 0.1.0"}]
end
  1. ```

  2. ```

Ensure lodash is started before your application:

  1. ``` sh
  2. ```elixir
def application do
  [applications: [:lodash]]
end
  1. ```

  2. ```

Docs


Read more at hex

Examples


String


  1. ``` elixir
  2.   iex> Lodash.String.words("erlang elixir")
  3.   ["erlang", "elixir"]

  4.   iex> Lodash.String.deburr("déjà vu")
  5.   "deja vu"

  6.   iex> Lodash.String.pascal_case("Pascal CASE")
  7.   "PascalCase"

  8.   iex> Lodash.String.camel_case("---CAMEL--CASE")
  9.   "camelCase"

  10.   iex> Lodash.String.kebab_case("Kebab__CASE")
  11.   "kebab-case"

  12.   iex> Lodash.String.snake_case("Snake CASE")
  13.   "snake_case"

  14.   iex> Lodash.String.lower_case("Lower case")
  15.   "lower case"

  16.   iex> Lodash.String.start_case("START CASE")
  17.   "Start Case"

  18.   iex> Lodash.String.truncate("pokemon go", length: 5)
  19.   "pok..."
  20. ```

Collection


  1. ``` elixir
  2.   iex> Lodash.Collection.compact([1, 2, nil])
  3.   [1, 2]
  4.   iex> Lodash.Collection.difference([1, 2], [2, 3])
  5.   [1]
  6.   iex> Lodash.Collection.difference_by([1.1, 2.2], [1.2, 3.0], fn(x, y) -> Float.floor(x) == Float.floor(y) end)
  7.   [2.2]
  8.   iex> Lodash.Collection.intersection([1, 2], [2, 3])
  9.   [2]
  10.   iex> Lodash.Collection.intersection_by([1.1, 2.2], [1.2, 3.0], fn(x, y) -> Float.floor(x) == Float.floor(y) end)
  11.   [1.1]
  12.   iex> Lodash.Collection.pull([1, 2], 1)
  13.   [2]
  14.   iex> Lodash.Collection.pull_all([1, 2, 3], [2, 3])
  15.   [1]
  16.   iex> Lodash.Collection.union([1, 2], [2, 3])
  17.   [1, 2, 3]
  18.   iex> Lodash.Collection.union_by([1, 2, 3], [4, 5, 6], fn(x) -> x == 1 end)
  19.   [1, 2]
  20. ```
Last Updated: 2023-05-15 20:35:46