Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commist

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commist - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

leven.js

18

index.js
/*
The MIT License (MIT)
Copyright (c) 2014-2021 Matteo Collina
Copyright (c) 2014-2022 Matteo Collina

@@ -27,3 +27,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

const leven = require('leven')
const leven = require('./leven')

@@ -68,3 +68,3 @@ function commist () {

strict: false,
func: func
func
}

@@ -88,5 +88,5 @@

return {
register: register,
parse: parse,
lookup: lookup
register,
parse,
lookup
}

@@ -101,6 +101,2 @@ }

this.func = options.func
this.parts.forEach(function (part) {
if (part.length < 3) { throw new Error('command words must be at least 3 chars: ' + options.command) }
})
}

@@ -127,3 +123,3 @@

}).filter(function (distance, i) {
return distance !== undefined && distance < cmd.parts[i].length - 2
return distance !== undefined && distance < cmd.parts[i].length
})

@@ -130,0 +126,0 @@

{
"name": "commist",
"version": "2.0.0",
"version": "3.0.0",
"description": "Build your commands on minimist!",

@@ -21,4 +21,2 @@ "main": "index.js",

"dependencies": {
"leven": "^3.1.0",
"minimist": "^1.1.0"
},

@@ -28,5 +26,5 @@ "devDependencies": {

"pre-commit": "^1.0.0",
"standard": "^16.0.0",
"standard": "^17.0.0",
"tape": "^5.0.0"
}
}
commist
=======
[![Build Status](https://travis-ci.com/mcollina/commist.svg?branch=master)](https://travis-ci.com/mcollina/commist)
Build command line application with multiple commands the easy way.

@@ -62,7 +60,2 @@ To be used with [minimist](http://npm.im/minimist).

Acknowledgements
----------------
This project was kindly sponsored by [nearForm](http://nearform.com).
License

@@ -69,0 +62,0 @@ -------

@@ -6,2 +6,3 @@ 'use strict'

const commist = require('./')
const leven = require('./leven')

@@ -172,3 +173,3 @@ test('registering a command', function (t) {

test('a command must be at least 3 chars', function (t) {
test('one char command', function (t) {
const program = commist()

@@ -178,7 +179,4 @@

try {
program.register('h', noop1)
t.ok(false, 'not thrown')
} catch (err) {
}
program.register('h', noop1)
t.equal(program.lookup('h')[0].func, noop1)

@@ -188,2 +186,13 @@ t.end()

test('two char command', function (t) {
const program = commist()
function noop1 () {}
program.register('he', noop1)
t.equal(program.lookup('he')[0].func, noop1)
t.end()
})
test('a command part must be at least 3 chars', function (t) {

@@ -194,9 +203,42 @@ const program = commist()

try {
program.register('h b', noop1)
t.ok(false, 'not thrown')
} catch (err) {
}
program.register('h b', noop1)
t.equal(program.lookup('h b')[0].func, noop1)
t.end()
})
test('short commands match exactly', function (t) {
const program = commist()
function noop1 () {}
function noop2 () {}
program.register('h', noop1)
program.register('help', noop2)
t.equal(program.lookup('h')[0].func, noop1)
t.equal(program.lookup('he')[0].func, noop2)
t.equal(program.lookup('hel')[0].func, noop2)
t.equal(program.lookup('help')[0].func, noop2)
t.end()
})
test('leven', function (t) {
t.is(leven('a', 'b'), 1)
t.is(leven('ab', 'ac'), 1)
t.is(leven('ac', 'bc'), 1)
t.is(leven('abc', 'axc'), 1)
t.is(leven('kitten', 'sitting'), 3)
t.is(leven('xabxcdxxefxgx', '1ab2cd34ef5g6'), 6)
t.is(leven('cat', 'cow'), 2)
t.is(leven('xabxcdxxefxgx', 'abcdefg'), 6)
t.is(leven('javawasneat', 'scalaisgreat'), 7)
t.is(leven('example', 'samples'), 3)
t.is(leven('sturgeon', 'urgently'), 6)
t.is(leven('levenshtein', 'frankenstein'), 6)
t.is(leven('distance', 'difference'), 5)
t.is(leven('因為我是中國人所以我會說中文', '因為我是英國人所以我會說英文'), 2)
t.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc