conductor
Why I'm building conductorGitHub
v1.5.0
v1.5.0
  • Introduction
  • Overview
    • Introduction
    • Core concepts
  • API reference
    • always
    • append
    • apply
    • arity
    • branch
    • capitalize
    • compose
    • concat
    • curry
    • curryN
    • delay
    • dump
    • entries
    • equals
    • equalsBy
    • factory
    • filter
    • findIndex
    • flatten
    • flip
    • forEach
    • get
    • head
    • ifElse
    • identity
    • into
    • isPromise
    • iterate
    • join
    • keys
    • map
    • merge
    • mergeBy
    • next
    • not
    • pluck
    • prepend
    • random
    • reduce
    • replace
    • slice
    • some
    • split
    • take
    • then
    • toLowerCase
    • transduce
    • transformers
      • transformers/filter
      • transformers/map
    • type
    • upsert
    • values
  • Guides
    • example use cases
    • checkGuards
Powered by GitBook
On this page
  • description
  • examples
  1. API reference

flatten

flatten :: Collection -> Collection

description

Deeply flattens a Collection (Array | Set | Map | Object).

examples

array

import { flatten } from 'conductor'

const array = [1, [2, [3]]]
flatten(array) // [1, 2, 3]

object

import { flatten } from 'conductor'

const object = { a: { b: { c: 3 } } }
flatten(array) // { 'a.b.c': 3 }

set

import { flatten } from 'conductor'

const set = new Set([1, [2, [3]]])
flatten(set) // Set{1, 2, 3}

map

import { flatten } from 'conductor'

const map = new Map([['a', new Map([['b', new Map(['c', 3])])])
flatten(array) // Map{ 'a.b.c' => 3 }
PreviousfindIndexNextflip

Last updated 6 years ago