@@ -10,15 +10,15 @@ function copy(subject, n = 1) {
1010}
1111
1212function first ( subject ) {
13- if ( subject . length == 0 ) {
14- throw new Error ( ` Binary is of length 0` ) ;
13+ if ( subject . length === 0 ) {
14+ throw new Error ( ' Binary is of length 0' ) ;
1515 }
1616 return at ( subject , 0 ) ;
1717}
1818
1919function last ( subject ) {
20- if ( subject . length == 0 ) {
21- throw new Error ( ` Binary is of length 0` ) ;
20+ if ( subject . length === 0 ) {
21+ throw new Error ( ' Binary is of length 0' ) ;
2222 }
2323 return subject . slice ( - 1 ) ;
2424}
@@ -29,20 +29,19 @@ function list_to_bin(bytelist) {
2929
3030function part ( subject , posOrTuple , len = null ) {
3131 if ( len === null ) {
32- var pos ;
33- [ pos , len ] = posOrTuple . values ;
34- return subject . substr ( pos , len ) ;
35- } else {
36- return subject . substr ( posOrTuple , len ) ;
32+ const [ pos , theLen ] = posOrTuple . values ;
33+ return subject . substr ( pos , theLen ) ;
3734 }
35+
36+ return subject . substr ( posOrTuple , len ) ;
3837}
3938
40- //TODO: Support more options
41- //TODO: pattern cannot be list of strings
39+ // TODO: Support more options
40+ // TODO: pattern cannot be list of strings
4241function replace ( subject , pattern , replacement , options = [ ] ) {
4342 const opt_global = proplists . get_value ( Symbol . for ( 'global' ) , options ) ;
4443
45- var regex ;
44+ let regex ;
4645 if ( opt_global !== Symbol . for ( 'undefined' ) ) {
4746 regex = new RegExp ( pattern , 'g' ) ;
4847 } else {
@@ -52,8 +51,8 @@ function replace(subject, pattern, replacement, options = []) {
5251 return subject . replace ( regex , replacement ) ;
5352}
5453
55- //TODO: Support more options, global is implied
56- //TODO: pattern cannot be list of strings
54+ // TODO: Support more options, global is implied
55+ // TODO: pattern cannot be list of strings
5756function split ( subject , pattern , options = [ ] ) {
5857 return subject . split ( pattern ) ;
5958}
0 commit comments