diff options
| author | Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> | 2019-09-29 19:04:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-29 19:04:29 -0400 |
| commit | 89fd714207dbd965dc4b566202ec85bbd7998adf (patch) | |
| tree | 4b6279f1fe0157eb79fabd000a55754c33253506 /src/extensions | |
| parent | c40480ec1a2da84b4223b0605bea2fe19df1104c (diff) | |
| parent | 5bd6158a1f839d19f8965bff97a908c89271437d (diff) | |
Merge pull request #289 from browngraphicslab/googlephotos_sharing_master
Googlephotos sharing master
Diffstat (limited to 'src/extensions')
| -rw-r--r-- | src/extensions/ArrayExtensions.ts | 13 | ||||
| -rw-r--r-- | src/extensions/General/Extensions.ts | 9 | ||||
| -rw-r--r-- | src/extensions/General/ExtensionsTypings.ts | 8 | ||||
| -rw-r--r-- | src/extensions/StringExtensions.ts | 17 |
4 files changed, 47 insertions, 0 deletions
diff --git a/src/extensions/ArrayExtensions.ts b/src/extensions/ArrayExtensions.ts new file mode 100644 index 000000000..422a10dbc --- /dev/null +++ b/src/extensions/ArrayExtensions.ts @@ -0,0 +1,13 @@ +function Assign() { + + Array.prototype.lastElement = function <T>() { + if (!this.length) { + return undefined; + } + const last: T = this[this.length - 1]; + return last; + }; + +} + +export { Assign };
\ No newline at end of file diff --git a/src/extensions/General/Extensions.ts b/src/extensions/General/Extensions.ts new file mode 100644 index 000000000..4b6d05d5f --- /dev/null +++ b/src/extensions/General/Extensions.ts @@ -0,0 +1,9 @@ +import { Assign as ArrayAssign } from "../ArrayExtensions"; +import { Assign as StringAssign } from "../StringExtensions"; + +function AssignAllExtensions() { + ArrayAssign(); + StringAssign(); +} + +export { AssignAllExtensions };
\ No newline at end of file diff --git a/src/extensions/General/ExtensionsTypings.ts b/src/extensions/General/ExtensionsTypings.ts new file mode 100644 index 000000000..370157ed0 --- /dev/null +++ b/src/extensions/General/ExtensionsTypings.ts @@ -0,0 +1,8 @@ +interface Array<T> { + lastElement(): T; +} + +interface String { + removeTrailingNewlines(): string; + hasNewline(): boolean; +}
\ No newline at end of file diff --git a/src/extensions/StringExtensions.ts b/src/extensions/StringExtensions.ts new file mode 100644 index 000000000..2c76e56c8 --- /dev/null +++ b/src/extensions/StringExtensions.ts @@ -0,0 +1,17 @@ +function Assign() { + + String.prototype.removeTrailingNewlines = function () { + let sliced = this; + while (sliced.endsWith("\n")) { + sliced = sliced.substring(0, this.length - 1); + } + return sliced as string; + }; + + String.prototype.hasNewline = function () { + return this.endsWith("\n"); + }; + +} + +export { Assign };
\ No newline at end of file |
