-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: cleanup entire project API
- Loading branch information
1 parent
a0d5502
commit c2382bc
Showing
24 changed files
with
982 additions
and
584 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @module edge | ||
*/ | ||
|
||
/* | ||
* edge | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* This class generates a valid object as a string, which is written to the template | ||
* output. The reason we need a string like object, since we don't want it's | ||
* properties to be evaluated during the object creation, instead it must | ||
* be evaluated when the compiled output is invoked. | ||
*/ | ||
export class StringifiedObject { | ||
private obj: string = '' | ||
|
||
/** | ||
* Add key/value pair to the object. | ||
* | ||
* ```js | ||
* stringifiedObject.add('username', `'virk'`) | ||
* ``` | ||
*/ | ||
public add (key: any, value: any) { | ||
this.obj += this.obj.length ? `, ${key}: ${value}` : `${key}: ${value}` | ||
} | ||
|
||
/** | ||
* Returns the object alike string back. | ||
* | ||
* ```js | ||
* stringifiedObject.flush() | ||
* | ||
* // returns | ||
* `{ username: 'virk' }` | ||
* ``` | ||
*/ | ||
public flush (): string { | ||
const obj = `{ ${this.obj} }` | ||
this.obj = '' | ||
return obj | ||
} | ||
} |
Oops, something went wrong.