Skip to content

Commit

Permalink
docs: add since tag
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasnix committed Aug 27, 2024
1 parent d9b106c commit 8eb4679
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/object-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns an instance of ObjectGraph.
* @since 0.1.0
*/
constructor(nodeValues: Array<NodeValue>, keyExtractor: (nodeValue: NodeValue) => string) {
if (!nodeValues) {
Expand All @@ -23,13 +24,15 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns the length of the object graph.
* @since 0.1.0
*/
public get length() {
return this.nodes.size;
}

/**
* @description Returns a node of the object graph.
* @since 0.1.0
*/
public get(nodeKey: string) {
if (!nodeKey) {
Expand All @@ -47,20 +50,23 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns all nodes of the object graph.
* @since 0.1.0
*/
public getAll() {
return Array.from(this.nodes.values());
}

/**
* @description Returns a copy of the original object graph.
* @since 0.1.0
*/
public copy() {
return new ObjectGraph(Array.from(this.nodes.values()), this.keyExtractor);
}

/**
* @description Adds a node to the object graph.
* @since 0.1.0
*/
public add(nodeValue: NodeValue) {
if (!nodeValue) {
Expand All @@ -75,6 +81,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns a copy of the original object graph with a received node added.
* @since 0.1.0
*/
public toAdded(nodeValue: NodeValue) {
const copiedObjectGraph = this.copy();
Expand All @@ -84,6 +91,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Updates a node in the object graph.
* @since 0.1.0
*/
public update(nodeValue: NodeValue) {
if (!nodeValue) {
Expand All @@ -98,6 +106,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns a copy of the original object graph with a received node updated.
* @since 0.1.0
*/
public toUpdated(nodeValue: NodeValue) {
const copiedObjectGraph = this.copy();
Expand All @@ -107,6 +116,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Removes a node from the object graph.
* @since 0.1.0
*/
public remove(nodeKey: string) {
if (!nodeKey) {
Expand All @@ -123,6 +133,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns a copy of the original object graph with a received node removed.
* @since 0.1.0
*/
public toRemoved(nodeKey: string) {
const copiedObjectGraph = this.copy();
Expand All @@ -132,6 +143,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns all values of the provided property.
* @since 0.1.0
*/
public valuesOf(propertyKey: keyof NodeValue) {
if (!propertyKey) {
Expand All @@ -149,6 +161,7 @@ export class ObjectGraph<NodeValue extends Record<string, unknown>> {

/**
* @description Returns all nodes that match with the provided shape.
* @since 0.1.0
*/
public match(shape: Partial<Record<keyof NodeValue, Array<unknown>>>) {
if (!shape) {
Expand Down

0 comments on commit 8eb4679

Please sign in to comment.