Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@waiting/shared-core

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waiting/shared-core - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

11

CHANGELOG.md

@@ -1,5 +0,14 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [1.8.0](https://github.com/waitingsong/node-shared-core/compare/v1.7.0...v1.8.0) (2019-05-21)
### Features
* add ab2buf(), buf2ab() ([77aa8e2](https://github.com/waitingsong/node-shared-core/commit/77aa8e2))
# [1.7.0](https://github.com/waitingsong/node-shared-core/compare/v1.6.0...v1.7.0) (2019-03-01)

@@ -6,0 +15,0 @@

103

dist/index.cjs.js

@@ -5,3 +5,3 @@ /**

*
* @version 1.7.0
* @version 1.8.0
* @author waiting

@@ -216,2 +216,14 @@ * @license MIT

}
/**
* Convert Browser ArrayBuffer to js Buffer
*/
function ab2buf(ab) {
return Buffer.from(ab)
}
/**
* Convert Node.js Buffer to js ArrayBuffer
*/
function buf2ab(buf) {
return Uint8Array.from(buf).buffer
}

@@ -323,39 +335,76 @@ /* istanbul ignore next */

exports.basename = path.basename;
exports.dirname = path.dirname;
exports.join = path.join;
exports.normalize = path.normalize;
exports.pathResolve = path.resolve;
exports.promisify = util.promisify;
exports.tmpdir = os.tmpdir;
Object.defineProperty(exports, 'basename', {
enumerable: true,
get: function () {
return path.basename;
}
});
Object.defineProperty(exports, 'dirname', {
enumerable: true,
get: function () {
return path.dirname;
}
});
Object.defineProperty(exports, 'join', {
enumerable: true,
get: function () {
return path.join;
}
});
Object.defineProperty(exports, 'normalize', {
enumerable: true,
get: function () {
return path.normalize;
}
});
Object.defineProperty(exports, 'pathResolve', {
enumerable: true,
get: function () {
return path.resolve;
}
});
Object.defineProperty(exports, 'promisify', {
enumerable: true,
get: function () {
return util.promisify;
}
});
Object.defineProperty(exports, 'tmpdir', {
enumerable: true,
get: function () {
return os.tmpdir;
}
});
exports.ab2buf = ab2buf;
exports.assertNever = assertNever;
exports.assertNeverRx = assertNeverRx;
exports.isWin32 = isWin32;
exports.userHome = userHome;
exports.buf2ab = buf2ab;
exports.chmodAsync = chmodAsync;
exports.closeAsync = closeAsync;
exports.chmodAsync = chmodAsync;
exports.copyFileAsync = copyFileAsync;
exports.createDir = createDir;
exports.createDirAsync = createDirAsync;
exports.createFileAsync = createFileAsync;
exports.dirExists = dirExists;
exports.fileExists = fileExists;
exports.genFileFromExample = genFileFromExample;
exports.isDirExists = isDirExists;
exports.isDirFileExists = isDirFileExists;
exports.isFileExists = isFileExists;
exports.isPathAccessible = isPathAccessible;
exports.isSkipCommitlint = isSkipCommitlint;
exports.isWin32 = isWin32;
exports.mkdirAsync = mkdirAsync;
exports.openAsync = openAsync;
exports.pathAccessible = pathAccessible;
exports.readDirAsync = readDirAsync;
exports.readFileAsync = readFileAsync;
exports.readDirAsync = readDirAsync;
exports.rimraf = rimraf;
exports.rmdirAsync = rmdirAsync;
exports.setPathDirectory = setPathDirectory;
exports.statAsync = statAsync;
exports.unlinkAsync = unlinkAsync;
exports.userHome = userHome;
exports.validateDllFile = validateDllFile;
exports.writeAsync = writeAsync;
exports.writeFileAsync = writeFileAsync;
exports.pathAccessible = pathAccessible;
exports.isPathAccessible = isPathAccessible;
exports.dirExists = dirExists;
exports.isDirExists = isDirExists;
exports.fileExists = fileExists;
exports.isFileExists = isFileExists;
exports.isDirFileExists = isDirFileExists;
exports.createDir = createDir;
exports.createDirAsync = createDirAsync;
exports.createFileAsync = createFileAsync;
exports.rimraf = rimraf;
exports.validateDllFile = validateDllFile;
exports.setPathDirectory = setPathDirectory;
exports.genFileFromExample = genFileFromExample;
exports.isSkipCommitlint = isSkipCommitlint;

@@ -5,3 +5,3 @@ /**

*
* @version 1.7.0
* @version 1.8.0
* @author waiting

@@ -214,2 +214,14 @@ * @license MIT

}
/**
* Convert Browser ArrayBuffer to js Buffer
*/
function ab2buf(ab) {
return Buffer.from(ab)
}
/**
* Convert Node.js Buffer to js ArrayBuffer
*/
function buf2ab(buf) {
return Uint8Array.from(buf).buffer
}

@@ -321,2 +333,2 @@ /* istanbul ignore next */

export { assertNever, assertNeverRx, isWin32, userHome, closeAsync, chmodAsync, copyFileAsync, mkdirAsync, openAsync, readFileAsync, readDirAsync, rmdirAsync, statAsync, unlinkAsync, writeAsync, writeFileAsync, pathAccessible, isPathAccessible, dirExists, isDirExists, fileExists, isFileExists, isDirFileExists, createDir, createDirAsync, createFileAsync, rimraf, validateDllFile, setPathDirectory, genFileFromExample, isSkipCommitlint };
export { ab2buf, assertNever, assertNeverRx, buf2ab, chmodAsync, closeAsync, copyFileAsync, createDir, createDirAsync, createFileAsync, dirExists, fileExists, genFileFromExample, isDirExists, isDirFileExists, isFileExists, isPathAccessible, isSkipCommitlint, isWin32, mkdirAsync, openAsync, pathAccessible, readDirAsync, readFileAsync, rimraf, rmdirAsync, setPathDirectory, statAsync, unlinkAsync, userHome, validateDllFile, writeAsync, writeFileAsync };

@@ -5,3 +5,3 @@ /**

*
* @version 1.7.0
* @version 1.8.0
* @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 p,open as f,readFile as u,readdir as l,rmdir as w,stat as m,unlink as h,write as v,writeFile as d,access as x}from"fs";import{normalize as E,sep as y,resolve as g,dirname as M,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as P,mergeMap as T,scan as b,concatMap as j,last as D,mapTo as O,defaultIfEmpty as $,tap as F,share as R,filter as S,take as A}from"rxjs/operators";import{promisify as N}from"util";export{promisify}from"util";export{tmpdir}from"os";function B(t){throw new Error("Assert Never Unexpected object: "+t)}function C(e){return t(new Error("Assert Never Unexpected object: "+e))}const G=N(s),H=N(a),U=N(c),_=N(p),k=N(f),L=N(u),z=N(l),J=N(w),q=N(m),K=N(h),Q=N(v),V=N(d);function W(t){return e(()=>X(t)).pipe(P(e=>e?E(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=E(t);return e(()=>Z(r)).pipe(P(t=>t?r:""))}function Z(t){return t?nt(t,"DIR"):Promise.resolve(!1)}function tt(t){const n=E(t);return e(()=>et(n)).pipe(P(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(E(t)),o=e.pipe(T(t=>r(t.split(y))),b((t,e)=>g(t,e),y)),i=o.pipe(j(ot),D()),s=e.pipe(T(Y),T(t=>t?n(t):i));return s}function ot(t,r){return W(t).pipe(T(r=>r?n(r):e(()=>_(t,493)).pipe(O(t))))}async function it(t){if(t){const e=E(t);return await Z(e)||await e.split(y).reduce(async(t,e)=>{const n=g(await t,e);return await X(n)||await _(n,493),n},Promise.resolve(y)),e}throw new Error("value of path param invalid")}async function st(t,e,n){const r=M(t);if(!r)throw new Error("folder empty");await Z(r)||await it(r);const o=E(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 pt(t){if(!t)throw new Error("File path empth ");if(t.includes("/")&&!await X(t))throw new Error("File not exists: "+t)}const ft="win32"===process.platform,ut=E(ft?process.env.USERPROFILE||"":`${process.env.HOME}`);function lt(t){t&&"string"==typeof t&&process&&process.env&&(process.env.PATH=`${process.env.PATH};${t}`)}async function wt(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(!mt(t))continue;const o=I(e,t),i=ht(t),s=I(e,i);await X(s)||(await U(o,s),n.push(`${r}/${i}`))}}return n}function mt(t){if(!t)return!1;if(".example"===t)return!1;const e=t.split(".");return e.length>1&&"example"===e[e.length-1]}function ht(t){const e=t.split(".");return e.length>1&&"example"===e[e.length-1]?e.slice(0,e.length-1).join("."):t}function vt(t){const{baseDir:e,COMMIT_EDITMSG:s,branchName:a,protectBranch:c,skipMsg:p}=t,f=I(e,s);if(!s)return console.info("COMMIT_EDITMSG value blank"),n(1);const u=r(c).pipe($()),l=r(p).pipe($()),w=W(f).pipe(F(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${f}"`),process.exit(1))}),T(t=>L(t,{encoding:"utf8"})),P(t=>{const e=t.split(/\n|\r\n/)[0];return{head:e,msg:t}}),R()),m=o(n(a),u).pipe(P(([t,e])=>!(!e||!e.test(t))),S(t=>t),O(0),$(1)),h=o(w,l).pipe(P(([{head:t},e])=>!(!e||!e.test(t))),S(t=>t),O(1),$(0)),v=i(m,h).pipe(P(([t,e])=>t&e),$(0),A(1));return v}export{B as assertNever,C as assertNeverRx,ft as isWin32,ut as userHome,G as closeAsync,H as chmodAsync,U as copyFileAsync,_ as mkdirAsync,k as openAsync,L as readFileAsync,z as readDirAsync,J as rmdirAsync,q as statAsync,K as unlinkAsync,Q as writeAsync,V as writeFileAsync,W as pathAccessible,X as isPathAccessible,Y as dirExists,Z as isDirExists,tt as fileExists,et as isFileExists,nt as isDirFileExists,rt as createDir,it as createDirAsync,st as createFileAsync,at as rimraf,pt as validateDllFile,lt as setPathDirectory,wt as genFileFromExample,vt as isSkipCommitlint};
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 v,writeFile as d,access as x}from"fs";import{normalize as y,sep as E,resolve as g,dirname as M,join as I}from"path";export{basename,dirname,join,normalize,resolve as pathResolve}from"path";import{map as P,mergeMap as b,scan as T,concatMap as j,last as D,mapTo as O,defaultIfEmpty as $,tap as A,share as F,filter as R,take as S}from"rxjs/operators";import{promisify as B}from"util";export{promisify}from"util";export{tmpdir}from"os";function N(t){throw new Error("Assert Never Unexpected object: "+t)}function U(e){return t(new Error("Assert Never Unexpected object: "+e))}const C=B(s),G=B(a),H=B(c),_=B(f),k=B(p),L=B(u),z=B(l),J=B(w),q=B(m),K=B(h),Q=B(v),V=B(d);function W(t){return e(()=>X(t)).pipe(P(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(P(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(P(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))),T((t,e)=>g(t,e),E)),i=o.pipe(j(ot),D()),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(O(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=g(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=M(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}const lt="win32"===process.platform,wt=y(lt?process.env.USERPROFILE||"":`${process.env.HOME}`);function mt(t){t&&"string"==typeof t&&process&&process.env&&(process.env.PATH=`${process.env.PATH};${t}`)}async function ht(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(!vt(t))continue;const o=I(e,t),i=dt(t),s=I(e,i);await X(s)||(await H(o,s),n.push(`${r}/${i}`))}}return n}function vt(t){if(!t)return!1;if(".example"===t)return!1;const e=t.split(".");return e.length>1&&"example"===e[e.length-1]}function dt(t){const e=t.split(".");return e.length>1&&"example"===e[e.length-1]?e.slice(0,e.length-1).join("."):t}function xt(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($()),l=r(f).pipe($()),w=W(p).pipe(A(t=>{t||(console.info(`COMMIT_EDITMSG file not exists: "${p}"`),process.exit(1))}),b(t=>L(t,{encoding:"utf8"})),P(t=>{const e=t.split(/\n|\r\n/)[0];return{head:e,msg:t}}),F()),m=o(n(a),u).pipe(P(([t,e])=>!(!e||!e.test(t))),R(t=>t),O(0),$(1)),h=o(w,l).pipe(P(([{head:t},e])=>!(!e||!e.test(t))),R(t=>t),O(1),$(0)),v=i(m,h).pipe(P(([t,e])=>t&e),$(0),S(1));return v}export{pt as ab2buf,N as assertNever,U 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,ht as genFileFromExample,Z as isDirExists,nt as isDirFileExists,et as isFileExists,X as isPathAccessible,xt as isSkipCommitlint,lt as isWin32,_ as mkdirAsync,k as openAsync,W as pathAccessible,z as readDirAsync,L as readFileAsync,at as rimraf,J as rmdirAsync,mt as setPathDirectory,q as statAsync,K as unlinkAsync,wt as userHome,ft as validateDllFile,Q as writeAsync,V as writeFileAsync};
//# sourceMappingURL=index.esm.min.js.map

@@ -70,1 +70,9 @@ /// <reference types="node" />

export declare function validateDllFile(path: string): Promise<void>;
/**
* Convert Browser ArrayBuffer to js Buffer
*/
export declare function ab2buf(ab: ArrayBuffer): Buffer;
/**
* Convert Node.js Buffer to js ArrayBuffer
*/
export declare function buf2ab(buf: Buffer): ArrayBuffer;

@@ -194,1 +194,13 @@ import { access, chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, } from 'fs'

}
/**
* Convert Browser ArrayBuffer to js Buffer
*/
export function ab2buf(ab) {
return Buffer.from(ab)
}
/**
* Convert Node.js Buffer to js ArrayBuffer
*/
export function buf2ab(buf) {
return Uint8Array.from(buf).buffer
}
{
"name": "@waiting/shared-core",
"author": "waiting",
"version": "1.7.0",
"version": "1.8.0",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc