# [JavaScript (Node.js)], 257 bytes

[JavaScript (Node.js)]: https://nodejs.org

<!-- language: lang-javascript -->

    f=n=>n?`012388887654`.replace(e=/\d/g,y=>`7654|0123
    `.replace(e,x=>"_ \\/.'|"[q=y/2&2|x>3,y&8?1:(k=8-~~'80764467'[j=~~('0x'+(1e6+'1023405671567899AB99A899CB99C')[y%4+~-(n/10**q%10)*4])]>>x%4&1?'0122233346545'[j]:2045>>j&1)^0xCC6600>>k*4+q&1]))+f(n/1e4|0):''

[Try it online!](https://tio.run/##VVDbaoNAFHzPV5SA7q5G3ZvrBXal9TPU1pCsoYloTEpREH/drn1qDwwDZw7DzLkev4/P0@Pz/uV1/VmvayM7qbqsxoSy2EwkQl77D31vjycNtQzKc3A5TFLVmzJvZ7s/@mGUav/xUpaBD@Z9McgpoDadR8UOkx1nJIU3GXvLAmIcCc5FBIqrXBYI8AhcSLRwAcGUcRyKiBjESfL6ZmA4N5wDVEwWdxcPdgHBjjNYBCOHV6hSarS4TTJgIlHKGOMmX2jsq5RiHip1tQl6x2OeC4GxUjeHu4NNKoTcZjPTpgxKAVhPfffsW@23/QU20PTjIUK7/9vk9y@MEoTWHw "JavaScript (Node.js) – Try It Online")

### Encoding

Each digit pattern is a 4x4 matrix consisting of 7 distinct characters. Each character is encoded as a single decimal digit from `0` to `6`:

    0: "_"
    1: " "
    2: "\"
    3: "/"
    4: "."
    5: "'"
    6: "|"

All matrices are built with 13 distinct rows, encoded as a single hexadecimal digit from `0` to `C`:

    0: 1111 for "    "
    1: 0001 for "___ "
    2: 2111 for "\   "
    3: 1211 for " \  "
    4: 1121 for "  \ "
    5: 1131 for "  / "
    6: 1311 for " /  "
    7: 3111 for "/   "
    8: 1114 for "   ."
    9: 1116 for "   |"
    A: 1115 for "   '"
    B: 0004 for "___."
    C: 0005 for "___'"

So, each matrix is fully described by a sequence of 4 hexadecimal digits. For instance, the matrix for `7` is encoded as `B99A`:

    B99A -> 0004 -> "___."
            1116    "   |"
            1116    "   |"
            1115    "   '"

Each of the 13 rows are made of a 'background' character and a 'foreground' character. So they can be encoded as:

- a 4-bit mask
- the 'background' character (which is always either `0` for `"_"` or `1` for `" "`)
- the 'foreground' character

This is summarized in the following table:

     ID | string | digits | mask | BG char. | FG char.
    ----+--------+--------+------+----------+----------
      0 | "    " |  1111  | 0000 |    1     |    0
      1 | "___ " |  0001  | 0001 |    0     |    1
      2 | "\   " |  2111  | 1000 |    1     |    2
      3 | " \  " |  1211  | 0100 |    1     |    2
      4 | "  \ " |  1121  | 0010 |    1     |    2
      5 | "  / " |  1131  | 0010 |    1     |    3
      6 | " /  " |  1311  | 0100 |    1     |    3
      7 | "/   " |  3111  | 1000 |    1     |    3
      8 | "   ." |  1114  | 0001 |    1     |    4
      9 | "   |" |  1116  | 0001 |    1     |    6
      A | "   '" |  1115  | 0001 |    1     |    5
      B | "___." |  0004  | 0001 |    0     |    4
      C | "___'" |  0005  | 0001 |    0     |    5