Socket
Socket
Sign inDemoInstall

@microsoft/node-core-library

Package Overview
Dependencies
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/node-core-library - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/PackageName.d.ts

15

CHANGELOG.json

@@ -5,2 +5,17 @@ {

{
"version": "1.1.0",
"tag": "@microsoft/node-core-library_v1.1.0",
"date": "Mon, 02 Apr 2018 16:05:24 GMT",
"comments": {
"minor": [
{
"comment": "Add new API \"PackageName\" for validating package names and extracting scopes"
},
{
"comment": "Add new API \"ProtectableMap\" for tracking/restricting how a map is consumed"
}
]
}
},
{
"version": "1.0.0",

@@ -7,0 +22,0 @@ "tag": "@microsoft/node-core-library_v1.0.0",

10

CHANGELOG.md
# Change Log - @microsoft/node-core-library
This log was last generated on Sat, 17 Mar 2018 02:54:22 GMT and should not be manually modified.
This log was last generated on Mon, 02 Apr 2018 16:05:24 GMT and should not be manually modified.
## 1.1.0
Mon, 02 Apr 2018 16:05:24 GMT
### Minor changes
- Add new API "PackageName" for validating package names and extracting scopes
- Add new API "ProtectableMap" for tracking/restricting how a map is consumed
## 1.0.0

@@ -6,0 +14,0 @@ Sat, 17 Mar 2018 02:54:22 GMT

@@ -276,2 +276,60 @@ /**

/**
* A package name that has been separated into its scope and unscoped name.
*
* @public
*/
export declare interface IParsedPackageName {
/**
* The parsed NPM scope, or an empty string if there was no scope. The scope value will
* always include the at-sign.
* @remarks
* For example, if the parsed input was "\@scope/example", then scope would be "\@scope".
*/
scope: string;
/**
* The parsed NPM package name without the scope.
* @remarks
* For example, if the parsed input was "\@scope/example", then the name would be "example".
*/
unscopedName: string;
}
/**
* Result object returned by {@link PackageName.tryParse}
*
* @public
*/
export declare interface IParsedPackageNameOrError extends IParsedPackageName {
/**
* If the input string could not be parsed, then this string will contain a nonempty
* error message. Otherwise it will be an empty string.
*/
error: string;
}
/**
* Constructor parameters for {@link ProtectableMap}
*
* @public
*/
export declare interface IProtectableMapParameters<K, V> {
/**
* An optional hook that will be invoked before Map.clear() is performed.
*/
onClear?: (source: ProtectableMap<K, V>) => void;
/**
* An optional hook that will be invoked before Map.delete() is performed.
*/
onDelete?: (source: ProtectableMap<K, V>, key: K) => void;
/**
* An optional hook that will be invoked before Map.set() is performed.
* @remarks
* If this hook is provided, the function MUST return the `value` parameter.
* This provides the opportunity to modify the value before it is added
* to the map.
*/
onSet?: (source: ProtectableMap<K, V>, key: K, value: V) => V;
}
/**
* Utilities for reading/writing JSON files.

@@ -524,2 +582,46 @@ * @public

/**
* Various functions for working with package names that may include scopes.
*
* @public
*/
export declare class PackageName {
private static readonly invalidNameCharactersRegExp;
/**
* This attempts to parse a package name that may include a scope component.
* @remarks
* This function will not throw an exception.
*
* @returns an {@link IParsedPackageNameOrError} structure whose `error` property will be
* nonempty if the string could not be parsed.
*/
static tryParse(packageName: string): IParsedPackageNameOrError;
/**
* Same as {@link PackageName.tryParse}, except this throws an exception if the input
* cannot be parsed
*/
static parse(packageName: string): IParsedPackageName;
/**
* {@inheritdoc IParsedPackageName.scope}
*/
static getScope(packageName: string): string;
/**
* {@inheritdoc IParsedPackageName.unscopedName}
*/
static getUnscopedName(packageName: string): string;
/**
* Returns true if the specified package name is valid, or false otherwise.
* @remarks
* This function will not throw an exception.
*/
static isValidName(packageName: string): boolean;
/**
* Combines an optional package scope with an unscoped root name.
* @param scope - Must be either an empty string, or a scope name such as "\@example"
* @param unscopedName - Must be a nonempty package name that does not contain a scope
* @returns A full package name such as "\@example/some-library".
*/
static combineParts(scope: string, unscopedName: string): string;
}
/**
* Common operations for manipulating file and directory paths.

@@ -541,2 +643,62 @@ * @remarks

/**
* The ProtectableMap provides an easy way for an API to expose a Map<K, V> property
* while intercepting and validating any write operations that are performed by
* consumers of the API.
*
* @remarks
* The ProtectableMap itself is intended to be a private object that only its owner
* can access directly. Any operations performed directly on the ProtectableMap will
* bypass the hooks and any validation they perform. The public property that is exposed
* to API consumers should return {@link ProtectableMap.protectedView} instead.
*
* For example, suppose you want to share your Map<string,number> data structure,
* but you want to enforce that the key must always be an upper case string:
* You could use the onSet() hook to validate the keys and throw an exception
* if the key is not uppercase.
*
* @public
*/
export declare class ProtectableMap<K, V> {
private readonly _protectedView;
constructor(parameters: IProtectableMapParameters<K, V>);
/**
* The owner of the protectable map should return this object via its public API.
*/
readonly protectedView: Map<K, V>;
/**
* Removes all entries from the map.
* This operation does NOT invoke the ProtectableMap onClear() hook.
*/
clear(): void;
/**
* Removes the specified key from the map.
* This operation does NOT invoke the ProtectableMap onDelete() hook.
*/
delete(key: K): boolean;
/**
* Sets a value for the specified key.
* This operation does NOT invoke the ProtectableMap onSet() hook.
*/
set(key: K, value: V): this;
/**
* Performs an operation for each (key, value) entries in the map.
*/
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
/**
* Retrieves the value for the specified key.
* @returns undefined if the value is undefined OR if the key is missing;
* otherwise returns the value associated with the key.
*/
get(key: K): V | undefined;
/**
* Returns true if the specified key belongs to the map.
*/
has(key: K): boolean;
/**
* Returns the number of (key, value) entries in the map.
*/
readonly size: number;
}
/**
* Operations for working with strings that contain text.

@@ -543,0 +705,0 @@ *

8

lib/index.d.ts

@@ -6,10 +6,12 @@ /**

*/
export { FileConstants, FolderConstants } from './Constants';
export { FileDiffTest } from './FileDiffTest';
export { IPackageJson, IPackageJsonDependencyTable, IPackageJsonScriptTable, IPackageJsonTsdocConfiguration } from './IPackageJson';
export { JsonFile, IJsonFileSaveOptions, IJsonFileStringifyOptions } from './JsonFile';
export { JsonSchema, IJsonSchemaErrorInfo, IJsonSchemaValidateOptions, IJsonSchemaFromFileOptions } from './JsonSchema';
export { LockFile } from './LockFile';
export { ProtectableMap, IProtectableMapParameters } from './ProtectableMap';
export { IPackageJsonLookupParameters, PackageJsonLookup } from './PackageJsonLookup';
export { IPackageJson, IPackageJsonDependencyTable, IPackageJsonScriptTable, IPackageJsonTsdocConfiguration } from './IPackageJson';
export { FileConstants, FolderConstants } from './Constants';
export { LockFile } from './LockFile';
export { PackageName, IParsedPackageName, IParsedPackageNameOrError } from './PackageName';
export { Path } from './Path';
export { Text } from './Text';

@@ -5,7 +5,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
/**
* Core libraries that every NodeJS toolchain project should use.
*
* @packagedocumentation
*/
var FileDiffTest_1 = require("./FileDiffTest");

@@ -17,6 +12,10 @@ exports.FileDiffTest = FileDiffTest_1.FileDiffTest;

exports.JsonSchema = JsonSchema_1.JsonSchema;
var LockFile_1 = require("./LockFile");
exports.LockFile = LockFile_1.LockFile;
var ProtectableMap_1 = require("./ProtectableMap");
exports.ProtectableMap = ProtectableMap_1.ProtectableMap;
var PackageJsonLookup_1 = require("./PackageJsonLookup");
exports.PackageJsonLookup = PackageJsonLookup_1.PackageJsonLookup;
var LockFile_1 = require("./LockFile");
exports.LockFile = LockFile_1.LockFile;
var PackageName_1 = require("./PackageName");
exports.PackageName = PackageName_1.PackageName;
var Path_1 = require("./Path");

@@ -23,0 +22,0 @@ exports.Path = Path_1.Path;

@@ -62,4 +62,3 @@ "use strict";

const testFolder = path.join(__dirname, '1');
fsx.removeSync(testFolder);
fsx.mkdirsSync(testFolder);
fsx.emptyDirSync(testFolder);
const resourceName = 'test';

@@ -85,4 +84,3 @@ const pidLockFileName = LockFile_1.LockFile.getLockFilePath(testFolder, resourceName);

const testFolder = path.join(__dirname, '2');
fsx.removeSync(testFolder);
fsx.mkdirsSync(testFolder);
fsx.emptyDirSync(testFolder);
const otherPid = 999999999;

@@ -89,0 +87,0 @@ const otherPidStartTime = '2012-01-02 12:53:12';

{
"name": "@microsoft/node-core-library",
"version": "1.0.0",
"version": "1.1.0",
"description": "Core libraries that every NodeJS toolchain project should use",

@@ -28,4 +28,4 @@ "main": "lib/index.js",

"mocha": "~3.4.2",
"@microsoft/node-library-build": "4.3.13"
"@microsoft/node-library-build": "4.3.28"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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