Skip to content

Commit

Permalink
fix: remove reTrimSpace in favor of trim (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen authored Apr 28, 2023
1 parent a0cb846 commit a61ec13
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup latest deno version
uses: denolib/setup-deno@v2
uses: denoland/setup-deno@main
with:
deno-version: v1.x

Expand All @@ -24,10 +24,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup latest deno version
uses: denolib/setup-deno@v2
uses: denoland/setup-deno@main
with:
deno-version: v1.x

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
version:
description: 'Emoji Version'
required: true
default: 14
default: 15

jobs:
publish:
Expand All @@ -24,13 +24,12 @@ jobs:
uses: actions/checkout@v3

- name: Setup Deno
# uses: denoland/setup-deno@v1
uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
uses: denoland/setup-deno@main
with:
deno-version: v1.x

- name: Run Update Script
run: deno run --allow-net --allow-write ./update.ts ${{ github.event.inputs.version }}
run: deno task update ${{ github.event.inputs.version }}

- name: Run deno fmt
run: deno fmt
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2014 Daniel Bugl
Copyright (c) 2020-2023 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
8 changes: 4 additions & 4 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export { Emoji };
// Regex to parse emoji in a string - e.g. :coffee:
const reEmojiName = /:([a-zA-Z0-9_\-\+]+):/g;

// Regex to trim whitespace. (with IE8 support)
const reTrimSpace = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;

// Non spacing mark, some emoticons have them. It's the 'Variant Form',
// which provides more information so that emoticons can be rendered as
// more colorful graphics. FE0E is a unicode text version, where as FE0F
Expand All @@ -28,11 +25,10 @@ function stripColons(str: string): string {
if (colonIndex > -1) {
if (colonIndex === str.length - 1) {
str = str.substring(0, colonIndex);
return stripColons(str);
} else {
str = str.substr(colonIndex + 1);
return stripColons(str);
str = str.substring(colonIndex + 1);
}
return stripColons(str);
}

return str;
Expand Down Expand Up @@ -128,7 +124,7 @@ export function replace(
return emoji ? replace(emoji) : s;
})
.join("");
return trim ? result.replace(reTrimSpace, "") : result;
return trim ? result.trim() : result;
}

/** Replace all emoji names in a string with actual emojis. */
Expand Down
2 changes: 1 addition & 1 deletion emoji.test.ts → emoji_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.184.0/testing/asserts.ts";
import * as emj from "./emoji.ts";

Deno.test({
Expand Down

0 comments on commit a61ec13

Please sign in to comment.