diff-leven 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +18 -18
- package/dist/index.mjs +18 -18
- package/package.json +15 -3
package/dist/index.d.mts
CHANGED
|
@@ -53,8 +53,8 @@ declare enum DiffType {
|
|
|
53
53
|
interface DiffResult {
|
|
54
54
|
type: DiffType;
|
|
55
55
|
path?: string[];
|
|
56
|
-
oldValue?:
|
|
57
|
-
newValue?:
|
|
56
|
+
oldValue?: SerializableValue;
|
|
57
|
+
newValue?: SerializableValue;
|
|
58
58
|
children?: DiffResult[];
|
|
59
59
|
/**
|
|
60
60
|
* Additional metadata about the diff, such as Levenshtein distance metrics
|
|
@@ -65,7 +65,7 @@ interface DiffResult {
|
|
|
65
65
|
/** Similarity ratio (0-1) where 1 means identical */
|
|
66
66
|
similarity?: number;
|
|
67
67
|
/** Any other metadata properties */
|
|
68
|
-
[key: string]:
|
|
68
|
+
[key: string]: unknown;
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -53,8 +53,8 @@ declare enum DiffType {
|
|
|
53
53
|
interface DiffResult {
|
|
54
54
|
type: DiffType;
|
|
55
55
|
path?: string[];
|
|
56
|
-
oldValue?:
|
|
57
|
-
newValue?:
|
|
56
|
+
oldValue?: SerializableValue;
|
|
57
|
+
newValue?: SerializableValue;
|
|
58
58
|
children?: DiffResult[];
|
|
59
59
|
/**
|
|
60
60
|
* Additional metadata about the diff, such as Levenshtein distance metrics
|
|
@@ -65,7 +65,7 @@ interface DiffResult {
|
|
|
65
65
|
/** Similarity ratio (0-1) where 1 means identical */
|
|
66
66
|
similarity?: number;
|
|
67
67
|
/** Any other metadata properties */
|
|
68
|
-
[key: string]:
|
|
68
|
+
[key: string]: unknown;
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _leven = require('leven'); var _leven2 = _interopRequireDefault(_leven);var g=(o=>(o.ADDED="added",o.REMOVED="removed",o.CHANGED="changed",o.UNCHANGED="unchanged",o))(g||{});function
|
|
2
|
-
${f}`;default:return o=c(_nullishCoalesce(e.newValue, () => (e.oldValue))),t?`${
|
|
3
|
-
`,f=0;if(e.children)for(let
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
6
|
-
${l}${
|
|
7
|
-
${l}+ ${c(
|
|
8
|
-
`),
|
|
9
|
-
`,f=0;if(e.children){let
|
|
10
|
-
`)&&(
|
|
11
|
-
`),
|
|
12
|
-
${l}${
|
|
13
|
-
${l}+ ${
|
|
14
|
-
`)&&(
|
|
15
|
-
`)||(
|
|
16
|
-
`)}}return f>0&&!
|
|
17
|
-
`)&&(
|
|
18
|
-
`),
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _leven = require('leven'); var _leven2 = _interopRequireDefault(_leven);var g=(o=>(o.ADDED="added",o.REMOVED="removed",o.CHANGED="changed",o.UNCHANGED="unchanged",o))(g||{});function y(e,t,u={},r=[]){let{keysOnly:o=!1,ignoreValues:m=!1}=u;if(e===void 0&&t===void 0)return{type:"unchanged"};if(e===void 0)return{type:"added",path:r,newValue:t};if(t===void 0)return{type:"removed",path:r,oldValue:e};if(typeof e!="object"||typeof t!="object"||e===null||t===null){if(o||m)return{type:"unchanged",path:r,oldValue:e,newValue:t,meta:{ignored:!0}};if(e===t)return{type:"unchanged",path:r,oldValue:e,newValue:t};if(typeof e=="string"&&typeof t=="string"){let $=_leven2.default.call(void 0, e,t),l=Math.max(e.length,t.length),i=l>0?1-$/l:1;return{type:"changed",path:r,oldValue:e,newValue:t,meta:{levenDistance:$,similarity:i}}}return{type:"changed",path:r,oldValue:e,newValue:t}}return Array.isArray(e)&&Array.isArray(t)?A(e,t,u,r):S(e,t,u,r)}function S(e,t,u,r){let{ignoreKeys:o=[]}=u,m=new Set([...Object.keys(e).filter(i=>!o.includes(i)),...Object.keys(t).filter(i=>!o.includes(i))]),$=[],l=!1;for(let i of m){let f=[...r,i],D=e[i],n=t[i],s=y(D,n,u,f);s.type!=="unchanged"&&(l=!0),$.push(s)}return l?{type:"changed",path:r,oldValue:e,newValue:t,children:$}:{type:"unchanged",path:r,oldValue:e,newValue:t}}function A(e,t,u,r){if(e.length!==t.length){let $=[],l=Math.max(e.length,t.length);for(let i=0;i<l;i++){let f=[...r,i.toString()];i>=e.length?$.push({type:"added",path:f,newValue:t[i]}):i>=t.length?$.push({type:"removed",path:f,oldValue:e[i]}):$.push(y(e[i],t[i],u,f))}return{type:"changed",path:r,oldValue:e,newValue:t,children:$}}let o=[],m=!1;for(let $=0;$<e.length;$++){let l=[...r,$.toString()],i=e[$],f=t[$],D;if(typeof i=="string"&&typeof f=="string")if(i===f)D={type:"unchanged",path:l,oldValue:i,newValue:f};else{let n=_leven2.default.call(void 0, i,f),s=Math.max(i.length,f.length),h=s>0?1-n/s:1;D={type:"changed",path:l,oldValue:i,newValue:f,meta:{levenDistance:n,similarity:h}},m=!0}else D=y(i,f,u,l),D.type!=="unchanged"&&(m=!0);o.push(D)}return m?{type:"changed",path:r,oldValue:e,newValue:t,children:o}:{type:"unchanged",path:r,oldValue:e,newValue:t}}var a={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",gray:"\x1B[90m"};function E(e,t={}){let{color:u=!0,full:r=!1,withSimilarity:o=!1}=t;return e.type==="unchanged"&&!r&&(!e.children||e.children.length===0)?"":!e.children||e.children.length===0?C(e,u,o):G(e,t,0)}function C(e,t,u=!1){let r=H(e.type),o="";switch(e.type){case"added":return o=c(e.newValue),t?`${a.green}${r} ${o}${a.reset}`:`${r} ${o}`;case"removed":return o=c(e.oldValue),t?`${a.red}${r} ${o}${a.reset}`:`${r} ${o}`;case"changed":let m=c(e.oldValue),$=c(e.newValue),l="";if(u&&_optionalChain([e, 'access', _ => _.meta, 'optionalAccess', _2 => _2.similarity])!==void 0&&typeof e.oldValue=="string"&&typeof e.newValue=="string"){let D=Math.round(e.meta.similarity*100);l=t?`${a.gray} (${D}% similar)${a.reset}`:` (${D}% similar)`}let i=t?`${a.red}- ${m}${a.reset}`:`- ${m}`,f=t?`${a.green}+ ${$}${l}${a.reset}`:`+ ${$}${l}`;return`${i}
|
|
2
|
+
${f}`;default:return o=c(_nullishCoalesce(e.newValue, () => (e.oldValue))),t?`${a.gray}${r} ${o}${a.reset}`:`${r} ${o}`}}function G(e,t,u=0){let{full:r=!1}=t;return e.type==="unchanged"&&!r&&(!e.children||e.children.length===0||typeof e.oldValue!="object"&&typeof e.newValue!="object")?"":Array.isArray(e.oldValue)||Array.isArray(e.newValue)?p(e,t,u):d(e,t,u)}function p(e,t,u=0){let{color:r=!0,full:o=!1,withSimilarity:m=!1}=t,$=" ".repeat(u),l=" ".repeat(u+2),i=`[
|
|
3
|
+
`,f=0;if(e.children)for(let D=0;D<e.children.length;D++){let n=e.children[D];if(!(n.type==="unchanged"&&!o&&(!n.children||n.children.length===0)))if(n.children&&n.children.length>0){let s=Array.isArray(n.newValue||n.oldValue)?p(n,t,u+2):d(n,t,u+2);s.trim().length>2&&(f>0&&(i+=`,
|
|
4
|
+
`),i+=l,i+=s,f++)}else switch(f>0&&(i+=`,
|
|
5
|
+
`),n.type){case"added":i+=r?`${l}${a.green}+ ${c(n.newValue)}${a.reset}`:`${l}+ ${c(n.newValue)}`,f++;break;case"removed":i+=r?`${l}${a.red}- ${c(n.oldValue)}${a.reset}`:`${l}- ${c(n.oldValue)}`,f++;break;case"unchanged":_optionalChain([n, 'access', _3 => _3.meta, 'optionalAccess', _4 => _4.ignored])&&n.path?i+=r?`${l}${a.gray} ${n.path[n.path.length-1]||""}${a.reset}`:`${l} ${n.path[n.path.length-1]||""}`:i+=r?`${l}${a.gray} ${c(n.newValue)}${a.reset}`:`${l} ${c(n.newValue)}`,f++;break;case"changed":i+=r?`${l}${a.red}- ${c(n.oldValue)}${a.reset}
|
|
6
|
+
${l}${a.green}+ ${c(n.newValue)}${_optionalChain([n, 'access', _5 => _5.meta, 'optionalAccess', _6 => _6.similarity])!==void 0&&m?r?`${a.gray} (${Math.round(n.meta.similarity*100)}% similar)${a.reset}`:` (${Math.round(n.meta.similarity*100)}% similar)`:""}${a.reset}`:`${l}- ${c(n.oldValue)}
|
|
7
|
+
${l}+ ${c(n.newValue)}${_optionalChain([n, 'access', _7 => _7.meta, 'optionalAccess', _8 => _8.similarity])!==void 0&&m?` (${Math.round(n.meta.similarity*100)}% similar)`:""}`,f++;break}}return f>0&&(i+=`
|
|
8
|
+
`),i+=`${$}]`,i}function d(e,t,u=0){let{color:r=!0,full:o=!1,withSimilarity:m=!1}=t,$=" ".repeat(u),l=" ".repeat(u+2),i=`{
|
|
9
|
+
`,f=0;if(e.children){let D=e.children.filter(n=>{if(n.type!=="unchanged"||o||n.children&&n.children.length>0)return!0;let s=_optionalChain([n, 'access', _9 => _9.path, 'optionalAccess', _10 => _10[n.path.length-1]])||"";return!!_optionalChain([t, 'access', _11 => _11.outputKeys, 'optionalAccess', _12 => _12.includes, 'call', _13 => _13(s)])});for(let n=0;n<D.length;n++){let s=D[n],h=_optionalChain([s, 'access', _14 => _14.path, 'optionalAccess', _15 => _15[s.path.length-1]])||"",R=n===D.length-1;if(f>0&&!i.endsWith(`
|
|
10
|
+
`)&&(i+=`,
|
|
11
|
+
`),s.children&&s.children.length>0){let b=Array.isArray(s.newValue||s.oldValue)?p(s,t,u+2):d(s,t,u+2);b.trim().length>2&&(i+=`${l}${h}: ${b}`,f++)}else switch(s.type){case"added":i+=r?`${l}${a.green}+ ${h}: ${c(s.newValue)}${a.reset}`:`${l}+ ${h}: ${c(s.newValue)}`,f++;break;case"removed":i+=r?`${l}${a.red}- ${h}: ${c(s.oldValue)}${a.reset}`:`${l}- ${h}: ${c(s.oldValue)}`,f++;break;case"changed":i+=r?`${l}${a.red}- ${h}: ${c(s.oldValue)}${a.reset}
|
|
12
|
+
${l}${a.green}+ ${h}: ${c(s.newValue)}${_optionalChain([s, 'access', _16 => _16.meta, 'optionalAccess', _17 => _17.similarity])!==void 0&&m?r?`${a.gray} (${Math.round(s.meta.similarity*100)}% similar)${a.reset}`:` (${Math.round(s.meta.similarity*100)}% similar)`:""}${a.reset}`:`${l}- ${h}: ${c(s.oldValue)}
|
|
13
|
+
${l}+ ${h}: ${c(s.newValue)}${_optionalChain([s, 'access', _18 => _18.meta, 'optionalAccess', _19 => _19.similarity])!==void 0&&m?` (${Math.round(s.meta.similarity*100)}% similar)`:""}`,f++;break;case"unchanged":(o||_optionalChain([t, 'access', _20 => _20.outputKeys, 'optionalAccess', _21 => _21.includes, 'call', _22 => _22(h)]))&&(_optionalChain([s, 'access', _23 => _23.meta, 'optionalAccess', _24 => _24.ignored])?i+=r?`${l}${a.gray} ${h}${a.reset}`:`${l} ${h}`:i+=r?`${l}${a.gray} ${h}: ${c(s.newValue)}${a.reset}`:`${l} ${h}: ${c(s.newValue)}`,f++);break}!R&&!i.endsWith(`
|
|
14
|
+
`)&&(i+=","),i.endsWith(`
|
|
15
|
+
`)||(i+=`
|
|
16
|
+
`)}}return f>0&&!i.endsWith(`
|
|
17
|
+
`)&&(i+=`
|
|
18
|
+
`),i+=`${$}}`,i}function H(e){switch(e){case"added":return"+";case"removed":return"-";case"changed":return"!";default:return" "}}function c(e){return e===void 0?"undefined":e===null?"null":typeof e=="string"?`'${e}'`:typeof e=="number"||typeof e=="boolean"?e.toString():typeof e=="object"?JSON.stringify(e,null,2):String(e)}function N(e,t,u={}){return y(e,t,u)}function B(e,t,u={}){let r=N(e,t,u);return E(r,u)}function F(e,t,u={}){return N(e,t,u).type!=="unchanged"}exports.DiffType = g; exports.diff = B; exports.diffRaw = N; exports.isDiff = F;
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import V from"leven";var g=(o=>(o.ADDED="added",o.REMOVED="removed",o.CHANGED="changed",o.UNCHANGED="unchanged",o))(g||{});function
|
|
2
|
-
${f}`;default:return o=c(e.newValue??e.oldValue),t?`${
|
|
3
|
-
`,f=0;if(e.children)for(let
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
6
|
-
${l}${
|
|
7
|
-
${l}+ ${c(
|
|
8
|
-
`),
|
|
9
|
-
`,f=0;if(e.children){let
|
|
10
|
-
`)&&(
|
|
11
|
-
`),
|
|
12
|
-
${l}${
|
|
13
|
-
${l}+ ${
|
|
14
|
-
`)&&(
|
|
15
|
-
`)||(
|
|
16
|
-
`)}}return f>0&&!
|
|
17
|
-
`)&&(
|
|
18
|
-
`),
|
|
1
|
+
import V from"leven";var g=(o=>(o.ADDED="added",o.REMOVED="removed",o.CHANGED="changed",o.UNCHANGED="unchanged",o))(g||{});function y(e,t,u={},r=[]){let{keysOnly:o=!1,ignoreValues:m=!1}=u;if(e===void 0&&t===void 0)return{type:"unchanged"};if(e===void 0)return{type:"added",path:r,newValue:t};if(t===void 0)return{type:"removed",path:r,oldValue:e};if(typeof e!="object"||typeof t!="object"||e===null||t===null){if(o||m)return{type:"unchanged",path:r,oldValue:e,newValue:t,meta:{ignored:!0}};if(e===t)return{type:"unchanged",path:r,oldValue:e,newValue:t};if(typeof e=="string"&&typeof t=="string"){let $=V(e,t),l=Math.max(e.length,t.length),i=l>0?1-$/l:1;return{type:"changed",path:r,oldValue:e,newValue:t,meta:{levenDistance:$,similarity:i}}}return{type:"changed",path:r,oldValue:e,newValue:t}}return Array.isArray(e)&&Array.isArray(t)?A(e,t,u,r):S(e,t,u,r)}function S(e,t,u,r){let{ignoreKeys:o=[]}=u,m=new Set([...Object.keys(e).filter(i=>!o.includes(i)),...Object.keys(t).filter(i=>!o.includes(i))]),$=[],l=!1;for(let i of m){let f=[...r,i],D=e[i],n=t[i],s=y(D,n,u,f);s.type!=="unchanged"&&(l=!0),$.push(s)}return l?{type:"changed",path:r,oldValue:e,newValue:t,children:$}:{type:"unchanged",path:r,oldValue:e,newValue:t}}function A(e,t,u,r){if(e.length!==t.length){let $=[],l=Math.max(e.length,t.length);for(let i=0;i<l;i++){let f=[...r,i.toString()];i>=e.length?$.push({type:"added",path:f,newValue:t[i]}):i>=t.length?$.push({type:"removed",path:f,oldValue:e[i]}):$.push(y(e[i],t[i],u,f))}return{type:"changed",path:r,oldValue:e,newValue:t,children:$}}let o=[],m=!1;for(let $=0;$<e.length;$++){let l=[...r,$.toString()],i=e[$],f=t[$],D;if(typeof i=="string"&&typeof f=="string")if(i===f)D={type:"unchanged",path:l,oldValue:i,newValue:f};else{let n=V(i,f),s=Math.max(i.length,f.length),h=s>0?1-n/s:1;D={type:"changed",path:l,oldValue:i,newValue:f,meta:{levenDistance:n,similarity:h}},m=!0}else D=y(i,f,u,l),D.type!=="unchanged"&&(m=!0);o.push(D)}return m?{type:"changed",path:r,oldValue:e,newValue:t,children:o}:{type:"unchanged",path:r,oldValue:e,newValue:t}}var a={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",gray:"\x1B[90m"};function E(e,t={}){let{color:u=!0,full:r=!1,withSimilarity:o=!1}=t;return e.type==="unchanged"&&!r&&(!e.children||e.children.length===0)?"":!e.children||e.children.length===0?C(e,u,o):G(e,t,0)}function C(e,t,u=!1){let r=H(e.type),o="";switch(e.type){case"added":return o=c(e.newValue),t?`${a.green}${r} ${o}${a.reset}`:`${r} ${o}`;case"removed":return o=c(e.oldValue),t?`${a.red}${r} ${o}${a.reset}`:`${r} ${o}`;case"changed":let m=c(e.oldValue),$=c(e.newValue),l="";if(u&&e.meta?.similarity!==void 0&&typeof e.oldValue=="string"&&typeof e.newValue=="string"){let D=Math.round(e.meta.similarity*100);l=t?`${a.gray} (${D}% similar)${a.reset}`:` (${D}% similar)`}let i=t?`${a.red}- ${m}${a.reset}`:`- ${m}`,f=t?`${a.green}+ ${$}${l}${a.reset}`:`+ ${$}${l}`;return`${i}
|
|
2
|
+
${f}`;default:return o=c(e.newValue??e.oldValue),t?`${a.gray}${r} ${o}${a.reset}`:`${r} ${o}`}}function G(e,t,u=0){let{full:r=!1}=t;return e.type==="unchanged"&&!r&&(!e.children||e.children.length===0||typeof e.oldValue!="object"&&typeof e.newValue!="object")?"":Array.isArray(e.oldValue)||Array.isArray(e.newValue)?p(e,t,u):d(e,t,u)}function p(e,t,u=0){let{color:r=!0,full:o=!1,withSimilarity:m=!1}=t,$=" ".repeat(u),l=" ".repeat(u+2),i=`[
|
|
3
|
+
`,f=0;if(e.children)for(let D=0;D<e.children.length;D++){let n=e.children[D];if(!(n.type==="unchanged"&&!o&&(!n.children||n.children.length===0)))if(n.children&&n.children.length>0){let s=Array.isArray(n.newValue||n.oldValue)?p(n,t,u+2):d(n,t,u+2);s.trim().length>2&&(f>0&&(i+=`,
|
|
4
|
+
`),i+=l,i+=s,f++)}else switch(f>0&&(i+=`,
|
|
5
|
+
`),n.type){case"added":i+=r?`${l}${a.green}+ ${c(n.newValue)}${a.reset}`:`${l}+ ${c(n.newValue)}`,f++;break;case"removed":i+=r?`${l}${a.red}- ${c(n.oldValue)}${a.reset}`:`${l}- ${c(n.oldValue)}`,f++;break;case"unchanged":n.meta?.ignored&&n.path?i+=r?`${l}${a.gray} ${n.path[n.path.length-1]||""}${a.reset}`:`${l} ${n.path[n.path.length-1]||""}`:i+=r?`${l}${a.gray} ${c(n.newValue)}${a.reset}`:`${l} ${c(n.newValue)}`,f++;break;case"changed":i+=r?`${l}${a.red}- ${c(n.oldValue)}${a.reset}
|
|
6
|
+
${l}${a.green}+ ${c(n.newValue)}${n.meta?.similarity!==void 0&&m?r?`${a.gray} (${Math.round(n.meta.similarity*100)}% similar)${a.reset}`:` (${Math.round(n.meta.similarity*100)}% similar)`:""}${a.reset}`:`${l}- ${c(n.oldValue)}
|
|
7
|
+
${l}+ ${c(n.newValue)}${n.meta?.similarity!==void 0&&m?` (${Math.round(n.meta.similarity*100)}% similar)`:""}`,f++;break}}return f>0&&(i+=`
|
|
8
|
+
`),i+=`${$}]`,i}function d(e,t,u=0){let{color:r=!0,full:o=!1,withSimilarity:m=!1}=t,$=" ".repeat(u),l=" ".repeat(u+2),i=`{
|
|
9
|
+
`,f=0;if(e.children){let D=e.children.filter(n=>{if(n.type!=="unchanged"||o||n.children&&n.children.length>0)return!0;let s=n.path?.[n.path.length-1]||"";return!!t.outputKeys?.includes(s)});for(let n=0;n<D.length;n++){let s=D[n],h=s.path?.[s.path.length-1]||"",R=n===D.length-1;if(f>0&&!i.endsWith(`
|
|
10
|
+
`)&&(i+=`,
|
|
11
|
+
`),s.children&&s.children.length>0){let b=Array.isArray(s.newValue||s.oldValue)?p(s,t,u+2):d(s,t,u+2);b.trim().length>2&&(i+=`${l}${h}: ${b}`,f++)}else switch(s.type){case"added":i+=r?`${l}${a.green}+ ${h}: ${c(s.newValue)}${a.reset}`:`${l}+ ${h}: ${c(s.newValue)}`,f++;break;case"removed":i+=r?`${l}${a.red}- ${h}: ${c(s.oldValue)}${a.reset}`:`${l}- ${h}: ${c(s.oldValue)}`,f++;break;case"changed":i+=r?`${l}${a.red}- ${h}: ${c(s.oldValue)}${a.reset}
|
|
12
|
+
${l}${a.green}+ ${h}: ${c(s.newValue)}${s.meta?.similarity!==void 0&&m?r?`${a.gray} (${Math.round(s.meta.similarity*100)}% similar)${a.reset}`:` (${Math.round(s.meta.similarity*100)}% similar)`:""}${a.reset}`:`${l}- ${h}: ${c(s.oldValue)}
|
|
13
|
+
${l}+ ${h}: ${c(s.newValue)}${s.meta?.similarity!==void 0&&m?` (${Math.round(s.meta.similarity*100)}% similar)`:""}`,f++;break;case"unchanged":(o||t.outputKeys?.includes(h))&&(s.meta?.ignored?i+=r?`${l}${a.gray} ${h}${a.reset}`:`${l} ${h}`:i+=r?`${l}${a.gray} ${h}: ${c(s.newValue)}${a.reset}`:`${l} ${h}: ${c(s.newValue)}`,f++);break}!R&&!i.endsWith(`
|
|
14
|
+
`)&&(i+=","),i.endsWith(`
|
|
15
|
+
`)||(i+=`
|
|
16
|
+
`)}}return f>0&&!i.endsWith(`
|
|
17
|
+
`)&&(i+=`
|
|
18
|
+
`),i+=`${$}}`,i}function H(e){switch(e){case"added":return"+";case"removed":return"-";case"changed":return"!";default:return" "}}function c(e){return e===void 0?"undefined":e===null?"null":typeof e=="string"?`'${e}'`:typeof e=="number"||typeof e=="boolean"?e.toString():typeof e=="object"?JSON.stringify(e,null,2):String(e)}function N(e,t,u={}){return y(e,t,u)}function B(e,t,u={}){let r=N(e,t,u);return E(r,u)}function F(e,t,u={}){return N(e,t,u).type!=="unchanged"}export{g as DiffType,B as diff,N as diffRaw,F as isDiff};
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diff-leven",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Git like diff between two strings, using the Levenshtein distance algorithm",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"files": [
|
|
9
21
|
"dist"
|
|
10
22
|
],
|
|
@@ -40,13 +52,13 @@
|
|
|
40
52
|
},
|
|
41
53
|
"homepage": "https://github.com/kushalshit27/diff-leven#readme",
|
|
42
54
|
"devDependencies": {
|
|
43
|
-
"eslint": "^9.
|
|
55
|
+
"eslint": "^9.28.0",
|
|
44
56
|
"husky": "9.1.7",
|
|
45
57
|
"prettier": "^3.5.3",
|
|
46
58
|
"ts-node": "^10.9.2",
|
|
47
59
|
"tsup": "^8.5.0",
|
|
48
60
|
"typescript": "^5.8.3",
|
|
49
|
-
"typescript-eslint": "^8.
|
|
61
|
+
"typescript-eslint": "^8.33.0",
|
|
50
62
|
"vitest": "^3.1.4"
|
|
51
63
|
},
|
|
52
64
|
"engines": {
|