From 1835ea3891deb81c7eba6b712c94e8eafd8afd58 Mon Sep 17 00:00:00 2001 From: Ardalan Date: Tue, 31 Jul 2018 16:42:39 +0430 Subject: [PATCH] Update documents --- API.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/API.md b/API.md index 8ec6f82b..ce4576ec 100644 --- a/API.md +++ b/API.md @@ -60,7 +60,7 @@ * [.max([path])](#Array+max) ⇒ number * [.median([path])](#Array+median) ⇒ number * [.min([path])](#Array+min) ⇒ number - * [.nest(id, link)](#Array+nest) ⇒ [Array.<Object>](#Object) + * [.nest(link, id)](#Array+nest) ⇒ [Array.<Object>](#Object) * [.orderBy([field], [order])](#Array+orderBy) ⇒ [Array](#Array) * [.pad(size, [value])](#Array+pad) ⇒ [Array](#Array) * [.partition(fn)](#Array+partition) ⇒ [Array](#Array) @@ -550,26 +550,26 @@ Returns the minimum value of a given path ``` -### array.nest(id, link) ⇒ [Array.<Object>](#Object) +### array.nest(link, id) ⇒ [Array.<Object>](#Object) Given a flat array of objects linked to one another, it will nest them recursively **Kind**: instance method of [Array](#Array) | Param | Type | | --- | --- | -| id | \* | | link | string | +| id | string | **Example** ```javascript const comments = [ - { id: 1, parent_id: null }, - { id: 2, parent_id: 1 }, - { id: 3, parent_id: 1 }, - { id: 4, parent_id: 2 }, - { id: 5, parent_id: 4 } + { id: 1, comment_id: null }, + { id: 2, comment_id: 1 }, + { id: 3, comment_id: 1 }, + { id: 4, comment_id: 2 }, + { id: 5, comment_id: 4 } ]; -comments.nest(); // [{ id: 1, parent_id: null, children: [...] }] +comments.nest("comment_id"); // [{ id: 1, comment_id: null, children: [...] }] ```