All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.core.model.linkifier.model.ts Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: 2017-2024 Enedis
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 */

export class Linkifier {
    constructor(public pattern: string,
                public link: string,
                public id?: string) {
        if (this.id == null) {
            this.id = this.hash(pattern) + this.hash(link);
        }
    }

    hash(s: string) {
        for (var i = 0, h = 0; i < s.length; i++) {
            h = Math.imul(31, h) + s.charCodeAt(i) | 0;
        }
        return h.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy