diff --git a/src/index.ts b/src/index.ts index 4e9c138..8f4bfbb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import obfuscate from "./obfuscate"; -export * from './encryption-character-range.enum' +export * from "./encryption-character-range.enum"; export default obfuscate; diff --git a/src/obfuscate/number.ts b/src/obfuscate/number.ts index 99efd1d..7b3594a 100644 --- a/src/obfuscate/number.ts +++ b/src/obfuscate/number.ts @@ -1,5 +1,5 @@ import obfuscateString from "./string"; export default function obfuscateNumber(n: number, translation) { - return obfuscateString(`${n}`, translation) + return obfuscateString(`${n}`, translation); } diff --git a/src/obfuscate/object.ts b/src/obfuscate/object.ts index 749d398..bda4b08 100644 --- a/src/obfuscate/object.ts +++ b/src/obfuscate/object.ts @@ -5,7 +5,7 @@ import obfuscateString from "./string"; export default function obfuscateObject( value: T, translation: Map -): T { +): T { const obj = _.clone(value); Object.keys(obj).map((key) => { diff --git a/src/obfuscate/value.ts b/src/obfuscate/value.ts index 9c71cd5..ef81e60 100644 --- a/src/obfuscate/value.ts +++ b/src/obfuscate/value.ts @@ -6,18 +6,15 @@ import obfuscateString from "./string"; export default function obfuscateValue( value: T | string | number, translation: Map -): T | string | number { - - switch (typeof value) { - case "number": - return obfuscateNumber(value, translation); - case "string": - return obfuscateString(value, translation); - case "object": - return obfuscateObject(value, translation); - default: - throw new Error(typeof value + ' could not be obfuscated'); - } +): T | string | number { + switch (typeof value) { + case "number": + return obfuscateNumber(value, translation); + case "string": + return obfuscateString(value, translation); + case "object": + return obfuscateObject(value, translation); + default: + throw new Error(typeof value + " could not be obfuscated"); + } } - - \ No newline at end of file diff --git a/src/obfuscation-options.ts b/src/obfuscation-options.ts index 7d191ae..724289e 100644 --- a/src/obfuscation-options.ts +++ b/src/obfuscation-options.ts @@ -1,7 +1,6 @@ import { EncryptionCharacterRange } from "."; export interface ObfuscationOptions { - /** * obfuscation strength multiplier ( default: 1 ) * all under 0.1 makes no sense ( can simply be rounded and so back calculated ) @@ -13,5 +12,4 @@ export interface ObfuscationOptions { * the character-range to pick obfuscation glyphs from */ characterRange?: EncryptionCharacterRange; - } diff --git a/src/value2glyphs.ts b/src/value2glyphs.ts index fdc9c7a..a6c0301 100644 --- a/src/value2glyphs.ts +++ b/src/value2glyphs.ts @@ -1,12 +1,9 @@ import _ from "lodash"; import { Font, Glyph } from "opentype.js"; - - const values = (object) => { - - if (typeof object === 'number') { - object = `${object}` + if (typeof object === "number") { + object = `${object}`; } return _.flatten( @@ -28,11 +25,11 @@ export default function value2glyphs(value: T, font: Font): Glyph[] { const uniqChars = _.union(chars); - const glyphs = font.stringToGlyphs(_.shuffle(uniqChars).join("")); + const glyphs = font.stringToGlyphs(_.shuffle(uniqChars).join("")); - const notDefGlyph = font.glyphs.glyphs[0] + const notDefGlyph = font.glyphs.glyphs[0]; - glyphs.unshift(notDefGlyph) + glyphs.unshift(notDefGlyph); - return glyphs + return glyphs; }