New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@waiting/shared-core

Package Overview
Dependencies
Maintainers
1
Versions
201
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 3.5.1 to 4.0.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [4.0.0](https://github.com/waitingsong/node-shared-core/compare/v3.5.1...v4.0.0) (2020-06-11)
### Bug Fixes
* **core:** createFileAsync() types of param `data` ([d19f510](https://github.com/waitingsong/node-shared-core/commit/d19f510b40d53272025d8e1843d714b80782d3a2))
### Features
* increase pkg.engines.node to >=12.13.0 ([b296c00](https://github.com/waitingsong/node-shared-core/commit/b296c0030a5c36a566975ba802a3763f96dbe774))
## [3.5.1](https://github.com/waitingsong/node-shared-core/compare/v3.5.0...v3.5.1) (2020-03-18)

@@ -8,0 +24,0 @@

41

dist/index.cjs.js

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

*
* @version 3.5.0
* @version 3.5.1
* @author waiting

@@ -33,3 +33,3 @@ * @license MIT

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
const closeAsync = util.promisify(fs.close);

@@ -92,22 +92,4 @@ const chmodAsync = util.promisify(fs.chmod);

function createDir(absolutePath) {
/* istanbul ignore else */
if (!absolutePath) {
throw new Error('value of path param invalid');
}
// ! normalize required for '.../.myca' under win32
const path$ = rxjs.of(path.normalize(absolutePath));
const paths$ = path$.pipe(operators.mergeMap(target => rxjs.from(target.split(path.sep))), operators.scan((acc, curr) => path.resolve(acc, curr), path.sep));
const create$ = paths$.pipe(operators.concatMap(_createDirObb), operators.last());
const ret$ = path$.pipe(operators.mergeMap(dirExists), operators.mergeMap((ps) => {
return ps ? rxjs.of(ps) : create$;
}));
return ret$;
return rxjs.defer(() => createDirAsync(absolutePath));
}
function _createDirObb(path) {
return pathAccessible(path).pipe(operators.mergeMap((str) => {
return str
? rxjs.of(str)
: rxjs.defer(() => mkdirAsync(path, 0o755)).pipe(operators.mapTo(path));
}));
}
/** create directories recursively */

@@ -119,7 +101,3 @@ async function createDirAsync(path$1) {

if (!await isDirExists(target)) {
await target.split(path.sep).reduce(async (parentDir, childDir) => {
const curDir = path.resolve(await parentDir, childDir);
await isPathAccessible(curDir) || await mkdirAsync(curDir, 0o755);
return curDir;
}, Promise.resolve(path.sep));
await mkdirAsync(path$1, { recursive: true });
}

@@ -158,2 +136,5 @@ return target;

}
else if (typeof data === 'number') {
await writeFileAsync(path$1, data.toString(), opts);
}
else {

@@ -267,2 +248,3 @@ await writeFileAsync(path$1, data, opts);

/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* istanbul ignore next */

@@ -273,3 +255,3 @@ const isWin32 = process.platform === 'win32';

? path.normalize(process.env.USERPROFILE || '')
: path.normalize(`${process.env.HOME}`);
: path.normalize(process.env.HOME ? `${process.env.HOME}` : '');

@@ -300,4 +282,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

function setPathDirectory(path) {
if (path && typeof path === 'string' && process && process.env) {
process.env.PATH = `${process.env.PATH};${path}`;
if (path && typeof path === 'string') {
const ori = process.env.PATH ? process.env.PATH : '';
process.env.PATH = `${ori};${path}`;
}

@@ -304,0 +287,0 @@ }

@@ -0,1 +1,2 @@

/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
import { normalize } from './utils';

@@ -7,2 +8,2 @@ /* istanbul ignore next */

? normalize(process.env.USERPROFILE || '')
: normalize(`${process.env.HOME}`);
: normalize(process.env.HOME ? `${process.env.HOME}` : '');
/** Set loading path for node-ffi linking dll */
export function setPathDirectory(path) {
if (path && typeof path === 'string' && process && process.env) {
process.env.PATH = `${process.env.PATH};${path}`;
if (path && typeof path === 'string') {
const ori = process.env.PATH ? process.env.PATH : '';
process.env.PATH = `${ori};${path}`;
}
}
/// <reference types="node" />
import { chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile } from 'fs';
import { chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, WriteFileOptions } from 'fs';
import { basename, dirname, join, normalize, resolve as pathResolve } from 'path';

@@ -40,5 +40,5 @@ import { promisify } from 'util';

*/
export declare function createFileAsync(file: string, data: any, options?: WriteFileOptions): Promise<string>;
export declare function createFileAsync(file: string, data: string | NodeJS.ArrayBufferView | number | Record<PropertyKey, unknown>, options?: WriteFileOptions): Promise<string>;
/**
* @deprecated in favor of using child_process['ExecOptions']
* @deprecated in favor of using child_process['ExecFileOptions']
*/

@@ -57,7 +57,2 @@ export interface ExecFileOptions {

}
export interface WriteFileOptions {
encoding?: string | null;
mode?: number;
flag?: string;
}
/**

@@ -64,0 +59,0 @@ * Remove directory recursively

@@ -0,7 +1,8 @@

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { access, chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, } from 'fs';
import { basename, dirname, join, normalize, resolve as pathResolve, sep, } from 'path';
import { basename, dirname, join, normalize, resolve as pathResolve, } from 'path';
import { promisify, TextDecoder, TextEncoder } from 'util';
import { defer, from as ofrom, of, } from 'rxjs';
import { concatMap, last, map, mapTo, mergeMap, scan, } from 'rxjs/operators';
import { defer, of, } from 'rxjs';
import { map } from 'rxjs/operators';
export const closeAsync = promisify(close);

@@ -66,22 +67,4 @@ export const chmodAsync = promisify(chmod);

export function createDir(absolutePath) {
/* istanbul ignore else */
if (!absolutePath) {
throw new Error('value of path param invalid');
}
// ! normalize required for '.../.myca' under win32
const path$ = of(normalize(absolutePath));
const paths$ = path$.pipe(mergeMap(target => ofrom(target.split(sep))), scan((acc, curr) => pathResolve(acc, curr), sep));
const create$ = paths$.pipe(concatMap(_createDirObb), last());
const ret$ = path$.pipe(mergeMap(dirExists), mergeMap((ps) => {
return ps ? of(ps) : create$;
}));
return ret$;
return defer(() => createDirAsync(absolutePath));
}
function _createDirObb(path) {
return pathAccessible(path).pipe(mergeMap((str) => {
return str
? of(str)
: defer(() => mkdirAsync(path, 0o755)).pipe(mapTo(path));
}));
}
/** create directories recursively */

@@ -93,7 +76,3 @@ export async function createDirAsync(path) {

if (!await isDirExists(target)) {
await target.split(sep).reduce(async (parentDir, childDir) => {
const curDir = pathResolve(await parentDir, childDir);
await isPathAccessible(curDir) || await mkdirAsync(curDir, 0o755);
return curDir;
}, Promise.resolve(sep));
await mkdirAsync(path, { recursive: true });
}

@@ -132,2 +111,5 @@ return target;

}
else if (typeof data === 'number') {
await writeFileAsync(path, data.toString(), opts);
}
else {

@@ -134,0 +116,0 @@ await writeFileAsync(path, data, opts);

{
"name": "@waiting/shared-core",
"author": "waiting",
"version": "3.5.1",
"version": "4.0.0",
"description": "node core function re export with Promise or Observable",

@@ -26,3 +26,3 @@ "keywords": [

"dependencies": {
"@waiting/shared-types": "^3.5.1",
"@waiting/shared-types": "^4.0.0",
"rxjs": "^6.5.2"

@@ -34,3 +34,3 @@ },

"engines": {
"node": ">=10.16.0"
"node": ">=12.13.0"
},

@@ -79,3 +79,3 @@ "files": [

},
"gitHead": "20571ae259c6d87b2dbf6fbcc56b68706d8b5ec5"
"gitHead": "e65bdfabff406c0a533c26400cae4c8a23a00007"
}

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