Installations
npm install center-align
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=0.10.0
Node Version
7.7.3
NPM Version
4.6.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
jonschlinkert
Download Statistics
Total Downloads
1,053,089,045
Last Day
242,166
Last Week
1,095,184
Last Month
5,404,508
Last Year
77,694,805
GitHub Statistics
23 Stars
18 Commits
10 Forks
4 Watching
1 Branches
2 Contributors
Bundle Size
3.03 kB
Minified
1.16 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.1
Package Id
center-align@1.0.1
Size
2.77 kB
NPM Version
4.6.1
Node Version
7.7.3
Publised On
26 May 2017
Total Downloads
Cumulative downloads
Total Downloads
1,053,089,045
Last day
-4.7%
242,166
Compared to previous day
Last week
-19.3%
1,095,184
Compared to previous week
Last month
5.5%
5,404,508
Compared to previous month
Last year
-5.3%
77,694,805
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
2
center-align
Center-align the text in a string.
Install
Install with npm:
1$ npm install --save center-align
Usage
1var center = require('center-align'); 2center(val, width);
Params
val
{String|Array}: the string or array of strings to center alignwidth
{Number} (optional): the total width of each line in the expected result, after it's centered.
Examples
1console.log(center('foo')); //=> 'foo' (does nothing) 2console.log(center('foo', 12)); //=> ' foo ' 3console.log(center('foo', 10)); //=> ' foo ' 4console.log(center('foo', 8)); //=> ' foo '
Multiple lines
If expected width
is not provided, the length of the longest line will be used.
Example
If used on the following:
1// value can be a string, or an array of strings 2center([ 3 'Lorem ipsum dolor sit amet,', 4 'consectetur adipiscing', 5 'elit, sed do eiusmod tempor incididunt', 6 'ut labore et dolore', 7 'magna aliqua. Ut enim ad minim', 8 'veniam, quis' 9]);
The result would be:
Lorem ipsum dolor sit amet,
consectetur adipiscing
elit, sed do eiusmod tempor incididunt
ut labore et dolore
magna aliqua. Ut enim ad minim
veniam, quis
About
Related projects
- align-text: Align the text in a string. | homepage
- justified: Wrap words to a specified length and justified the text. | homepage
- right-align: Right-align the text in a string. | homepage
- word-wrap: Wrap words to a specified length. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
Author
Jon Schlinkert
License
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on May 26, 2017.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 1/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More