Analyzing-Modules

I learned how to analyze and select NPM modules:

View on GitHub

Pad Left - NPM, GitHub

Single Responsibility:

On Replication:

Principle Developer: jonschlinkert

Index


Analysis

This package is the best of it’s kind I was able to find. While it’s not too actively maintained, the code is also very simple and still passes it’s tests. The code is also well written and well documented so I would have no trouble hunting down any errors that came from this module.

Top Down

Community:

  1. Dependent Projects: 52
  2. Dependencies: 1
  3. Contributors: 4
  4. Forks: 6
  5. Stars: 31
  6. Curated Lists: Awesome Micro NPM Packages
  7. Version: 2.1.0
  8. Releases: 11
  9. Latest Commit: March 14, 2017
  10. Downloads Last Month: 124,085
  11. Open Issues: 0
  12. Open Pull Requests: 0
  13. License: MIT

Bottom Up

The Code:

  1. Ease of Use: high
  2. Documentation: good
  3. Differentiation: faster
  4. Maintenance: unmaintained, but not relevant for such a small package
  5. Project Scope: Clear, simple, well-stated
  6. Complaints: no open issues. Just the bigger questions of why not to write it myself
  7. Support: not relevant with no complaints
  8. Code: clear and well-written. I have no trouble understanding it or navigating it

Security

The source code in this module poses very little risk. While it’s not very actively maintained, and does not have a large group of contributors it’s also small and simple enough that this isn’t that big of an issue.

But it does have one dependency that could be a vulnerability. I haven’t assessed this one yet.

I can imagine this package posing a risk if someone were to get hold of the maintainer’s account and messed with the padding. They could either have the function pad with a dangerous regular expression, or simply make it pad by more than I want. Either way they could crash my system, or open dangerous vulnerabilities.

Competition

There is only one major competitor: The Infamous Left-Pad. Apparently this one is faster.

TOP


File Structure

pad-left
|
+-- /benchmark
|	+-- /code
|	|	: Many ways to left pad a string
|	+-- /fixtures
|	|	: Test cases
|	+-- index.js
|	|	: Runs the benchmark tests and outputs the results
|	+-- node-*.md
|		: Outputs from the benchmark tests
|
+-- .*
|		: A whole lot of configuration files
|
+-- LICENSE
|
+-- README.md
|	: Title, stats
|	: The module's behavior, and a link to a related module
|	: Install instructions
|	: Usage instructions
|	: Benchmarking against the infamous left-pad
|	: More related projects
|	: Contributing Guidelines
|	: How to build the docs with verb
|	: How to run the tests
|	: Author info
|	: License
|
+-- index.js
|	: Requires the repeat-string node module
|	: Exports the pad-left function
|	: Defines and exports the module's functionality
|
+-- package.json
|	: Pretty basic package.json
|
+-- test.js
	: Requires mocha, should, and pad-left
	: Exports nothing
	: Runs test cases for pad-left

TOP


Specs

pad-left: Function
	ARGS: 3
		str: String
			* the string to be left-padded
		num: Number
			* the length of the final string
		ch: String
			* what to pad the string with
	RETURN: String
	BEHAVIOR:
		* returns 'str' with 'ch' repeated to the 
		left until 'str' is 'num' characters long.

TOP


Use Cases

I don’t know of many use cases myself. But it must be a common operation since the left-pad incident is real.

It’s probably useful if you’re doing protocol compliance.

TOP