File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
src/javascript/lib/core/erlang_compat Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -105,11 +105,7 @@ function is_atom(value) {
105105 return true ;
106106 }
107107
108- return (
109- typeof value === 'symbol' ||
110- value instanceof Symbol ||
111- value . __MODULE__ != null
112- ) ;
108+ return typeof value === 'symbol' || value instanceof Symbol || value . __MODULE__ != null ;
113109}
114110
115111function is_bitstring ( value ) {
@@ -407,6 +403,22 @@ function function_exported(module, _function) {
407403 return module [ _function ] != null ;
408404}
409405
406+ function binary_to_term ( binary ) {
407+ let data = null ;
408+
409+ if ( is_binary ( binary ) ) {
410+ const buf = new ArrayBuffer ( binary . length ) ;
411+ const bufView = new Uint16Array ( buf ) ;
412+ for ( const i = 0 , strLen = str . length ; i < strLen ; i ++ ) {
413+ bufView [ i ] = binary . charCodeAt ( i ) ;
414+ }
415+
416+ data = bufView ;
417+ } else {
418+ data = Uint8Array . of ( ...binary ) ;
419+ }
420+ }
421+
410422export default {
411423 atom_to_binary,
412424 binary_to_atom,
@@ -472,5 +484,5 @@ export default {
472484 exit,
473485 raise,
474486 list_to_binary,
475- nodes
487+ nodes,
476488} ;
You can’t perform that action at this time.
0 commit comments