Socket
Socket
Sign inDemoInstall

suffix-thumb

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suffix-thumb - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

13

builds/suffix-thumb.js

@@ -1,2 +0,2 @@

/* suffix-thumb 0.0.1 MIT */
/* suffix-thumb 0.1.0 MIT */
(function (global, factory) {

@@ -67,3 +67,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

for (var i = 4; i > 0; i -= 1) {
for (var i = 4; i >= 0; i -= 1) {
if (str.length - 1 <= i) {

@@ -88,2 +88,4 @@ continue;

var fromList = getSuffixes(from);
fromList.push(''); //add a prepend-only option
fromList.forEach(function (left) {

@@ -266,9 +268,8 @@ suffixes[left] = suffixes[left] || {};

var coverage = pairs.length - untouched.length;
var percent = coverage / pairs.length * 100;
var percent = coverage / pairs.length;
return {
rules: fmtRules(rules),
exceptions: exceptions,
percent: percent // coverage: coverage,
// remaining: untouched,
coverage: percent,
remaining: untouched
};

@@ -275,0 +276,0 @@ };

@@ -1,1 +0,1 @@

!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=r||self).suffixThumb=n()}(this,(function(){"use strict";function r(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var t=[],e=!0,o=!1,f=void 0;try{for(var u,i=r[Symbol.iterator]();!(e=(u=i.next()).done)&&(t.push(u.value),!n||t.length!==n);e=!0);}catch(r){o=!0,f=r}finally{try{e||null==i.return||i.return()}finally{if(o)throw f}}return t}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return n(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return n(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}var t=function(r){for(var n=[],t=4;t>0;t-=1)if(!(r.length-1<=t)){var e=r.substr(r.length-t-1,r.length-1);n.push(e)}return n},e=function(n){var e={};return n.forEach((function(n){var o=r(n,2),f=o[0],u=o[1];t(f).forEach((function(r){e[r]=e[r]||{},t(u).forEach((function(n){e[r][n]=e[r][n]||0,e[r][n]+=1}))}))})),e},o=function(r){var n=[];return Object.keys(r).forEach((function(t){var e,o,f=(e=r[t],o=t,Object.keys(e).map((function(r){return{from:o,to:r,yes:e[r]}})).sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0})));f[0]&&f[0].yes>1&&n.push(f[0])})),n=n.sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0}))},f=function(r,n){var t=function(r,n){return r.map((function(r){var t=0,e=0,o={};return n.forEach((function(n){if(n[0].endsWith(r.from)){var f=new RegExp(r.from+"$");n[0].replace(f,r.to)===n[1]?t+=1:(e+=1,o[n[0]]=n[1])}})),{from:r.from,to:r.to,yes:t,no:e,percent:t/(t+e),exceptions:o}}))}(r,n);return t=(t=t.filter((function(r){return r.yes>1&&r.yes>r.no}))).sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0}))},u=function(r){var n={};return r.forEach((function(t,e){r.slice(e+1,r.length).forEach((function(r){r.from.endsWith(t.from)&&(n[r.from]=!0)}))})),r=r.filter((function(r){return!1===n.hasOwnProperty(r.from)}))};function i(r){return r.split("").reverse().join("")}var c=function(r){return(r=r.sort((function(r,n){return r.from.length>n.from.length?-1:r.from.length<n.from.length||(r=i(r.from))>(n=i(n.from))?1:r<n?-1:0}))).map((function(r){return[r.from,r.to,r.yes]}))},s=function(r,n){var t={};r.forEach((function(r){Object.assign(t,r.exceptions)}));var e=n.filter((function(n){return!t.hasOwnProperty(n[0])&&!r.find((function(r){return n[0].endsWith(r.from)}))})),o=(n.length-e.length)/n.length*100;return{rules:c(r),exceptions:t,percent:o}};return function(r){var n=e(r),t=o(n),i=f(t,r);return i=u(i),s(i,r)}}));
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=r||self).suffixThumb=n()}(this,(function(){"use strict";function r(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var t=[],e=!0,o=!1,f=void 0;try{for(var u,i=r[Symbol.iterator]();!(e=(u=i.next()).done)&&(t.push(u.value),!n||t.length!==n);e=!0);}catch(r){o=!0,f=r}finally{try{e||null==i.return||i.return()}finally{if(o)throw f}}return t}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return n(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return n(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}var t=function(r){for(var n=[],t=4;t>=0;t-=1)if(!(r.length-1<=t)){var e=r.substr(r.length-t-1,r.length-1);n.push(e)}return n},e=function(n){var e={};return n.forEach((function(n){var o=r(n,2),f=o[0],u=o[1],i=t(f);i.push(""),i.forEach((function(r){e[r]=e[r]||{},t(u).forEach((function(n){e[r][n]=e[r][n]||0,e[r][n]+=1}))}))})),e},o=function(r){var n=[];return Object.keys(r).forEach((function(t){var e,o,f=(e=r[t],o=t,Object.keys(e).map((function(r){return{from:o,to:r,yes:e[r]}})).sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0})));f[0]&&f[0].yes>1&&n.push(f[0])})),n=n.sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0}))},f=function(r,n){var t=function(r,n){return r.map((function(r){var t=0,e=0,o={};return n.forEach((function(n){if(n[0].endsWith(r.from)){var f=new RegExp(r.from+"$");n[0].replace(f,r.to)===n[1]?t+=1:(e+=1,o[n[0]]=n[1])}})),{from:r.from,to:r.to,yes:t,no:e,percent:t/(t+e),exceptions:o}}))}(r,n);return t=(t=t.filter((function(r){return r.yes>1&&r.yes>r.no}))).sort((function(r,n){return r.yes>n.yes?-1:r.yes<n.yes?1:0}))},u=function(r){var n={};return r.forEach((function(t,e){r.slice(e+1,r.length).forEach((function(r){r.from.endsWith(t.from)&&(n[r.from]=!0)}))})),r=r.filter((function(r){return!1===n.hasOwnProperty(r.from)}))};function i(r){return r.split("").reverse().join("")}var c=function(r){return(r=r.sort((function(r,n){return r.from.length>n.from.length?-1:r.from.length<n.from.length||(r=i(r.from))>(n=i(n.from))?1:r<n?-1:0}))).map((function(r){return[r.from,r.to,r.yes]}))},a=function(r,n){var t={};r.forEach((function(r){Object.assign(t,r.exceptions)}));var e=n.filter((function(n){return!t.hasOwnProperty(n[0])&&!r.find((function(r){return n[0].endsWith(r.from)}))})),o=(n.length-e.length)/n.length;return{rules:c(r),exceptions:t,coverage:o,remaining:e}};return function(r){var n=e(r),t=o(n),i=f(t,r);return i=u(i),a(i,r)}}));
{
"name": "suffix-thumb",
"description": "learn transformations between two sets of words",
"version": "0.0.1",
"version": "0.1.0",
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)",

@@ -6,0 +6,0 @@ "main": "./builds/suffix-thumb.js",

@@ -30,6 +30,20 @@ <div align="center">

![carbon(1)](https://user-images.githubusercontent.com/399657/79898840-e7e66780-83d9-11ea-9ff3-099bf39cf892.png)
```js
const thumb = require('./src')
const thumb = require('suffix-thumb')
const words = [
const pairs = [
['walk', 'walked'],
['talk', 'talked'],
['go', 'went'],
]
let res = thumb(pairs)
/* { rules: [ ['alk', 'alked'] ],
exceptions: {},
coverage: 0.66,
remaining: [ ['go', 'went'] ]
}*/
const pairs = [
['aail', 'aael'],

@@ -41,3 +55,3 @@ ['bbil', 'bbel'],

]
let res = thumb(words)
let res = thumb(pairs)
/*

@@ -44,0 +58,0 @@ {

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