improve README

This commit is contained in:
Philipp Kunz 2016-11-02 22:55:17 +01:00
parent bb7caa36ea
commit 76c590b045
6 changed files with 31 additions and 14 deletions

View File

@ -23,6 +23,16 @@ Use TypeScript for intellisense.
```typescript ```typescript
import * as smartstring from "smartstring"; 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 // smartstring.GitRepo class
let myGitRepo = new smartstring.GitRepo("git@github.com:someorg/somerepo.git"); // takes https and git and npm repo URL versions let myGitRepo = new smartstring.GitRepo("git@github.com:someorg/somerepo.git"); // takes https and git and npm repo URL versions
myGitRepo.host // "github.com" 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.sshUrl // "git@github.com:someorg/somerepo.git" (computed also from https)
myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh) myGitRepo.httpsUrl // "https://github.com/someorg/somerepo.git" (computed also from ssh)
// smartstring.Domain class //smartstring.Base64
let myDomain = new smartstring.Domain("https://sub.main.tld"); let myBase64 = new smartstring.Base64('somestring','string') // first arg is the string, second is string type (can be string, base64, base64uri)
myDomain.level1 // "tld" myBase64.simpleString // 'somestring'
myDomain.level2 // "main" myBase64.base64String // base64 representation of 'somestring'
// level3 , level 4 and so on... myBase64.base64UriString // base64uri representation of 'sometring'
myDomain.zoneName // "main.tld"
myDOmain.protocol // "https" // 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) [![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

View File

@ -19,7 +19,7 @@ export declare class Base64 {
/** /**
* the base64uri encoded version of the original string * the base64uri encoded version of the original string
*/ */
readonly base64StringUri: any; readonly base64UriString: any;
} }
export declare let base64: { export declare let base64: {
encode: (stringArg: string) => any; encode: (stringArg: string) => any;

View File

@ -31,7 +31,7 @@ class Base64 {
/** /**
* the base64uri encoded version of the original string * the base64uri encoded version of the original string
*/ */
get base64StringUri() { get base64UriString() {
return exports.base64.encodeUri(this.refString); return exports.base64.encodeUri(this.refString);
} }
} }

View File

@ -10,8 +10,8 @@ describe('smartstring', function () {
should(testBase64).be.instanceOf(smartstring.Base64); should(testBase64).be.instanceOf(smartstring.Base64);
}); });
it('should read output a file as base64 and base64uri', function () { it('should read output a file as base64 and base64uri', function () {
should(testBase64.base64String).not.equal(testBase64.base64StringUri); should(testBase64.base64String).not.equal(testBase64.base64UriString);
let testBase64_2 = new smartstring.Base64(testBase64.base64StringUri, 'base64uri'); let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
should(testBase64_2.simpleString).equal(testBase64.simpleString); should(testBase64_2.simpleString).equal(testBase64.simpleString);
}); });
}); });

View File

@ -10,8 +10,8 @@ describe('smartstring',function(){
should(testBase64).be.instanceOf(smartstring.Base64) should(testBase64).be.instanceOf(smartstring.Base64)
}) })
it('should read output a file as base64 and base64uri', function(){ it('should read output a file as base64 and base64uri', function(){
should(testBase64.base64String).not.equal(testBase64.base64StringUri) should(testBase64.base64String).not.equal(testBase64.base64UriString)
let testBase64_2 = new smartstring.Base64(testBase64.base64StringUri, 'base64uri') let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri')
should(testBase64_2.simpleString).equal(testBase64.simpleString) should(testBase64_2.simpleString).equal(testBase64.simpleString)
}) })
}) })

View File

@ -40,7 +40,7 @@ export class Base64 {
/** /**
* the base64uri encoded version of the original string * the base64uri encoded version of the original string
*/ */
get base64StringUri() { get base64UriString() {
return base64.encodeUri(this.refString) return base64.encodeUri(this.refString)
} }
} }