🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@autometa/bind-decorator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autometa/bind-decorator - npm Package Compare versions

Comparing version
0.4.0
to
0.4.1
.eslintignore

Sorry, the diff of this file is not supported yet

+4
declare function Bind<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
declare function Freeze<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
export { Bind, Freeze };
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// index.ts
var bind_decorator_exports = {};
__export(bind_decorator_exports, {
Bind: () => Bind,
Freeze: () => Freeze
});
module.exports = __toCommonJS(bind_decorator_exports);
function Bind(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(
`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`
);
}
return {
configurable: true,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true
});
return bound;
},
// eslint-disable-next-line @typescript-eslint/ban-types
set(value) {
const bound = value.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true
});
return bound;
}
};
}
function Freeze(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(
`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`
);
}
return {
configurable: false,
writable: false,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true
});
return bound;
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Bind,
Freeze
});
export declare function Bind<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
export declare function Freeze<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CA6BnC;AAGD,wBAAgB,MAAM,CAAC,CAAC,SAAS,QAAQ,EACvC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CAoBnC"}

Sorry, the diff of this file is not supported yet

import type { Options } from "tsup";
export const tsup: Options = {
clean: true, // clean up the dist folder
format: ["cjs", "esm"], // generate cjs and esm files
skipNodeModulesBundle: true,
entryPoints: ["index.ts"],
target: "es2020",
outDir: "dist",
legacyOutput: true,
external: ["dist"],
};
+29
-8
> @autometa/bind-decorator@0.4.0 build /home/runner/work/autometa/autometa/libraries/bind-decorator
> pnpm build:code && pnpm postbuild
> @autometa/bind-decorator@0.4.1 build /home/runner/work/autometa/autometa/libraries/bind-decorator
> pnpm build:js && pnpm build:dts
> @autometa/bind-decorator@0.4.0 build:code /home/runner/work/autometa/autometa/libraries/bind-decorator
> rimraf dist/ && pnpm run build:libs && ./fixup
> @autometa/bind-decorator@0.4.1 build:js /home/runner/work/autometa/autometa/libraries/bind-decorator
> tsup
CLI Building entry: index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.7.0
CLI Using tsup config: /home/runner/work/autometa/autometa/libraries/bind-decorator/tsup.config.ts
CLI Target: es2020
CLI Cleaning output folder
CJS Build start
ESM Build start
CJS You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
ESM You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
CJS dist/index.js 2.32 KB
CJS ⚡️ Build success in 27ms
ESM dist/esm/index.js 1.30 KB
ESM ⚡️ Build success in 27ms
> @autometa/bind-decorator@0.4.0 build:libs /home/runner/work/autometa/autometa/libraries/bind-decorator
> tsc -p tsconfig.json && tsc -p tsconfig.cjs.json
> @autometa/bind-decorator@0.4.1 build:dts /home/runner/work/autometa/autometa/libraries/bind-decorator
> pnpm build:dts:tsc
> @autometa/bind-decorator@0.4.0 postbuild /home/runner/work/autometa/autometa/libraries/bind-decorator
> tsc-alias -p ./tsconfig.cjs.json && tsc-alias -p ./tsconfig.json
> @autometa/bind-decorator@0.4.1 build:dts:tsc /home/runner/work/autometa/autometa/libraries/bind-decorator
> tsc --build --clean && tsc && tsup --entry.index out/index.d.ts --dtsOnly
CLI Building entry: {"index":"out/index.d.ts"}
CLI Using tsconfig: tsconfig.json
CLI tsup v6.7.0
CLI Using tsup config: /home/runner/work/autometa/autometa/libraries/bind-decorator/tsup.config.ts
DTS Build start
DTS ⚡️ Build success in 154ms
DTS dist/index.d.ts 340.00 B
> @autometa/bind-decorator@0.4.0 lint /home/runner/work/autometa/autometa/libraries/bind-decorator
> @autometa/bind-decorator@0.4.1 lint /home/runner/work/autometa/autometa/libraries/bind-decorator
> eslint . --max-warnings 0
> @autometa/bind-decorator@0.4.0 test /home/runner/work/autometa/autometa/libraries/bind-decorator
> @autometa/bind-decorator@0.4.1 test /home/runner/work/autometa/autometa/libraries/bind-decorator
> vitest run --passWithNoTests

@@ -4,0 +4,0 @@

# @autometa/dto-builder
## 0.4.1
### Patch Changes
- 6a4a9ac: Swapped project type to "composite", unified build system for most projects
## 0.4.0

@@ -4,0 +10,0 @@

@@ -1,47 +0,54 @@

// eslint-disable-next-line @typescript-eslint/ban-types
export function Bind(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`);
// index.ts
function Bind(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(
`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`
);
}
return {
configurable: true,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true
});
return bound;
},
// eslint-disable-next-line @typescript-eslint/ban-types
set(value) {
const bound = value.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true
});
return bound;
}
return {
};
}
function Freeze(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(
`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`
);
}
return {
configurable: false,
writable: false,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
// eslint-disable-next-line @typescript-eslint/ban-types
set(value) {
const bound = value.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
};
}
// eslint-disable-next-line @typescript-eslint/ban-types
export function Freeze(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`);
writable: true
});
return bound;
}
return {
configurable: false,
writable: false,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
};
};
}
export {
Bind,
Freeze
};
{
"name": "@autometa/bind-decorator",
"version": "0.4.0",
"description": "Binds the this keyword of a method",
"version": "0.4.1",
"description": "Binds the this keyword of a method. Respectfully a fork of https://www.npmjs.com/package/bind-decorator",
"type": "module",

@@ -10,8 +10,4 @@ "main": "dist/cjs/index.js",

"keywords": [
"status codes",
"http",
"node",
"http status",
"status text",
"reason phrases"
"bind this keyword",
"bind decorator"
],

@@ -35,3 +31,3 @@ "repository": {

"eslint": "^7.32.0",
"eslint-config-custom": "0.5.0",
"eslint-config-custom": "0.5.1",
"node": "^19.6.0",

@@ -43,17 +39,20 @@ "prettier": "^2.8.3",

"ts-node": "^10.9.1",
"tsc-alias": "^1.8.2",
"typescript": "^4.9.5",
"vitest": "^0.28.5"
},
"dependencies": {
"tsup": "^6.7.0"
},
"scripts": {
"test": "vitest run --passWithNoTests",
"prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettify": "prettier --config .prettierrc '**/*.ts' --write",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"postbuild": "tsc-alias -p ./tsconfig.cjs.json && tsc-alias -p ./tsconfig.json",
"build:libs": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
"build:code": "rimraf dist/ && pnpm run build:libs && ./fixup",
"build": "pnpm build:code && pnpm postbuild"
"build:js": "tsup",
"build:dts:tsc": "tsc --build --clean && tsc && tsup --entry.index out/index.d.ts --dtsOnly",
"build:dts": "pnpm build:dts:tsc",
"build": "pnpm build:js && pnpm build:dts ",
"build:watch": "tsup --watch"
},
"readme": "# Introduction\n\nBinds the `this` keyword on a clss method.\n\nThis is a fork of [bind-decorator](https://www.npmjs.com/package/bind-decorator) for use with Autometa.\n\n```\nnpm add @autometa/bind-decorator\n```\n\n# Use\n\n```ts\nimport { Bind } from \"@autometa/bind-decorator\";\n\nclass Foo {\n @Bind\n a() {\n // this.doStuff()\n }\n}\n```\n"
"readme": "# Introduction\n\nBinds the `this` keyword on a class method.\n\nThis is a fork of [bind-decorator](https://www.npmjs.com/package/bind-decorator) for use with Autometa.\n\n```\nnpm add @autometa/bind-decorator\n```\n\n# Use\n\n```ts\nimport { Bind } from \"@autometa/bind-decorator\";\n\nclass Foo {\n @Bind\n a() {\n // this.doStuff()\n }\n}\n```\n"
}
# Introduction
Binds the `this` keyword on a clss method.
Binds the `this` keyword on a class method.

@@ -5,0 +5,0 @@ This is a fork of [bind-decorator](https://www.npmjs.com/package/bind-decorator) for use with Autometa.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Freeze = exports.Bind = void 0;
// eslint-disable-next-line @typescript-eslint/ban-types
function Bind(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`);
}
return {
configurable: true,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
// eslint-disable-next-line @typescript-eslint/ban-types
set(value) {
const bound = value.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
};
}
exports.Bind = Bind;
// eslint-disable-next-line @typescript-eslint/ban-types
function Freeze(_target, propertyKey, descriptor) {
if (!descriptor || typeof descriptor.value !== "function") {
throw new TypeError(`Only methods can be decorated with @bind. <${propertyKey}> is not a method!`);
}
return {
configurable: false,
writable: false,
get() {
const bound = descriptor.value?.bind(this);
Object.defineProperty(this, propertyKey, {
value: bound,
configurable: true,
writable: true,
});
return bound;
},
};
}
exports.Freeze = Freeze;
{
"type": "commonjs"
}
{
"type": "module"
}
export declare function Bind<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
export declare function Freeze<T extends Function>(_target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AACA,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CA6BnC;AAGD,wBAAgB,MAAM,CAAC,CAAC,SAAS,QAAQ,EACvC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CAoBnC"}

Sorry, the diff of this file is not supported yet