Skip to content

Commit

Permalink
fix: typo in cancelable property
Browse files Browse the repository at this point in the history
  • Loading branch information
drusco committed Aug 21, 2024
1 parent e97d23c commit 2b5fc9d
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/events/NexoEmitter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("NexoEmitter", () => {

it("Adds the return value to the events 'returnValue' property", () => {
const emitter = new NexoEmitter();
const nexoEvent = new NexoEvent("test", { cancellable: true });
const nexoEvent = new NexoEvent("test", { cancelable: true });
const returnValue = new Object();

emitter.on("test", (event: NexoEvent) => {
Expand Down
2 changes: 1 addition & 1 deletion src/events/NexoEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("NexoEvent", () => {
});

it("Prevents the event default behaviour", () => {
const event = new NexoEvent("foo", { cancellable: true });
const event = new NexoEvent("foo", { cancelable: true });
event.preventDefault();

expect(event.defaultPrevented).toBe(true);
Expand Down
8 changes: 4 additions & 4 deletions src/events/NexoEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ class NexoEvent<Target = unknown, Data = unknown> {
readonly data: Data;
readonly target: Target;
readonly timestamp: number;
readonly cancellable: boolean;
readonly cancelable: boolean;
public returnValue: unknown;
private _defaultPrevented: boolean;

constructor(name: string, options: nx.events.options<Target, Data> = {}) {
options = { cancellable: false, ...options };
options = { cancelable: false, ...options };
this.name = name;
this.data = options.data;
this.target = options.target;
this.cancellable = options.cancellable;
this.cancelable = options.cancelable;
this.timestamp = Date.now();
this._defaultPrevented = false;
}

preventDefault(): void {
if (!this.cancellable) {
if (!this.cancelable) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/handlers/apply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("apply", () => {
expect(applyCallbackNexo).toHaveBeenCalledTimes(1);
expect(applyEventForNexo).toBeInstanceOf(ProxyEvent);
expect(applyEventForNexo.target).toBe(proxy);
expect(applyEventForNexo.cancellable).toBe(true);
expect(applyEventForNexo.cancelable).toBe(true);

expect(applyEventForNexo.data).toStrictEqual({
this: _this,
Expand Down Expand Up @@ -136,7 +136,7 @@ describe("apply", () => {

expect(updateCallback).toHaveBeenCalledTimes(1);
expect(updateEvent.target).toBe(expectedProxy);
expect(updateEvent.cancellable).toBe(false);
expect(updateEvent.cancelable).toBe(false);
expect(updateEvent.data).toBe(expectedResult);
});

Expand Down Expand Up @@ -167,7 +167,7 @@ describe("apply", () => {

expect(updateCallback).toHaveBeenCalledTimes(1);
expect(updateEvent.target).toBe(expectedProxy);
expect(updateEvent.cancellable).toBe(false);
expect(updateEvent.cancelable).toBe(false);
expect(updateEvent.data).toBe(expectedResultProxy);
expect(isProxy(expectedResultProxy)).toBe(true);
expect(result).toBe(expectedResultProxy);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const apply = (
const event = new ProxyEvent("apply", {
target: proxy,
data: { this: that, arguments: args, result: resultProxy },
cancellable: true,
cancelable: true,
});

if (event.defaultPrevented) {
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/construct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("construct", () => {

expect(constructCallbackNexo).toHaveBeenCalledTimes(1);
expect(constructEventForNexo.target).toBe(proxy);
expect(constructEventForNexo.cancellable).toBe(true);
expect(constructEventForNexo.cancelable).toBe(true);

expect(constructEventForNexo.data).toStrictEqual({
arguments: args,
Expand Down Expand Up @@ -126,7 +126,7 @@ describe("construct", () => {

expect(updateCallback).toHaveBeenCalledTimes(1);
expect(updateEvent.target).toBe(expectedProxy);
expect(updateEvent.cancellable).toBe(false);
expect(updateEvent.cancelable).toBe(false);
expect(updateEvent.data).toBe(expectedResult);
});

Expand Down Expand Up @@ -154,7 +154,7 @@ describe("construct", () => {

expect(updateCallback).toHaveBeenCalledTimes(1);
expect(updateEvent.target).toBe(expectedProxy);
expect(updateEvent.cancellable).toBe(false);
expect(updateEvent.cancelable).toBe(false);
expect(updateEvent.data).toBeInstanceOf(constructable);
expect(isProxy(result)).toBe(true);
expect(result).toBe(updateEvent.data);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const construct = (fn: nx.voidFunction, args: nx.arrayLike = []): object => {
const event = new ProxyEvent("construct", {
target: proxy,
data: { arguments: args, result: resultProxy },
cancellable: true,
cancelable: true,
});

if (event.defaultPrevented) {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/defineProperty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("defineProperty", () => {
expect(result).toBe(true);
expect(definePropertyCallbackNexo).toHaveBeenCalledTimes(1);
expect(definePropertyEventForNexo.target).toBe(proxy);
expect(definePropertyEventForNexo.cancellable).toBe(true);
expect(definePropertyEventForNexo.cancelable).toBe(true);

expect(definePropertyEventForNexo.data).toStrictEqual({
property: "foo",
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/defineProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defineProperty = (

const event = new ProxyEvent("defineProperty", {
target: proxy,
cancellable: true,
cancelable: true,
data: {
property,
descriptor,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const get = (fn: nx.voidFunction, property: nx.objectKey): unknown => {

const event = new ProxyEvent("get", {
target: proxy,
cancellable: true,
cancelable: true,
data: { property },
});

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/getOwnPropertyDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getOwnPropertyDescriptor = (

new ProxyEvent("getOwnPropertyDescriptor", {
target: proxy,
cancellable: false,
cancelable: false,
data: {
property,
},
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ownKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ownKeys = (fn: nx.voidFunction): nx.objectKey[] => {

new ProxyEvent("ownKeys", {
target: proxy,
cancellable: false,
cancelable: false,
});

// Returns the own keys from the void function target
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const update = <Type>(proxy: nx.Proxy, value: Type): Proxy<Type> => {
const event = new NexoEvent("nx.update", {
target: proxy,
data: value,
cancellable: false,
cancelable: false,
});

/**
Expand Down
2 changes: 1 addition & 1 deletion src/types/Nexo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare namespace Nexo {
interface options<Target, Data> {
target?: Target;
data?: Data;
cancellable?: boolean;
cancelable?: boolean;
}
}
}
Expand Down

0 comments on commit 2b5fc9d

Please sign in to comment.