zenypass-modhex
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

zenypass-modhex

NPM

lightweight (388 bytes gzip) hex to modhex converter and vice-versa for zenypass.

Example

import { hex2modhex, modhex2hex, isPureModhex } from 'zenypass-modhex'
console.log(hex2modhex('84c16a0172e6d1f9b58df78503f65b'))
// 'jfrchlbciduhtcvkngjtvijgbevhgn'
console.log(modhex2hex('jfrchlbciduhtcvkngjtvijgbevhgn'))
// '84c16a0172e6d1f9b58df78503f65b'
console.log(modhex2hex('jfrqhl')) // `q` is not modhex -> not converted
// '84cq6a'
console.log(hex2modhex('84cq6a')) // `q` is not hex -> not converted
// 'jfrqhl'
console.log(isPureModhex('jfrqhl')) // includes a `q` !
// false
console.log(isPureModhex('jfrchlbciduhtcvkngjtvijgbevhgn'))
// true

API

export declare const modhex2hex: (val: string) => string
export declare const hex2modhex: (val: string) => string
export declare function isPureModhex(val: any): val is string
 
export declare const MODHEX_DIGITS = "bcdefghijklnrtuv"
export declare const HEX_DIGITS = "0123456789abcdef"
export declare function isString(val: any): val is string | String
export default function translator(
  digits: { from: string, to: string }
): (val: string) => string

TypeScript

although this library is written in TypeScript, it may also be imported into plain JavaScript code: modern code editors will still benefit from the available type definition, e.g. for helpful code completion.

License

Copyright 2019, ZenyWay S.A.S., Stéphane M. Catala

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and Limitations under the License.

Readme

Keywords

Package Sidebar

Install

npm i zenypass-modhex

Weekly Downloads

1

Version

1.0.0

License

SEE LICENSE IN LICENSE

Unpacked Size

17.3 kB

Total Files

6

Last publish

Collaborators

  • smcatala