diff --git a/README.md b/README.md index 0da6331..a58e668 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,16 @@ Use TypeScript for intellisense. ```typescript import * as smartstring from "smartstring"; +// classes + +// smartstring.Domain class +let myDomain = new smartstring.Domain("https://sub.main.tld"); +myDomain.level1 // "tld" +myDomain.level2 // "main" +// level3 , level 4 and so on... +myDomain.zoneName // "main.tld" +myDOmain.protocol // "https" + // smartstring.GitRepo class let myGitRepo = new smartstring.GitRepo("git@github.com:someorg/somerepo.git"); // takes https and git and npm repo URL versions myGitRepo.host // "github.com" @@ -32,13 +42,20 @@ myGitRepo.accessToken // accessToken if specified with https myGitRepo.sshUrl // "git@github.com:someorg/somerepo.git" (computed also from https) myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh) -// smartstring.Domain class -let myDomain = new smartstring.Domain("https://sub.main.tld"); -myDomain.level1 // "tld" -myDomain.level2 // "main" -// level3 , level 4 and so on... -myDomain.zoneName // "main.tld" -myDOmain.protocol // "https" +//smartstring.Base64 +let myBase64 = new smartstring.Base64('somestring','string') // first arg is the string, second is string type (can be string, base64, base64uri) +myBase64.simpleString // 'somestring' +myBase64.base64String // base64 representation of 'somestring' +myBase64.base64UriString // base64uri representation of 'sometring' + +// methods +smartstring.base64.encode('somestring') // encodes 'somestring' to base64 +smartstring.base64.encodeUri('sometring') // encodes 'somestring' to base64uri +smartstring.base64.decode() // decodes base64 and base64uri to simple string respresentation + +smartstring.indent.indent('somestring\anotherstring', 4) // indents a string by 4 +smartstring.indent.indent('somestring\anotherstring', '>>>> ') // indents a string with a prefix +smartstring.indent.normalize(' somestring\ anotherstring', '>>>> ') // looks for the least amount of indention and removes superflouous space ``` [![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) diff --git a/dist/smartstring.base64.d.ts b/dist/smartstring.base64.d.ts index 2a93b09..3a8509a 100644 --- a/dist/smartstring.base64.d.ts +++ b/dist/smartstring.base64.d.ts @@ -19,7 +19,7 @@ export declare class Base64 { /** * the base64uri encoded version of the original string */ - readonly base64StringUri: any; + readonly base64UriString: any; } export declare let base64: { encode: (stringArg: string) => any; diff --git a/dist/smartstring.base64.js b/dist/smartstring.base64.js index 2d3d68c..5a878b4 100644 --- a/dist/smartstring.base64.js +++ b/dist/smartstring.base64.js @@ -31,7 +31,7 @@ class Base64 { /** * the base64uri encoded version of the original string */ - get base64StringUri() { + get base64UriString() { return exports.base64.encodeUri(this.refString); } } diff --git a/test/test.js b/test/test.js index c7e4c40..472053f 100644 --- a/test/test.js +++ b/test/test.js @@ -10,8 +10,8 @@ describe('smartstring', function () { should(testBase64).be.instanceOf(smartstring.Base64); }); it('should read output a file as base64 and base64uri', function () { - should(testBase64.base64String).not.equal(testBase64.base64StringUri); - let testBase64_2 = new smartstring.Base64(testBase64.base64StringUri, 'base64uri'); + should(testBase64.base64String).not.equal(testBase64.base64UriString); + let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri'); should(testBase64_2.simpleString).equal(testBase64.simpleString); }); }); diff --git a/test/test.ts b/test/test.ts index 832e01b..2c87435 100644 --- a/test/test.ts +++ b/test/test.ts @@ -10,8 +10,8 @@ describe('smartstring',function(){ should(testBase64).be.instanceOf(smartstring.Base64) }) it('should read output a file as base64 and base64uri', function(){ - should(testBase64.base64String).not.equal(testBase64.base64StringUri) - let testBase64_2 = new smartstring.Base64(testBase64.base64StringUri, 'base64uri') + should(testBase64.base64String).not.equal(testBase64.base64UriString) + let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri') should(testBase64_2.simpleString).equal(testBase64.simpleString) }) }) diff --git a/ts/smartstring.base64.ts b/ts/smartstring.base64.ts index de5653f..fc79767 100644 --- a/ts/smartstring.base64.ts +++ b/ts/smartstring.base64.ts @@ -40,7 +40,7 @@ export class Base64 { /** * the base64uri encoded version of the original string */ - get base64StringUri() { + get base64UriString() { return base64.encodeUri(this.refString) } }