Skip to content

Instantly share code, notes, and snippets.

@SebDuf
Last active July 29, 2019 15:48
Show Gist options
  • Select an option

  • Save SebDuf/7dc609b258b2a933201ee2c6fbc450f9 to your computer and use it in GitHub Desktop.

Select an option

Save SebDuf/7dc609b258b2a933201ee2c6fbc450f9 to your computer and use it in GitHub Desktop.

Revisions

  1. SebDuf revised this gist Jul 29, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions getUserFriends.ts
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@ function getUserFriends(state): Friends[] {
    function getUserFriends(state): Friends[] {
    const friends = [];

    // Please never do this; it's only to illustrate the point
    for (let count = state.me.friendCount; i <= state.me.friendCount; i++) {
    friends.push(state.me[`friend-${count}`]);
    }
  2. SebDuf revised this gist Jul 29, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions getUserFriends.ts
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    // Before
    function getUserFriends(state): Friends[] {
    return state.me.friends;
    }

    // After
    function getUserFriends(state): Friends[] {
    const friends = [];

  3. SebDuf created this gist Jul 29, 2019.
    13 changes: 13 additions & 0 deletions getUserFriends.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function getUserFriends(state): Friends[] {
    return state.me.friends;
    }

    function getUserFriends(state): Friends[] {
    const friends = [];

    for (let count = state.me.friendCount; i <= state.me.friendCount; i++) {
    friends.push(state.me[`friend-${count}`]);
    }

    return friends;
    }