Skip to content

Commit

Permalink
Merge pull request benawad#2722 from goldyydev/patch-38
Browse files Browse the repository at this point in the history
feat(dolma) dolma improvements
  • Loading branch information
goldyydev authored May 14, 2021
2 parents 667abcd + fb72879 commit add0ab7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
27 changes: 19 additions & 8 deletions dolma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ interface RootMethodResponse {

export * from './util/types/tokenTypes';

export default function dolma(values?: Array<Unitoken | MessageToken | string> | string): RootMethodResponse {
return {
encoded: encodeTokens(values ?? ""),
decoded: decodeTokens(values ?? "")
}
}
// export default function dolma(values?: Array<Unitoken | MessageToken | string> | string): RootMethodResponse {
// return {
// encoded: encodeTokens(values ?? ""),
// decoded: decodeTokens(values ?? "")
// }
// }

// dolma['encode'] = encodeTokens;
// dolma['decode'] = decodeTokens;

export default class dolma {
public readonly emotes: {name: string}[];

dolma['encode'] = encodeTokens;
dolma['decode'] = decodeTokens;
constructor(emotes: {name: string}[]) {
this.emotes = emotes;
}

public decode = decodeTokens;
public encode = encodeTokens;
}
2 changes: 1 addition & 1 deletion dolma/src/test/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function main() {

tests.encoding.map(async test => {
const started = new Date();
const encodedValue = dolma.encode(test.input);
const encodedValue = new dolma([]).encode(test.input);
if (JSON.stringify(encodedValue) == JSON.stringify(test.expectedOutput)) testFinished(test, started, true);
else testFinished(test, started, false);
});
Expand Down
4 changes: 2 additions & 2 deletions dolma/src/util/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const validationRegex = {
emote: /\:([a-z0-9]+)\:/gi,
block: /\`(.*?)\`/gi,

global: /(\`.*?\`)|(\@[a-zA-Z0-9_]{4,})|(\:[a-z0-9]+\:)|(https?\:\/\/[^ ]+)/gi,
global: /(?=(\`.*?\`)|(\@[a-zA-Z0-9_]{4,})|(\:[a-z0-9]+\:)|(https?\:\/\/[^ ]+))/gi,

unicodeEmoji: /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])/gm
}
}
1 change: 1 addition & 0 deletions dolma/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true,
"noImplicitAny": false
},
"include": ["src/**/*.ts"]
Expand Down

0 comments on commit add0ab7

Please sign in to comment.