@@ -3,11 +3,11 @@
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
const stringShorten = require('./shorten');
|
||||
import stringShorten from './shorten';
|
||||
|
||||
/**
|
||||
@summary Utility methods to convert to work with `string` values
|
||||
*/
|
||||
module.exports = {
|
||||
export {
|
||||
stringShorten
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
stringShorten('1234567890', 2); // => 12..90
|
||||
*/
|
||||
module.exports = function stringShorten (_value: mixed, prefixLength: number = 6): string {
|
||||
export default function stringShorten (_value: mixed, prefixLength: number = 6): string {
|
||||
// $FlowFixMe coerced into string (by any means)
|
||||
const value = `${_value}`;
|
||||
|
||||
@@ -23,4 +23,4 @@ module.exports = function stringShorten (_value: mixed, prefixLength: number = 6
|
||||
}
|
||||
|
||||
return `${value.substr(0, prefixLength)}..${value.slice(-prefixLength)}`;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
const { stringShorten } = require('./index');
|
||||
import { stringShorten } from './index';
|
||||
|
||||
describe('stringShorten', () => {
|
||||
it('returns the value as-is when <= maxLength', () => {
|
||||
|
||||
Reference in New Issue
Block a user