Utilities

Examples for mm-nrc utilities.

Check if string is English NRC pattern

import { pattern } from 'mm-nrc';

const engNrcPattern = pattern.en;

console.log(
  'Test 1:',
  engNrcPattern.test('12/TAMANA(N)112233') // true
)

console.log(
  'Test 2:',
  engNrcPattern.test('12/TAMA(N)1133') // false
)

console.log(
  'Test 3:',
  engNrcPattern.test('၁၂/တမန(နိုင်)112233') // false
)
# OUTPUT
#
# Test 1: true
# Test 2: false
# Test 3: false

Check if string is Myanmar NRC pattern

import { pattern } from 'mm-nrc';

const mmNrcPattern = pattern.mm;

console.log(
  'Test 1:',
  mmNrcPattern.test('12/TAMANA(N)112233') // false
)

console.log(
  'Test 2:',
  mmNrcPattern.test('12/TAMA(N)1133') // false
)

console.log(
  'Test 3:',
  mmNrcPattern.test('၁၂/တမန(နိုင်)112233') // true
)
# OUTPUT
#
# Test 1: false
# Test 2: false
# Test 3: true

Convert English NRC string to Myanmar NRC string

import { convertToMmNrc } from 'mm-nrc';

console.log(
  convertToMmNrc('12/TAMANA(N)112233') // ၁၂/တမန(နိုင်)112233
);
# OUTPUT
#
# ၁၂/တမန(နိုင်)112233

Convert Myanmar NRC string to English NRC string

import { convertToEnNrc } from 'mm-nrc';

console.log(
  convertToEnNrc('၁၂/တမန(နိုင်)112233') // 12/TAMANA(N)112233
);
# OUTPUT
#
# 12/TAMANA(N)112233

De-structure NRC data from the NRC string

import { splitNrc } from 'mm-nrc';

console.log(
  splitNrc('12/TAMANA(N)112233')
);
# OUTPUT
#
# {
#    nrcNumber: '112233',
#    nrcType: 'N',
#    stateNo: '12',
#    townshipCode: 'TAMANA'
# }

Last updated