Compare commits

...

70 Commits

Author SHA1 Message Date
563d6f0ac3 3.0.26 2022-03-18 22:52:38 +01:00
4da0aeb871 fix(core): update 2022-03-18 22:52:38 +01:00
931defe98a 3.0.25 2022-03-18 22:50:25 +01:00
1e6077ce34 fix(core): update 2022-03-18 22:50:24 +01:00
8b1769d65e 3.0.24 2021-01-22 18:27:51 +00:00
48878c0b38 fix(core): update 2021-01-22 18:27:50 +00:00
76cfc8bec0 3.0.23 2021-01-22 14:46:04 +00:00
7f3118c525 fix(core): update 2021-01-22 14:46:02 +00:00
9d189d1b59 3.0.22 2020-12-31 04:42:47 +00:00
0266afca8e fix(core): update 2020-12-31 04:42:46 +00:00
bef836fc83 3.0.21 2020-12-31 04:25:31 +00:00
2bd1741893 fix(core): update 2020-12-31 04:25:31 +00:00
bd20512b10 3.0.20 2020-12-31 04:11:34 +00:00
25d0ba8036 fix(core): update 2020-12-31 04:11:33 +00:00
c517652122 3.0.19 2020-12-31 03:56:41 +00:00
bf3e640307 fix(core): update 2020-12-31 03:56:40 +00:00
08cb2392fa 3.0.18 2020-01-23 17:14:58 +00:00
4e1fa4efab fix(core): update 2020-01-23 17:14:57 +00:00
26d00bb9d3 3.0.17 2019-11-24 11:44:33 +00:00
fd27ed1a56 fix(core): update 2019-11-24 11:44:32 +00:00
1f31fe9dc5 3.0.16 2019-11-24 11:44:21 +00:00
bd7888f7ce fix(core): update 2019-11-24 11:44:21 +00:00
201812e182 3.0.15 2019-11-24 11:43:32 +00:00
8dfa3f8965 fix(core): update 2019-11-24 11:43:32 +00:00
43d50b746b 3.0.14 2019-10-10 18:24:04 +02:00
a1ee8f37d6 fix(core): update 2019-10-10 18:24:03 +02:00
8d9c75e113 3.0.13 2019-10-10 18:14:08 +02:00
8ff2a9d64a fix(core): update 2019-10-10 18:14:07 +02:00
8665464416 3.0.12 2019-10-10 18:03:05 +02:00
e773644256 fix(core): update 2019-10-10 18:03:04 +02:00
71fd0e614c 3.0.11 2019-10-10 17:28:24 +02:00
55a5948a51 fix(core): update 2019-10-10 17:28:23 +02:00
979375f08d 3.0.10 2019-04-16 08:55:37 +02:00
95d5c6ceee fix(core): update 2019-04-16 08:55:37 +02:00
c92ece79ff 3.0.9 2019-04-16 08:54:27 +02:00
7c625c4390 fix(core): update 2019-04-16 08:54:27 +02:00
65fc64f6aa 3.0.8 2019-01-12 20:41:02 +01:00
8cda8c55c0 fix(core): update 2019-01-12 20:41:01 +01:00
ec0b82de00 3.0.7 2019-01-12 20:19:17 +01:00
5e69664f59 fix(core): update 2019-01-12 20:19:16 +01:00
f5838f6d6a 3.0.6 2019-01-12 20:12:59 +01:00
fb4a03ad37 fix(core): update 2019-01-12 20:12:58 +01:00
ceb6962a1c 3.0.5 2018-11-28 21:01:13 +01:00
ffe757d820 fix(dependencies and structure): update 2018-11-28 21:01:13 +01:00
60eb4b6b6e 3.0.4 2018-08-14 00:21:55 +02:00
f73d394d35 fix(ci): reduce build dependencies 2018-08-14 00:21:55 +02:00
212f41e00b 3.0.3 2018-08-14 00:19:32 +02:00
59847dd287 fix(ci): fix build step 2018-08-14 00:19:32 +02:00
7fa2fb1e74 3.0.2 2018-08-14 00:17:37 +02:00
355f7442ca fix(dependencies): update test framework 2018-08-14 00:17:37 +02:00
88af0ab9aa 3.0.1 2018-08-13 22:27:22 +02:00
5b5bcd804f fix(dependencies): fix obsolete dependency on typings-global 2018-08-13 22:27:21 +02:00
8c894ea1c1 3.0.0 2018-07-21 14:37:39 +02:00
62336aa2cf BREAKING CHANGE(scope): change scope to @pushrocks 2018-07-21 14:37:39 +02:00
e9899e5451 2.0.28 2017-10-26 15:24:13 +02:00
235f380139 refactor to const 2017-10-26 15:24:10 +02:00
4a94ce3038 2.0.27 2017-10-11 15:18:30 +02:00
7c4c787539 add npmextra.json 2017-10-11 15:18:26 +02:00
714e3a162c 2.0.26 2017-10-11 14:52:24 +02:00
099bf9b270 add create module 2017-10-11 14:52:22 +02:00
83279a9c19 2.0.25 2017-10-05 15:56:03 +02:00
55d679e5ee update normalize of smartstring 2017-10-05 15:55:59 +02:00
974bf90703 2.0.24 2017-02-19 14:34:04 +01:00
93029d1aae update README 2017-02-19 14:33:00 +01:00
3a7740024c 2.0.23 2017-02-19 14:30:51 +01:00
a412285862 update dependencies and allow dots in git user and repo names 2017-02-19 14:09:39 +01:00
a57bd446d0 2.0.22 2016-11-02 23:02:00 +01:00
afe8d5bc1b improve README 2016-11-02 23:01:56 +01:00
576e81588d 2.0.21 2016-11-02 22:55:20 +01:00
76c590b045 improve README 2016-11-02 22:55:17 +01:00
50 changed files with 19946 additions and 873 deletions

18
.gitignore vendored
View File

@ -1,4 +1,20 @@
.nogit/
# artifacts
coverage/
pages/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,59 +1,140 @@
image: hosttoday/ht-docker-node:npmts
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
testLTS:
stage: test
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci test lts
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
testSTABLE:
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
stage: metadata
script:
- npmci command npmpage --host gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,44 +0,0 @@
# smartstring
handle strings in smart ways. TypeScript ready.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartstring)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartstring)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartstring)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartstring/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartstring/badges/master/build.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartstring/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartstring/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartstring.svg)](https://david-dm.org/pushrocks/smartstring)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartstring/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartstring/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartstring)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for intellisense.
```typescript
import * as smartstring from "smartstring";
// 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"
myGitRepo.user // "someorg"
myGitRepo.repo // "somerepo"
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"
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

7
dist/index.d.ts vendored
View File

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

15
dist/index.js vendored
View File

@ -1,15 +0,0 @@
"use strict";
const docker = require("./smartstring.docker");
exports.docker = docker;
const indent = require("./smartstring.indent");
exports.indent = indent;
const typescript = require("./smartstring.typescript");
exports.typescript = typescript;
var smartstring_base64_1 = require("./smartstring.base64");
exports.Base64 = smartstring_base64_1.Base64;
exports.base64 = smartstring_base64_1.base64;
var smartstring_domain_1 = require("./smartstring.domain");
exports.Domain = smartstring_domain_1.Domain;
var smartstring_git_1 = require("./smartstring.git");
exports.GitRepo = smartstring_git_1.GitRepo;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBSzFDLHdCQUFNO0FBSlYsK0NBQThDO0FBTTFDLHdCQUFNO0FBTFYsdURBQXNEO0FBSWxELGdDQUFVO0FBSWQsMkRBQXFEO0FBQTVDLHNDQUFBLE1BQU0sQ0FBQTtBQUFFLHNDQUFBLE1BQU0sQ0FBQTtBQUN2QiwyREFBNkM7QUFBcEMsc0NBQUEsTUFBTSxDQUFBO0FBQ2YscURBQTJDO0FBQWxDLG9DQUFBLE9BQU8sQ0FBQSJ9

View File

@ -1,28 +0,0 @@
/**
* the type for base 64
*/
export declare type TBase64Input = 'string' | 'base64' | 'base64uri';
/**
* handle base64 strings
*/
export declare class Base64 {
private refString;
constructor(inputStringArg: any, typeArg: TBase64Input);
/**
* the simple string (unencoded)
*/
readonly simpleString: string;
/**
* the base64 encoded version of the original string
*/
readonly base64String: any;
/**
* the base64uri encoded version of the original string
*/
readonly base64StringUri: any;
}
export declare let base64: {
encode: (stringArg: string) => any;
encodeUri: (stringArg: string) => any;
decode: (stringArg: string) => any;
};

View File

@ -1,59 +0,0 @@
"use strict";
const plugins = require("./smartstring.plugins");
/**
* handle base64 strings
*/
class Base64 {
constructor(inputStringArg, typeArg) {
switch (typeArg) {
case 'string':
this.refString = inputStringArg;
break;
case 'base64':
this.refString = exports.base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = exports.base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return exports.base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return exports.base64.encodeUri(this.refString);
}
}
exports.Base64 = Base64;
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxpREFBZ0Q7QUFPaEQ7O0dBRUc7QUFDSDtJQUVJLFlBQVksY0FBYyxFQUFFLE9BQXFCO1FBQzdDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZCxLQUFLLFFBQVE7Z0JBQ1QsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUFjLENBQUE7Z0JBQy9CLEtBQUssQ0FBQTtZQUNULEtBQUssUUFBUTtnQkFDVCxJQUFJLENBQUMsU0FBUyxHQUFHLGNBQU0sQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUE7Z0JBQ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object.
* @param envArrayArg
* @returns {}
*/
export declare let makeEnvObject: (envArrayArg: string[]) => {};

View File

@ -1,19 +0,0 @@
"use strict";
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
exports.makeEnvObject = function (envArrayArg) {
let returnObject = {};
let regexString = /(.*)=(.*)/;
if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[envKey]);
returnObject[regexMatches[1]] = regexMatches[2];
}
;
}
return returnObject;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9ja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9ja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7OztHQUlHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsVUFBVSxXQUFxQjtJQUN0RCxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUE7SUFDckIsSUFBSSxXQUFXLEdBQUcsV0FBVyxDQUFBO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sV0FBVyxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7UUFDckMsR0FBRyxDQUFDLENBQUMsSUFBSSxNQUFNLElBQUksV0FBVyxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFBO1lBQ3hELFlBQVksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxZQUFZLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkQsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -1,14 +0,0 @@
export declare class Domain {
fullName: string;
level1: string;
level2: string;
level3: string;
level4: string;
level5: string;
protocol: string;
zoneName: string;
topLevel: string;
domainName: any;
subDomain: any;
constructor(domainStringArg: string);
}

View File

@ -1,52 +0,0 @@
"use strict";
class Domain {
constructor(domainStringArg) {
let regexMatches = domainRegex(domainStringArg);
this.fullName = '';
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
let localMatch = regexMatches[i - 1];
this['level' + i.toString()] = localMatch;
if (this.fullName === '') {
this.fullName = localMatch;
}
else {
this.fullName = localMatch + '.' + this.fullName;
}
}
else {
this['level' + i.toString()] = undefined;
}
;
}
;
this.protocol = protocolRegex(domainStringArg);
this.zoneName = this.level2 + '.' + this.level1;
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
}
exports.Domain = Domain;
let domainRegex = function (stringArg) {
let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
let regexMatches = regexString.exec(stringArg);
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
let regexMatchesFiltered = regexMatches.filter(function (stringArg) {
return (stringArg !== '');
});
return regexMatchesFiltered;
};
let protocolRegex = function (stringArg) {
let regexString = /^([a-zA-Z0-9]*):\/\//;
let regexMatches = regexString.exec(stringArg);
if (regexMatches) {
return regexMatches[1];
}
else {
return undefined;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9tYWluLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOi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ENBQUM7UUFDZCxNQUFNLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzFCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQSJ9

View File

@ -1,9 +0,0 @@
export declare class GitRepo {
host: string;
user: string;
repo: string;
accessToken: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string);
}

View File

@ -1,45 +0,0 @@
"use strict";
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
class GitRepo {
constructor(stringArg, tokenArg) {
let regexMatches = gitRegex(stringArg);
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
}
}
exports.GitRepo = GitRepo;
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
let gitRegex = function (stringArg) {
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
};
let gitLink = function (hostArg, userArg, repoArg, tokenArg = '', linkTypeArg) {
let returnString;
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case 'https':
returnString = 'https://' +
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break;
case 'ssh':
returnString = 'git@' +
hostArg + ':' + userArg + '/' + repoArg + '.git';
break;
default:
console.error('Link Type ' + linkTypeArg + ' not known');
break;
}
return returnString;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZ2l0LmpzIiwic291cmNlUm9vdCI6IiIsIn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FZLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQsSUFBSSxPQUFPLEdBQUcsVUFBUyxPQUFlLEVBQUUsT0FBZSxFQUFFLE9BQWUsRUFBRSxXQUFtQixFQUFFLEVBQUUsV0FBVztJQUN4RyxJQUFJLFlBQVksQ0FBQTtJQUNoQixFQUFFLENBQUMsQ0FBQyxRQUFRLEtBQUssRUFBRSxDQUFDLENBQUMsQ0FBQztRQUNsQixRQUFRLEdBQUcsUUFBUSxHQUFHLEdBQUcsQ0FBQTtJQUM3QixDQUFDO0lBQ0QsTUFBTSxDQUFDLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNsQixLQUFLLE9BQU87WUFDUixZQUFZLEdBQUcsVUFBVTtnQkFDckIsUUFBUSxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLEdBQUcsR0FBRyxPQUFPLEdBQUcsTUFBTSxDQUFBO1lBQy9ELEtBQUssQ0FBQTtRQUNULEtBQUssS0FBSztZQUNOLFlBQVksR0FBRyxNQUFNO2dCQUNqQixPQUFPLEdBQUcsR0FBRyxHQUFHLE9BQU8sR0FBRyxHQUFHLEdBQUcsT0FBTyxHQUFHLE1BQU0sQ0FBQztZQUNyRCxLQUFLLENBQUE7UUFDVDtZQUNJLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxHQUFHLFdBQVcsR0FBRyxZQUFZLENBQUMsQ0FBQTtZQUN4RCxLQUFLLENBQUE7SUFDYixDQUFDO0lBQ0QsTUFBTSxDQUFDLFlBQVksQ0FBQTtBQUN2QixDQUFDLENBQUEifQ==

View File

@ -1,3 +0,0 @@
export declare let indent: (stringArg: string, spaceAmount: number) => string;
export declare let indentWithPrefix: (stringArg: string, prefixArg: string) => string;
export declare let normalize: (stringArg: string) => string;

View File

@ -1,61 +0,0 @@
"use strict";
let splitString = (stringArg) => {
let resultArray = stringArg.split('\n');
return cleanStringArray(resultArray);
};
let joinString = (stringArrayArg) => {
let resultString = '';
for (let line of stringArrayArg) {
resultString = resultString + line + '\n';
}
return resultString;
};
let cleanStringArray = (stringArrayArg) => {
let testRegex = /^[\s]*$/;
if (testRegex.test(stringArrayArg[0])) {
stringArrayArg.shift();
}
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
stringArrayArg.pop();
}
;
return stringArrayArg;
};
exports.indent = (stringArg, spaceAmount) => {
let resultString;
return resultString;
};
exports.indentWithPrefix = (stringArg, prefixArg) => {
let resultString;
let stringArray = splitString(stringArg);
let resultArray = [];
for (let stringItem of stringArray) {
resultArray.push(prefixArg + stringItem);
}
;
resultString = joinString(resultArray);
return resultString;
};
exports.normalize = (stringArg) => {
let resultString;
let splitStringArray = splitString(stringArg);
let minCommonLeftOffset;
let deIndentRegex = /^(\s*)/;
let emptyLineRegex = /^(\s*)$/;
for (let stringItem of splitStringArray) {
let offsetString = deIndentRegex.exec(stringItem)[1];
if ((typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
&& !emptyLineRegex.test(stringItem)) {
minCommonLeftOffset = offsetString.length;
}
}
;
let resultSplitStringArray = [];
for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
}
;
resultString = joinString(resultSplitStringArray);
return resultString;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxDQUFDLFNBQWlCO0lBQ2hDLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFBO0FBQ3hDLENBQUMsQ0F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BQztJQUNMLENBQUM7SUFBQSxDQUFDO0lBQ0YsSUFBSSxzQkFBc0IsR0FBRyxFQUFFLENBQUE7SUFDL0IsR0FBRyxDQUFDLENBQUMsSUFBSSxVQUFVLElBQUksZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1FBQ3RDLHNCQUFzQixDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQTtJQUN2RSxDQUFDO0lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUNqRCxNQUFNLENBQUMsWUFBWSxDQUFBO0FBQ3ZCLENBQUMsQ0FBQSJ9

View File

@ -1,2 +0,0 @@
import 'typings-global';
export declare let jsBase64: any;

View File

@ -1,4 +0,0 @@
"use strict";
require("typings-global");
exports.jsBase64 = require('js-base64').Base64;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUNaLFFBQUEsUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUEifQ==

View File

@ -1 +0,0 @@
export declare let regexReferencePath: RegExp;

View File

@ -1,3 +0,0 @@
"use strict";
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcudHlwZXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUVXLFFBQUEsa0JBQWtCLEdBQUcsOERBQThELENBQUEifQ==

View File

@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2016 Push.Rocks
Copyright (c) 2014 Maurice Butler
Copyright (c) 2016 Lossless GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

22
npmextra.json Normal file
View File

@ -0,0 +1,22 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"npmdocker": {
"baseImage": "hosttoday/ht-docker-node:npmci",
"command": "npmci node install stable && npmci npm install && npmci npm test",
"dockerSock": false
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartstring",
"description": "handle strings in smart ways. TypeScript ready.",
"npmPackagename": "@pushrocks/smartstring",
"license": "MIT"
}
}
}

19036
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,14 @@
{
"name": "smartstring",
"version": "2.0.20",
"name": "@pushrocks/smartstring",
"version": "3.0.26",
"private": false,
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)"
},
"repository": {
"type": "git",
@ -22,14 +25,39 @@
},
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": {
"@types/should": "^8.1.30",
"beautylog": "^6.0.0",
"npmts-g": "^5.2.8",
"should": "^11.1.1",
"typings-test": "^1.0.3"
"@gitzone/tsbuild": "^2.1.59",
"@gitzone/tsrun": "^1.2.31",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^5.0.2",
"@types/node": "^17.0.21",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"js-base64": "^2.1.9",
"typings-global": "^1.0.14"
}
"@pushrocks/isounique": "^1.0.5",
"@pushrocks/smartenv": "^5.0.0",
"@types/randomatic": "^3.1.3",
"buffer": "^6.0.3",
"crypto-random-string": "^4.0.0",
"js-base64": "^3.7.2",
"normalize-newline": "^4.1.0",
"randomatic": "^3.1.1",
"strip-indent": "^4.0.0",
"url": "^0.11.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

77
readme.md Normal file
View File

@ -0,0 +1,77 @@
# @pushrocks/smartstring
handle strings in smart ways. TypeScript ready.
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstring)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstring)
* [github.com (source mirror)](https://github.com/pushrocks/smartstring)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstring/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartstring/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartstring/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartstring)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartstring)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartstring)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartstring)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartstring)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class instellisense.
```javascript
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"
myGitRepo.user; // "someorg"
myGitRepo.repo; // "somerepo"
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.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('somestringanotherstring', 4); // indents a string by 4
smartstring.indent.indent('somestringanotherstring', '>>>> '); // indents a string with a prefix
smartstring.indent.normalize(' somestring anotherstring', '>>>> '); // looks for the least amount of indention and removes superflouous space
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

16
test/test.base64.both.ts Normal file
View File

@ -0,0 +1,16 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Base64
let testBase64: smartstring.Base64;
tap.test('expect create a valid instance of Base64', async () => {
testBase64 = new smartstring.Base64('somestring', 'string');
expect(testBase64).toBeInstanceOf(smartstring.Base64);
});
tap.test('expect read output a file as base64 and base64uri', async () => {
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
});
tap.start();

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

12
test/test.docker.both.ts Normal file
View File

@ -0,0 +1,12 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Docker
tap.test('expect create a Env Object', async () => {
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com'];
let envObject: any = smartstring.docker.makeEnvObject(envStringArray);
expect(envObject.VIRTUAL_HOST).toEqual('sub.domain.tld');
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
});
tap.start();

37
test/test.domain.both.ts Normal file
View File

@ -0,0 +1,37 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Domain
let testDomain: smartstring.Domain;
let testDomain2: smartstring.Domain;
tap.test('expect create a new Domain object', async () => {
testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
expect(testDomain).toBeInstanceOf(smartstring.Domain);
console.log(testDomain);
});
tap.test('expect have a .topLevel', async () => {
expect(testDomain.topLevel).toEqual('level1D');
});
tap.test('expect have a .level2', async () => {
expect(testDomain.level2).toEqual('level2D');
});
tap.test('expect have a .level3', async () => {
expect(testDomain.level3).toEqual('level3D');
});
tap.test('expect have the correct dns zone name', async () => {
expect(testDomain.zoneName).toEqual('level2D.level1D');
});
tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).toEqual('https');
});
tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2);
});
tap.start();

26
test/test.git.both.ts Normal file
View File

@ -0,0 +1,26 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// git
let testGit: smartstring.GitRepo;
tap.test('expect create a new Git class GitRepo', async () => {
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git');
expect(testGit).toBeInstanceOf(smartstring.GitRepo);
});
tap.test('expect return a .host', async () => {
expect(testGit.host).toEqual('github.com');
});
tap.test('expect return a .user', async () => {
expect(testGit.user).toEqual('pushrocks');
});
tap.test('expect return a .repo', async () => {
expect(testGit.repo).toEqual('smartstring');
});
tap.test('expect return a .httpsUrl', async () => {
expect(testGit.httpsUrl).toEqual('https://github.com/pushrocks/smartstring.git');
});
tap.test('expect return a .sshUrl', async () => {
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
});
tap.start();

28
test/test.indent.both.ts Normal file
View File

@ -0,0 +1,28 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// indent
let testString = `
base
expect be indented
some more
base
indented
`;
// normalize
tap.test('expect normalize a string', async () => {
testString = smartstring.indent.normalize(testString);
console.log(testString);
let zoneNameArg = 'test1';
let destinationIpArg = '111';
});
// indent with prefix
tap.test('expect indent', async () => {
testString = smartstring.indent.indentWithPrefix(testString, '>> ');
console.log(testString);
});
tap.start();

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,QAAQ,EAAC;QACd,IAAI,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAClF,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2BAA2B,EAAC;YAC3B,OAAO,CAAC,QAAQ;iBACX,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,yBAAyB,EAAC;YACzB,OAAO,CAAC,MAAM;iBACT,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,SAAS,EAAC;QACf,QAAQ,CAAC,gBAAgB,EAAC;YACtB,EAAE,CAAC,4BAA4B,EAAC;gBAC5B,IAAI,cAAc,GAAG,CAAC,6BAA6B,EAAC,8BAA8B,CAAC,CAAC;gBACpF,IAAI,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;gBACjE,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBACtD,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,19 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should normalize a string', async () => {
const testString = `
myawesome string;
is indented with two spaces
`;
const normalizedString = smartstring.normalize.standard(testString);
expect(normalizedString).toEqual(
`
myawesome string;
is indented with two spaces
`
);
});
tap.start();

View File

@ -1,115 +0,0 @@
import 'typings-test'
import * as smartstring from '../dist/index'
import * as should from 'should'
describe('smartstring',function(){
describe('.Base64 class', function(){
let testBase64: smartstring.Base64
it('should create a valid instance of Base64', function(){
testBase64 = new smartstring.Base64('somestring', 'string')
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_2.simpleString).equal(testBase64.simpleString)
})
})
describe('.Domain class',function(){
let testDomain:smartstring.Domain
let testDomain2:smartstring.Domain
it('should create a new Domain object',function(){
testDomain = new smartstring.Domain('https://level3D.level2D.level1D')
should(testDomain).be.instanceof(smartstring.Domain)
console.log(testDomain)
})
it('should have a .topLevel',function(){
should(testDomain.topLevel).equal('level1D')
})
it('should have a .level2',function(){
should(testDomain.level2).equal('level2D')
})
it('should have a .level3',function(){
should(testDomain.level3).equal('level3D')
})
it('should have the correct dns zone name',function(){
should(testDomain.zoneName).equal('level2D.level1D')
})
it ('should have the correct protocol',function(){
should(testDomain.protocol).equal('https')
})
it('testDomain2 should be a basic domain',function(){
testDomain2 = new smartstring.Domain('bleu.de')
console.log(testDomain2)
})
})
describe('.Git class',function(){
let testGit:smartstring.GitRepo
it('should create a new Git class GitRepo',function(){
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git')
should(testGit).be.instanceof(smartstring.GitRepo)
})
it('should return a .host',function(){
should(testGit.host).equal('github.com')
})
it('should return a .user',function(){
should(testGit.user).equal('pushrocks')
})
it('should return a .repo',function(){
should(testGit.repo).equal('smartstring')
})
it('should return a .httpsUrl',function(){
should(testGit.httpsUrl).equal('https://github.com/pushrocks/smartstring.git')
})
it('should return a .sshUrl',function(){
should(testGit.sshUrl).equal('git@github.com:pushrocks/smartstring.git')
})
})
describe('.docker',function(){
describe('.makeEnvObject',function(){
it('should create a Env Object',function(){
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld','DEFAULT_HOST=some.domain.com']
let envObject:any = smartstring.docker.makeEnvObject(envStringArray)
envObject.VIRTUAL_HOST.should.equal('sub.domain.tld')
envObject.DEFAULT_HOST.should.equal('some.domain.com')
})
})
})
describe('.indent',function(){
let testString = `
base
should be indented
some more
base
indented
`
describe('.normalize()',function(){
it('should normalize a string',function(){
testString = smartstring.indent.normalize(testString)
console.log(testString)
let zoneNameArg = 'test1'
let destinationIpArg = '111'
})
})
describe('.indentWithPrefix',function(){
it('should indent',function(){
testString = smartstring.indent.indentWithPrefix(testString,'>> ')
console.log(testString)
})
})
})
describe('.typescript',function(){
describe('.referenceRegex',function(){
it('should match reference paths',function(){
smartstring.typescript.regexReferencePath.test('/// <reference path=\"\" />')
.should.be.true()
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
.should.be.true()
smartstring.typescript.regexReferencePath.test('/// <referencepath=\"\" />')
.should.be.false()
})
})
})
})

14
test/test.type.both.ts Normal file
View File

@ -0,0 +1,14 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should state valuid utf8', async () => {
expect(smartstring.type.isUtf8('hithere')).toBeTrue();
});
tap.test('should state wether base64 string is valid', async () => {
const base64String = smartstring.base64.encode('hi there');
expect(smartstring.type.isBase64(base64String)).toBeTrue();
expect(smartstring.type.isBase64('hi there')).toBeFalse();
});
tap.start();

View File

@ -1,13 +1,11 @@
import * as docker from './smartstring.docker'
import * as indent from './smartstring.indent'
import * as typescript from './smartstring.typescript'
import * as create from './smartstring.create.js';
import * as docker from './smartstring.docker.js';
import * as indent from './smartstring.indent.js';
import * as normalize from './smartstring.normalize.js';
import * as type from './smartstring.type.js';
export {
docker,
typescript,
indent
}
export { create, docker, normalize, indent, type };
export { Base64, base64 } from './smartstring.base64'
export { Domain } from './smartstring.domain'
export { GitRepo } from './smartstring.git'
export { Base64, base64 } from './smartstring.base64.js';
export { Domain } from './smartstring.domain.js';
export { GitRepo } from './smartstring.git.js';

View File

@ -1,69 +1,69 @@
import * as plugins from './smartstring.plugins'
import * as plugins from './smartstring.plugins.js';
/**
* the type for base 64
*/
export type TBase64Input = 'string' | 'base64' | 'base64uri'
export type TBase64Input = 'string' | 'base64' | 'base64uri';
/**
* handle base64 strings
*/
export class Base64 {
private refString: string
constructor(inputStringArg, typeArg: TBase64Input) {
switch (typeArg) {
case 'string': // easiest case
this.refString = inputStringArg
break
case 'base64':
this.refString = base64.decode(inputStringArg)
break
case 'base64uri':
this.refString = base64.decode(inputStringArg)
}
private refString: string;
constructor(inputStringArg, typeArg: TBase64Input) {
switch (typeArg) {
case 'string': // easiest case
this.refString = inputStringArg;
break;
case 'base64':
this.refString = base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return base64.encode(this.refString)
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64StringUri() {
return base64.encodeUri(this.refString)
}
/**
* the base64uri encoded version of the original string
*/
get base64UriString() {
return base64.encodeUri(this.refString);
}
}
export let base64 = {
/**
* encodes the string
*/
encode: (stringArg: string) => {
return plugins.jsBase64.encode(stringArg)
},
/**
* 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)
},
/**
* 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)
}
}
/**
* decodes a base64 encoded string
*/
decode: (stringArg: string) => {
return plugins.jsBase64.decode(stringArg);
},
};

29
ts/smartstring.create.ts Normal file
View File

@ -0,0 +1,29 @@
import * as plugins from './smartstring.plugins.js';
/**
* creates a random string
*
* ```ts
* createRandomString('AAAA')
* //=> 'AGHR'
* ```
*
* @param patternArg the pattern argument to use, Aa0!* are viable pattern descritors
* @param lengthArg the length of the random string
* @param optionsArg options
*/
export const createRandomString = (
patternArg: string,
lengthArg?: number,
optionsArg?: any
): string => {
return plugins.randomatic(patternArg, lengthArg, optionsArg);
};
/**
* creates a crytic string in the speicifed length
* @param lengthArg the length of the crypto string
*/
export const createCryptoRandomString = (): string => {
return plugins.isounique.uni();
};

View File

@ -1,18 +1,18 @@
import * as plugins from './smartstring.plugins'
import * as plugins from './smartstring.plugins.js';
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
export let makeEnvObject = function (envArrayArg: string[]) {
let returnObject = {}
let regexString = /(.*)=(.*)/
if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[envKey])
returnObject[regexMatches[1]] = regexMatches[2]
};
export const makeEnvObject = function (envArrayArg: string[]) {
let returnObject = {};
let regexString = /(.*)=(.*)/;
if (typeof envArrayArg !== 'undefined') {
for (let envKey in envArrayArg) {
let regexMatches = regexString.exec(envArrayArg[envKey]);
returnObject[regexMatches[1]] = regexMatches[2];
}
return returnObject
}
}
return returnObject;
};

View File

@ -1,62 +1,87 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
export class Domain {
fullName: string
level1: string
level2: string
level3: string
level4: string
level5: string
protocol: string
zoneName: string
public fullName: string;
public level1: string;
public level2: string;
public level3: string;
public level4: string;
public level5: string;
public protocol: string;
public zoneName: string;
// aliases
public topLevel: string;
public domainName;
public subDomain;
public port;
public nodeParsedUrl: plugins.url.UrlWithStringQuery;
constructor(domainStringArg: string) {
// lets do the node standard stuff first
this.protocol = this._protocolRegex(domainStringArg);
if (!this.protocol) {
domainStringArg = `https://${domainStringArg}`;
}
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
// lets do the rest after
const regexMatches = this._domainRegex(
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
);
this.fullName = '';
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
const localMatch = regexMatches[i - 1];
this['level' + i.toString()] = localMatch;
if (this.fullName === '') {
this.fullName = localMatch;
} else {
this.fullName = localMatch + '.' + this.fullName;
}
} else {
this['level' + i.toString()] = undefined;
}
}
this.zoneName = this.level2 + '.' + this.level1;
// aliases
topLevel: string
domainName
subDomain
constructor(domainStringArg:string){
let regexMatches = domainRegex(domainStringArg);
this.fullName = ''
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
let localMatch = regexMatches[i - 1]
this['level' + i.toString()] = localMatch
if (this.fullName === ''){
this.fullName = localMatch
} else {
this.fullName = localMatch + '.' + this.fullName
}
} else {
this['level' + i.toString()] = undefined
};
};
this.protocol = protocolRegex(domainStringArg)
this.zoneName = this.level2 + '.' + this.level1
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
// aliases
this.topLevel = this.level1
this.domainName = this.level2
this.subDomain = this.level3
}
}
// helper functions
let domainRegex = function(stringArg:string){
let regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/
let regexMatches = regexString.exec(stringArg)
regexMatches.reverse() //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop() // pop the last element, which is, since we reversed the Array, the full String of matched elements
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg !== '')
/** */
private _domainRegex(stringArg: string) {
const regexString =
/([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
const regexMatches = regexString.exec(stringArg);
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
const regexMatchesFiltered = regexMatches.filter(function (stringArg: string) {
return stringArg !== '';
});
return regexMatchesFiltered
};
return regexMatchesFiltered;
}
let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//
let regexMatches = regexString.exec(stringArg)
if(regexMatches) {
return regexMatches[1]
private _protocolRegex(stringArg: string) {
const regexString = /^([a-zA-Z0-9]*):\/\//;
const regexMatches = regexString.exec(stringArg);
if (regexMatches) {
return regexMatches[1];
} else {
return undefined
return undefined;
}
}
private _portRegex(stringArg: string) {
const regexString = /^([a-zA-Z0-9]*):\/\//;
const regexMatches = regexString.exec(stringArg);
if (regexMatches) {
return regexMatches[1];
} else {
return undefined;
}
}
}

View File

@ -1,52 +1,57 @@
import * as plugins from './smartstring.plugins'
import * as plugins from './smartstring.plugins.js';
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
export class GitRepo {
host: string
user: string
repo: string
accessToken: string
sshUrl: string
httpsUrl: string
constructor(stringArg: string,tokenArg?: string) {
let regexMatches = gitRegex(stringArg)
this.host = regexMatches[1]
this.user = regexMatches[2]
this.repo = regexMatches[3]
this.accessToken = tokenArg
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'ssh')
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, 'https')
}
host: string;
user: string;
repo: string;
accessToken: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string) {
let regexMatches = gitRegex(stringArg);
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
}
}
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
let gitRegex = function(stringArg:string){
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-]*)(?:\/)([a-zA-Z0-9\-]*)(?:\.git)/
let regexMatches = regexString.exec(stringArg)
return regexMatches
}
const gitRegex = function (stringArg: string) {
const regexString =
/([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
};
let gitLink = function(hostArg: string, userArg: string, repoArg: string, tokenArg: string = '', linkTypeArg): string{
let returnString
if (tokenArg !== '') {
tokenArg = tokenArg + '@'
}
switch (linkTypeArg) {
case 'https':
returnString = 'https://' +
tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git'
break
case 'ssh':
returnString = 'git@' +
hostArg + ':' + userArg + '/' + repoArg + '.git';
break
default:
console.error('Link Type ' + linkTypeArg + ' not known')
break
}
return returnString
}
const gitLink = function (
hostArg: string,
userArg: string,
repoArg: string,
tokenArg: string = '',
linkTypeArg
): string {
let returnString;
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case 'https':
returnString = 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
break;
case 'ssh':
returnString = 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
break;
default:
console.error('Link Type ' + linkTypeArg + ' not known');
break;
}
return returnString;
};

View File

@ -1,64 +1,92 @@
import * as plugins from './smartstring.plugins'
import * as plugins from './smartstring.plugins.js';
let splitString = (stringArg: string): string[] => {
let resultArray = stringArg.split('\n')
return cleanStringArray(resultArray)
/**
* splits a string into an array
* @param stringArg
*/
const splitStringAtLineBreak = (stringArg: string): string[] => {
let resultArray = stringArg.split('\n');
return cleanStringArray(resultArray);
};
let joinString = (stringArrayArg: string[]): string => {
let resultString: string = ''
for (let line of stringArrayArg){
resultString = resultString + line + '\n'
/**
* joins a string together again
* @param stringArrayArg
*/
const joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
let resultString: string = '';
for (let line of stringArrayArg) {
resultString = resultString + line + '\n'; // add new line at end
}
return resultString;
};
/**
* cleans first and last line in case they are empty
* @param stringArrayArg
*/
const cleanStringArray = (stringArrayArg: string[]): string[] => {
let testRegex = /^[\s]*$/;
if (testRegex.test(stringArrayArg[0])) {
stringArrayArg.shift();
}
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
stringArrayArg.pop();
}
return stringArrayArg;
};
/**
* indent an array
* @param stringArg
* @param spaceAmount
*/
export const indent = (stringArg: string, spaceAmount: number): string => {
let localStringArray = splitStringAtLineBreak(stringArg);
for (let stringArg of localStringArray) {
stringArg = ' '.repeat(spaceAmount) + stringArg;
}
let resultString = joinStringWithLineBreaks(localStringArray);
return resultString;
};
/**
* indents a string with prefix
* @param stringArg
* @param prefixArg
*/
export const indentWithPrefix = (stringArg: string, prefixArg: string): string => {
let resultString: string;
let stringArray = splitStringAtLineBreak(stringArg);
let resultArray: string[] = [];
for (let stringItem of stringArray) {
resultArray.push(prefixArg + stringItem);
}
resultString = joinStringWithLineBreaks(resultArray);
return resultString;
};
export const normalize = (stringArg: string): string => {
let resultString: string;
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
let minCommonLeftOffset: number;
const deIndentRegex = /^(\s*)/;
const emptyLineRegex = /^(\s*)$/;
for (let stringItem of splitStringArray) {
let offsetString = deIndentRegex.exec(stringItem)[1];
if (
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset) &&
!emptyLineRegex.test(stringItem)
) {
minCommonLeftOffset = offsetString.length;
}
return resultString
}
let cleanStringArray = (stringArrayArg: string[]): string[] => {
let testRegex = /^[\s]*$/
if (testRegex.test(stringArrayArg[0])) {
stringArrayArg.shift()
}
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
stringArrayArg.pop()
};
return stringArrayArg
}
export let indent = (stringArg: string, spaceAmount: number): string => {
let resultString: string
return resultString
}
export let indentWithPrefix = (stringArg: string,prefixArg: string): string => {
let resultString: string
let stringArray = splitString(stringArg)
let resultArray: string[] = []
for (let stringItem of stringArray){
resultArray.push(prefixArg + stringItem)
};
resultString = joinString(resultArray)
return resultString
}
export let normalize = (stringArg: string): string => {
let resultString: string
let splitStringArray: string[] = splitString(stringArg)
let minCommonLeftOffset: number
let deIndentRegex = /^(\s*)/
let emptyLineRegex = /^(\s*)$/
for (let stringItem of splitStringArray){
let offsetString = deIndentRegex.exec(stringItem)[1]
if (
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset)
&& !emptyLineRegex.test(stringItem)
) {
minCommonLeftOffset = offsetString.length
}
};
let resultSplitStringArray = []
for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset))
};
resultString = joinString(resultSplitStringArray)
return resultString
}
}
let resultSplitStringArray = [];
for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
}
resultString = joinStringWithLineBreaks(resultSplitStringArray);
return resultString;
};

View File

@ -0,0 +1,22 @@
import * as plugins from './smartstring.plugins.js';
/**
* replaces all occurences of something in a string
* @param stringArg
* @param searchPattern
* @param replacementString
*/
export const replaceAll = (stringArg: string, searchPattern: string, replacementString: string) => {
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
};
/**
* normalizes a string
* @param stringArg
*/
export const standard = (stringArg: string): string => {
let fix1 = plugins.stripIndent(stringArg); // fix indention
let fix2 = plugins.normalizeNewline(fix1); // fix newlines
let fix3 = replaceAll(fix2, '\t/', ' '); // fix tabs
return fix3;
};

View File

@ -1,2 +1,22 @@
import 'typings-global'
export let jsBase64 = require('js-base64').Base64
// node native
import * as smartenv from '@pushrocks/smartenv';
const smartenvInstance = new smartenv.Smartenv();
import * as isounique from '@pushrocks/isounique';
export { isounique };
import { Buffer } from 'buffer';
if (smartenvInstance.isBrowser) {
globalThis.Buffer = Buffer;
}
import * as url from 'url';
export { url };
// third party
import { Base64 as jsBase64 } from 'js-base64';
import stripIndent from 'strip-indent';
import normalizeNewline from 'normalize-newline';
import randomatic from 'randomatic';
export { jsBase64, stripIndent, normalizeNewline, randomatic };

99
ts/smartstring.type.ts Normal file
View File

@ -0,0 +1,99 @@
import * as plugins from './smartstring.plugins.js';
import * as base64 from './smartstring.base64.js';
export const isUtf8 = (stringArg: string) => {
const bytes = Buffer.from(stringArg);
let i = 0;
while (i < bytes.length) {
if (
// ASCII
bytes[i] === 0x09 ||
bytes[i] === 0x0a ||
bytes[i] === 0x0d ||
(0x20 <= bytes[i] && bytes[i] <= 0x7e)
) {
i += 1;
continue;
}
if (
// non-overlong 2-byte
0xc2 <= bytes[i] &&
bytes[i] <= 0xdf &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf
) {
i += 2;
continue;
}
if (
// excluding overlongs
(bytes[i] === 0xe0 &&
0xa0 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf) || // straight 3-byte
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf) || // excluding surrogates
(bytes[i] === 0xed &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0x9f &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf)
) {
i += 3;
continue;
}
if (
// planes 1-3
(bytes[i] === 0xf0 &&
0x90 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf) || // planes 4-15
(0xf1 <= bytes[i] &&
bytes[i] <= 0xf3 &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf) || // plane 16
(bytes[i] === 0xf4 &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0x8f &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf)
) {
i += 4;
continue;
}
return false;
}
return true;
};
export const isBase64 = (stringArg: string) => {
const notBase64 = /[^A-Z0-9+\/=]/i;
const len = stringArg.length;
if (!len || len % 4 !== 0 || notBase64.test(stringArg)) {
return false;
}
const firstPaddingChar = stringArg.indexOf('=');
return (
firstPaddingChar === -1 ||
firstPaddingChar === len - 1 ||
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=')
);
};

View File

@ -1,3 +0,0 @@
import * as plugins from './smartstring.plugins'
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/

7
tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}