1.0.7 • Published 4 years ago

strings-template v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

#Installation

npm install strings-template

###使用方法

const st=require('strings-template');

// 解析字符串
const cmdStr = '21[len]0901[url]FS0140;';
const url = 'http://test.cn';
const len = url.length;
const rep = st.expandTemplate(cmdStr, { url, len });
console.log('rep', rep);  //  21140901http://test.cnFS0140;


// 反解析
const str = '21140901http://test.cnFS0140;';
const vs = 'header:2;len:2;cmd:2;form:2;url:0;crc:4;end:2;';
const strRepObj = st.parseTemplate(str, vs);
console.log('strRepObj', strRepObj); 
{
  header: '21',
  len: '14',
  cmd: '09',
  form: '01',
  url: 'http://test.cn',
  crc: 'FS01',
  end: '40'
}
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago