Socket
Socket
Sign inDemoInstall

longest

Package Overview
Dependencies
0
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    longest

Get the longest item in an array.


Version published
Maintainers
2
Install size
5.22 kB
Created

Package description

What is longest?

The 'longest' npm package is a simple utility that allows you to find the longest string in an array of strings. It is useful when you need to determine the maximum length of strings within a collection, which can be helpful for formatting console output, aligning text, or any other situation where string length matters.

What are longest's main functionalities?

Find the longest string in an array

This feature allows you to pass an array of strings to the 'longest' function, which returns the longest string in the array.

"const longest = require('longest');
const array = ['short', 'medium', 'longestString'];
const longestString = longest(array);
console.log(longestString); // 'longestString'"

Other packages similar to longest

Readme

Source

longest NPM version Build Status

Get the longest item in an array.

Install with npm

npm i longest --save

Install with bower

bower install longest --save

Running tests

Install dev dependencies.

npm i -d && npm test

Usage

var longest = require('longest');
longest(['a', 'abcde', 'abc']);
//=> 'abcde'

longest(['a', 'abcde', 'abc']).length;
//=> 5
  • longest-value: Get the longest value for the given property from an array of objects. Useful for aligning values.
  • right-align-values: Right align the values of a given property for each object in an array. Useful for creating text columns or tables.
  • right-pad-values: Right pad the values of a given property for each object in an array. Useful for creating text columns or tables.
  • repeat-string: Repeat the given string n times. Fastest implementation for repeating a string.
  • pad-right: Right pad a string with zeros or a specified string. Fastest implementation.
  • pad-left: Left pad a string with zeros or a specified string. Fastest implementation.

Running tests

Install dev dependencies.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 31, 2015.

Keywords

FAQs

Last updated on 31 Mar 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc