Compare commits

..

5 Commits

Author SHA1 Message Date
576e81588d 2.0.21 2016-11-02 22:55:20 +01:00
76c590b045 improve README 2016-11-02 22:55:17 +01:00
bb7caa36ea 2.0.20 2016-11-01 19:00:35 +01:00
a3a51bf0ca small export fix 2016-11-01 19:00:32 +01:00
1684eae1e8 expose base64 functions seperate from class 2016-11-01 18:59:43 +01:00
10 changed files with 93 additions and 27 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)

2
dist/index.d.ts vendored
View File

@ -2,6 +2,6 @@ import * as docker from './smartstring.docker';
import * as indent from './smartstring.indent'; import * as indent from './smartstring.indent';
import * as typescript from './smartstring.typescript'; import * as typescript from './smartstring.typescript';
export { docker, typescript, indent }; export { docker, typescript, indent };
export { Base64 } from './smartstring.base64'; export { Base64, base64 } from './smartstring.base64';
export { Domain } from './smartstring.domain'; export { Domain } from './smartstring.domain';
export { GitRepo } from './smartstring.git'; export { GitRepo } from './smartstring.git';

3
dist/index.js vendored
View File

@ -7,8 +7,9 @@ const typescript = require("./smartstring.typescript");
exports.typescript = typescript; exports.typescript = typescript;
var smartstring_base64_1 = require("./smartstring.base64"); var smartstring_base64_1 = require("./smartstring.base64");
exports.Base64 = smartstring_base64_1.Base64; exports.Base64 = smartstring_base64_1.Base64;
exports.base64 = smartstring_base64_1.base64;
var smartstring_domain_1 = require("./smartstring.domain"); var smartstring_domain_1 = require("./smartstring.domain");
exports.Domain = smartstring_domain_1.Domain; exports.Domain = smartstring_domain_1.Domain;
var smartstring_git_1 = require("./smartstring.git"); var smartstring_git_1 = require("./smartstring.git");
exports.GitRepo = smartstring_git_1.GitRepo; exports.GitRepo = smartstring_git_1.GitRepo;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQTZDO0FBQXBDLHNDQUFBLE1BQU0sQ0FBQTtBQUNmLDJEQUE2QztBQUFwQyxzQ0FBQSxNQUFNLENBQUE7QUFDZixxREFBMkM7QUFBbEMsb0NBQUEsT0FBTyxDQUFBIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQXFEO0FBQTVDLHNDQUFBLE1BQU0sQ0FBQTtBQUFFLHNDQUFBLE1BQU0sQ0FBQTtBQUN2QiwyREFBNkM7QUFBcEMsc0NBQUEsTUFBTSxDQUFBO0FBQ2YscURBQTJDO0FBQWxDLG9DQUFBLE9BQU8sQ0FBQSJ9

View File

@ -19,5 +19,10 @@ 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: {
encode: (stringArg: string) => any;
encodeUri: (stringArg: string) => any;
decode: (stringArg: string) => any;
};

View File

@ -10,10 +10,10 @@ class Base64 {
this.refString = inputStringArg; this.refString = inputStringArg;
break; break;
case 'base64': case 'base64':
this.refString = plugins.jsBase64.decode(inputStringArg); this.refString = exports.base64.decode(inputStringArg);
break; break;
case 'base64uri': case 'base64uri':
this.refString = plugins.jsBase64.decode(inputStringArg); this.refString = exports.base64.decode(inputStringArg);
} }
} }
/** /**
@ -26,14 +26,34 @@ class Base64 {
* the base64 encoded version of the original string * the base64 encoded version of the original string
*/ */
get base64String() { get base64String() {
return plugins.jsBase64.encode(this.refString); return exports.base64.encode(this.refString);
} }
/** /**
* the base64uri encoded version of the original string * the base64uri encoded version of the original string
*/ */
get base64StringUri() { get base64UriString() {
return plugins.jsBase64.encodeURI(this.refString); return exports.base64.encodeUri(this.refString);
} }
} }
exports.Base64 = Base64; exports.Base64 = Base64;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUFJLENBQUMsU0FBUyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLGNBQWMsQ0FBQyxDQUFBO2dCQUN4RCxLQUFLLENBQUE7WUFDVCxLQUFLLFdBQVc7Z0JBQ1osSUFBSSxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxjQUFjLENBQUMsQ0FBQTtRQUNoRSxDQUFDO0lBQ0wsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSSxZQUFZO1FBQ1osTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUE7SUFDekIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSSxZQUFZO1FBQ1osTUFBTSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNsRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLGVBQWU7UUFDZixNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3JELENBQUM7Q0FDSjtBQW5DRCx3QkFtQ0MifQ== exports.base64 = {
/**
* encodes the string
*/
encode: (stringArg) => {
return plugins.jsBase64.encode(stringArg);
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg) => {
return plugins.jsBase64.encodeURI(stringArg);
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg) => {
return plugins.jsBase64.decode(stringArg);
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUFJLENBQUMsU0FBUyxHQUFHLGNBQU0sQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUE7Z0JBQzlDLEtBQUssQ0FBQTtZQUNULEtBQUssV0FBVztnQkFDWixJQUFJLENBQUMsU0FBUyxHQUFHLGNBQU0sQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUE7UUFDdEQsQ0FBQztJQUNMLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksWUFBWTtRQUNaLE1BQU0sQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFBO0lBQ3pCLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUksWUFBWTtRQUNaLE1BQU0sQ0FBQyxjQUFNLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUN4QyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJLGVBQWU7UUFDZixNQUFNLENBQUMsY0FBTSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDM0MsQ0FBQztDQUNKO0FBbkNELHdCQW1DQztBQUVVLFFBQUEsTUFBTSxHQUFHO0lBQ2hCOztPQUVHO0lBQ0gsTUFBTSxFQUFFLENBQUMsU0FBaUI7UUFDdEIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQzdDLENBQUM7SUFFRDs7T0FFRztJQUNILFNBQVMsRUFBRSxDQUFDLFNBQWlCO1FBQ3pCLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNoRCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxNQUFNLEVBQUUsQ0FBQyxTQUFpQjtRQUN0QixNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDN0MsQ0FBQztDQUNKLENBQUEifQ==

View File

@ -1,6 +1,6 @@
{ {
"name": "smartstring", "name": "smartstring",
"version": "2.0.19", "version": "2.0.21",
"description": "handle strings in smart ways. TypeScript ready.", "description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

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

@ -8,6 +8,6 @@ export {
indent indent
} }
export { Base64 } from './smartstring.base64' export { Base64, base64 } from './smartstring.base64'
export { Domain } from './smartstring.domain' export { Domain } from './smartstring.domain'
export { GitRepo } from './smartstring.git' export { GitRepo } from './smartstring.git'

View File

@ -16,10 +16,10 @@ export class Base64 {
this.refString = inputStringArg this.refString = inputStringArg
break break
case 'base64': case 'base64':
this.refString = plugins.jsBase64.decode(inputStringArg) this.refString = base64.decode(inputStringArg)
break break
case 'base64uri': case 'base64uri':
this.refString = plugins.jsBase64.decode(inputStringArg) this.refString = base64.decode(inputStringArg)
} }
} }
@ -34,13 +34,36 @@ export class Base64 {
* the base64 encoded version of the original string * the base64 encoded version of the original string
*/ */
get base64String() { get base64String() {
return plugins.jsBase64.encode(this.refString) return base64.encode(this.refString)
} }
/** /**
* the base64uri encoded version of the original string * the base64uri encoded version of the original string
*/ */
get base64StringUri() { get base64UriString() {
return plugins.jsBase64.encodeURI(this.refString) return base64.encodeUri(this.refString)
}
}
export let base64 = {
/**
* encodes the string
*/
encode: (stringArg: string) => {
return plugins.jsBase64.encode(stringArg)
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg: string) => {
return plugins.jsBase64.encodeURI(stringArg)
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg: string) => {
return plugins.jsBase64.decode(stringArg)
} }
} }