@waiting/shared-core
Advanced tools
Comparing version 1.9.0 to 1.9.1
@@ -5,2 +5,6 @@ # Changelog | ||
### [1.9.1](https://github.com/waitingsong/node-shared-core/compare/v1.9.0...v1.9.1) (2019-05-22) | ||
## [1.9.0](https://github.com/waitingsong/node-shared-core/compare/v1.8.0...v1.9.0) (2019-05-21) | ||
@@ -7,0 +11,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.9.0 | ||
* @version 1.9.1 | ||
* @author waiting | ||
@@ -238,3 +238,3 @@ * @license MIT | ||
function ab2str(ab, encoding = 'utf8') { | ||
const decoder = new TextDecoder(encoding); | ||
const decoder = new util.TextDecoder(encoding); | ||
const view = new Uint8Array(ab); | ||
@@ -256,3 +256,3 @@ | ||
function str2Uint8Array(input) { | ||
const encoder = new TextEncoder(); | ||
const encoder = new util.TextEncoder(); | ||
const view = encoder.encode(input); | ||
@@ -259,0 +259,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.9.0 | ||
* @version 1.9.1 | ||
* @author waiting | ||
@@ -17,3 +17,3 @@ * @license MIT | ||
import { map, mergeMap, scan, concatMap, last, mapTo, defaultIfEmpty, tap, share, filter, take } from 'rxjs/operators'; | ||
import { promisify } from 'util'; | ||
import { promisify, TextDecoder, TextEncoder } from 'util'; | ||
export { promisify } from 'util'; | ||
@@ -20,0 +20,0 @@ export { tmpdir } from 'os'; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.9.0 | ||
* @version 1.9.1 | ||
* @author waiting | ||
@@ -12,3 +12,3 @@ * @license MIT | ||
import{throwError as t,defer as e,of as n,from as r,combineLatest as o,forkJoin as i}from"rxjs";import{close as s,chmod as a,copyFile as c,mkdir as f,open as p,readFile as u,readdir as l,rmdir as w,stat as m,unlink as h,write as d,writeFile as v,access as x}from"fs";import{normalize as y,sep as E,resolve as M,dirname as g,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as T,mergeMap as b,scan as P,concatMap as D,last as j,mapTo as A,defaultIfEmpty as O,tap as $,share as F,filter as R,take as S}from"rxjs/operators";import{promisify as U}from"util";export{promisify}from"util";export{tmpdir}from"os";function B(t){throw new Error("Assert Never Unexpected object: "+t)}function N(e){return t(new Error("Assert Never Unexpected object: "+e))}const C=U(s),G=U(a),H=U(c),_=U(f),k=U(p),L=U(u),z=U(l),J=U(w),q=U(m),K=U(h),Q=U(d),V=U(v);function W(t){return e(()=>X(t)).pipe(T(e=>e?y(t):""))}function X(t){return t?new Promise(e=>x(t,t=>e(!t))):Promise.resolve(!1)}function Y(t){if(!t)return n("");const r=y(t);return e(()=>Z(r)).pipe(T(t=>t?r:""))}function Z(t){return t?nt(t,"DIR"):Promise.resolve(!1)}function tt(t){const n=y(t);return e(()=>et(n)).pipe(T(t=>t?n:""))}function et(t){return t?nt(t,"FILE"):Promise.resolve(!1)}function nt(t,e){return t?X(t).then(n=>!!n&&q(t).then(t=>"DIR"===e?t.isDirectory():t.isFile())):Promise.resolve(!1)}function rt(t){if(!t)throw new Error("value of path param invalid");const e=n(y(t)),o=e.pipe(b(t=>r(t.split(E))),P((t,e)=>M(t,e),E)),i=o.pipe(D(ot),j()),s=e.pipe(b(Y),b(t=>t?n(t):i));return s}function ot(t,r){return W(t).pipe(b(r=>r?n(r):e(()=>_(t,493)).pipe(A(t))))}async function it(t){if(t){const e=y(t);return await Z(e)||await e.split(E).reduce(async(t,e)=>{const n=M(await t,e);return await X(n)||await _(n,493),n},Promise.resolve(E)),e}throw new Error("value of path param invalid")}async function st(t,e,n){const r=g(t);if(!r)throw new Error("folder empty");await Z(r)||await it(r);const o=y(t);if(!await et(o)){const t=n||{mode:416};Buffer.isBuffer(e)?await V(o,e,t):"object"==typeof e?await V(o,JSON.stringify(e)):await V(o,e,t)}return o}async function at(t){t&&(await ct(t),await Z(t)&&await J(t))}async function ct(t){if(t&&await X(t)){if(await et(t))return void await K(t);const e=await z(t);if(e.length)for(const n of e)await ct(I(t,n));else await J(t)}}async function ft(t){if(!t)throw new Error("File path empth ");if(t.includes("/")&&!await X(t))throw new Error("File not exists: "+t)}function pt(t){return Buffer.from(t)}function ut(t){return Uint8Array.from(t).buffer}function lt(t,e="utf8"){const n=new TextDecoder(e),r=new Uint8Array(t);return n.decode(r)}function wt(t){const e=mt(t);return e.buffer}function mt(t){const e=new TextEncoder,n=e.encode(t);return n}function ht(t){return Math.floor(Math.random()*Math.floor(t))}const dt="win32"===process.platform,vt=y(dt?process.env.USERPROFILE||"":`${process.env.HOME}`);function xt(t){t&&"string"==typeof t&&process&&process.env&&(process.env.PATH=`${process.env.PATH};${t}`)}async function yt(t,e){const n=[];for(const r of e){const e=I(t,r.replace(/\.{2,}/,"/"));if(!await X(e))continue;const o=await z(e);for(const t of o){if(!Et(t))continue;const o=I(e,t),i=Mt(t),s=I(e,i);await X(s)||(await H(o,s),n.push(`${r}/${i}`))}}return n}function Et(t){if(!t)return!1;if(".example"===t)return!1;const e=t.split(".");return e.length>1&&"example"===e[e.length-1]}function Mt(t){const e=t.split(".");return e.length>1&&"example"===e[e.length-1]?e.slice(0,e.length-1).join("."):t}function gt(t){const{baseDir:e,COMMIT_EDITMSG:s,branchName:a,protectBranch:c,skipMsg:f}=t,p=I(e,s);if(!s)return console.info("COMMIT_EDITMSG value blank"),n(1);const u=r(c).pipe(O()),l=r(f).pipe(O()),w=W(p).pipe($(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${p}"`),process.exit(1))}),b(t=>L(t,{encoding:"utf8"})),T(t=>{const e=t.split(/\n|\r\n/)[0];return{head:e,msg:t}}),F()),m=o(n(a),u).pipe(T(([t,e])=>!(!e||!e.test(t))),R(t=>t),A(0),O(1)),h=o(w,l).pipe(T(([{head:t},e])=>!(!e||!e.test(t))),R(t=>t),A(1),O(0)),d=i(m,h).pipe(T(([t,e])=>t&e),O(0),S(1));return d}export{pt as ab2buf,lt as ab2str,B as assertNever,N as assertNeverRx,ut as buf2ab,G as chmodAsync,C as closeAsync,H as copyFileAsync,rt as createDir,it as createDirAsync,st as createFileAsync,Y as dirExists,tt as fileExists,yt as genFileFromExample,ht as genRandomInt,Z as isDirExists,nt as isDirFileExists,et as isFileExists,X as isPathAccessible,gt as isSkipCommitlint,dt as isWin32,_ as mkdirAsync,k as openAsync,W as pathAccessible,z as readDirAsync,L as readFileAsync,at as rimraf,J as rmdirAsync,xt as setPathDirectory,q as statAsync,mt as str2Uint8Array,wt as str2ab,K as unlinkAsync,vt as userHome,ft as validateDllFile,Q as writeAsync,V as writeFileAsync}; | ||
import{throwError as t,defer as n,of as e,from as r,combineLatest as o,forkJoin as i}from"rxjs";import{close as s,chmod as a,copyFile as c,mkdir as f,open as p,readFile as u,readdir as l,rmdir as w,stat as m,unlink as h,write as v,writeFile as d,access as y}from"fs";import{normalize as x,sep as E,resolve as M,dirname as g,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as b,mergeMap as P,scan as T,concatMap as j,last as D,mapTo as A,defaultIfEmpty as O,tap as $,share as F,filter as R,take as S}from"rxjs/operators";import{promisify as U,TextDecoder as B,TextEncoder as N}from"util";export{promisify}from"util";export{tmpdir}from"os";function C(t){throw new Error("Assert Never Unexpected object: "+t)}function G(n){return t(new Error("Assert Never Unexpected object: "+n))}const H=U(s),_=U(a),k=U(c),L=U(f),z=U(p),J=U(u),q=U(l),K=U(w),Q=U(m),V=U(h),W=U(v),X=U(d);function Y(t){return n(()=>Z(t)).pipe(b(n=>n?x(t):""))}function Z(t){return t?new Promise(n=>y(t,t=>n(!t))):Promise.resolve(!1)}function tt(t){if(!t)return e("");const r=x(t);return n(()=>nt(r)).pipe(b(t=>t?r:""))}function nt(t){return t?ot(t,"DIR"):Promise.resolve(!1)}function et(t){const e=x(t);return n(()=>rt(e)).pipe(b(t=>t?e:""))}function rt(t){return t?ot(t,"FILE"):Promise.resolve(!1)}function ot(t,n){return t?Z(t).then(e=>!!e&&Q(t).then(t=>"DIR"===n?t.isDirectory():t.isFile())):Promise.resolve(!1)}function it(t){if(!t)throw new Error("value of path param invalid");const n=e(x(t)),o=n.pipe(P(t=>r(t.split(E))),T((t,n)=>M(t,n),E)),i=o.pipe(j(st),D()),s=n.pipe(P(tt),P(t=>t?e(t):i));return s}function st(t,r){return Y(t).pipe(P(r=>r?e(r):n(()=>L(t,493)).pipe(A(t))))}async function at(t){if(t){const n=x(t);return await nt(n)||await n.split(E).reduce(async(t,n)=>{const e=M(await t,n);return await Z(e)||await L(e,493),e},Promise.resolve(E)),n}throw new Error("value of path param invalid")}async function ct(t,n,e){const r=g(t);if(!r)throw new Error("folder empty");await nt(r)||await at(r);const o=x(t);if(!await rt(o)){const t=e||{mode:416};Buffer.isBuffer(n)?await X(o,n,t):"object"==typeof n?await X(o,JSON.stringify(n)):await X(o,n,t)}return o}async function ft(t){t&&(await pt(t),await nt(t)&&await K(t))}async function pt(t){if(t&&await Z(t)){if(await rt(t))return void await V(t);const n=await q(t);if(n.length)for(const e of n)await pt(I(t,e));else await K(t)}}async function ut(t){if(!t)throw new Error("File path empth ");if(t.includes("/")&&!await Z(t))throw new Error("File not exists: "+t)}function lt(t){return Buffer.from(t)}function wt(t){return Uint8Array.from(t).buffer}function mt(t,n="utf8"){const e=new B(n),r=new Uint8Array(t);return e.decode(r)}function ht(t){const n=vt(t);return n.buffer}function vt(t){const n=new N,e=n.encode(t);return e}function dt(t){return Math.floor(Math.random()*Math.floor(t))}const yt="win32"===process.platform,xt=x(yt?process.env.USERPROFILE||"":`${process.env.HOME}`);function Et(t){t&&"string"==typeof t&&process&&process.env&&(process.env.PATH=`${process.env.PATH};${t}`)}async function Mt(t,n){const e=[];for(const r of n){const n=I(t,r.replace(/\.{2,}/,"/"));if(!await Z(n))continue;const o=await q(n);for(const t of o){if(!gt(t))continue;const o=I(n,t),i=It(t),s=I(n,i);await Z(s)||(await k(o,s),e.push(`${r}/${i}`))}}return e}function gt(t){if(!t)return!1;if(".example"===t)return!1;const n=t.split(".");return n.length>1&&"example"===n[n.length-1]}function It(t){const n=t.split(".");return n.length>1&&"example"===n[n.length-1]?n.slice(0,n.length-1).join("."):t}function bt(t){const{baseDir:n,COMMIT_EDITMSG:s,branchName:a,protectBranch:c,skipMsg:f}=t,p=I(n,s);if(!s)return console.info("COMMIT_EDITMSG value blank"),e(1);const u=r(c).pipe(O()),l=r(f).pipe(O()),w=Y(p).pipe($(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${p}"`),process.exit(1))}),P(t=>J(t,{encoding:"utf8"})),b(t=>{const n=t.split(/\n|\r\n/)[0];return{head:n,msg:t}}),F()),m=o(e(a),u).pipe(b(([t,n])=>!(!n||!n.test(t))),R(t=>t),A(0),O(1)),h=o(w,l).pipe(b(([{head:t},n])=>!(!n||!n.test(t))),R(t=>t),A(1),O(0)),v=i(m,h).pipe(b(([t,n])=>t&n),O(0),S(1));return v}export{lt as ab2buf,mt as ab2str,C as assertNever,G as assertNeverRx,wt as buf2ab,_ as chmodAsync,H as closeAsync,k as copyFileAsync,it as createDir,at as createDirAsync,ct as createFileAsync,tt as dirExists,et as fileExists,Mt as genFileFromExample,dt as genRandomInt,nt as isDirExists,ot as isDirFileExists,rt as isFileExists,Z as isPathAccessible,bt as isSkipCommitlint,yt as isWin32,L as mkdirAsync,z as openAsync,Y as pathAccessible,q as readDirAsync,J as readFileAsync,ft as rimraf,K as rmdirAsync,Et as setPathDirectory,Q as statAsync,vt as str2Uint8Array,ht as str2ab,V as unlinkAsync,xt as userHome,ut as validateDllFile,W as writeAsync,X as writeFileAsync}; | ||
//# sourceMappingURL=index.esm.min.js.map |
@@ -87,3 +87,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare function ab2str(ab: ArrayBuffer, encoding?: 'utf8' | 'utf16'): string; | ||
export declare function ab2str(ab: ArrayBuffer, encoding?: 'utf8' | 'utf-16'): string; | ||
/** | ||
@@ -90,0 +90,0 @@ * Convert String to ArrayBuffer via TextEncoder |
@@ -5,3 +5,3 @@ import { access, chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, } from 'fs' | ||
import { concatMap, last, map, mapTo, mergeMap, scan, } from 'rxjs/operators' | ||
import { promisify } from 'util' | ||
import { promisify, TextDecoder, TextEncoder } from 'util' | ||
export const closeAsync = promisify(close) | ||
@@ -8,0 +8,0 @@ export const chmodAsync = promisify(chmod) |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73408