From 3f1bca7d26eb63be968d70908fd4dafa2a3de5f7 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 13 Jun 2016 10:06:29 -0700 Subject: [PATCH] Fix truncate tests Reviewed By: bestander Differential Revision: D3424960 fbshipit-source-id: 0f434d80e6e26cfc9f01800c266dd1a3710fe459 --- Libraries/Utilities/truncate.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/truncate.js b/Libraries/Utilities/truncate.js index 462a023d1..e375f0f37 100644 --- a/Libraries/Utilities/truncate.js +++ b/Libraries/Utilities/truncate.js @@ -11,27 +11,25 @@ */ 'use strict'; -var merge = require('merge'); - type truncateOptions = { breakOnWords: boolean; minDelta: number; elipsis: string; } -var defaultOptions = { +const defaultOptions = { breakOnWords: true, minDelta: 10, // Prevents truncating a tiny bit off the end elipsis: '...', }; // maxChars (including ellipsis) -var truncate = function( +const truncate = function( str: ?string, maxChars: number, options: truncateOptions ): ?string { - options = merge(defaultOptions, options); + options = Object.assign({}, defaultOptions, options); if (str && str.length && str.length - options.minDelta + options.elipsis.length >= maxChars) { str = str.slice(0, maxChars - options.elipsis.length + 1);