[Ramda] Convert a QueryString to an Object using Function Composition in Ramda
to in object Using an Function convert Ramda
2023-09-14 08:59:18 时间
In this lesson we'll use a handful of Ramda's utility functions to take a queryString full of name/value pairs and covert it into a JavaScript object so we can access those properties in a more useful way. Along the way, we'll build up a composition and look at the tail
, split
, map
and fromPairs
functions, along with the crucial compose
function.
const {compose, fromPairs, map, split, tail} = R const queryString = '?page=2&pageSize=10&total=203' const parseQs = compose( fromPairs, // {"page":"2","pageSize":"10","total":"203"} map(split('=')), // [["page","2"],["pageSize","10"],["total","203"]] split('&'), // ["page=2","pageSize=10","total=203"] tail // "page=2&pageSize=10&total=203" ) const result = parseQs(queryString) console.log(result)
相关文章
- spark包链接kafka集群报错org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
- How to access the HttpRequest object in Django forms( Django view 给 forms 传递数据)
- ORA-01240: too many data files to add in one command ORACLE 报错 故障修复 远程处理
- ORA-01650: unable to extend rollback segment string by string in tablespace string ORACLE 报错 故障修复 远程处理
- ORA-22819: scope of input value does not correspond to the scope of the target ORACLE 报错 故障修复 远程处理
- ORA-25280: complete sender information not provided to non-repudiate sender ORACLE 报错 故障修复 远程处理
- ORA-29251: Index1 is greater than Index2 in call to dbms_sql.bind_array ORACLE 报错 故障修复 远程处理
- ORA-31644: unable to position to block number string in dump file “string” ORACLE 报错 故障修复 远程处理
- ORA-48149: error encountered when attempting to copy a file ORACLE 报错 故障修复 远程处理
- MySQL Error number: 3638; Symbol: ER_CREDENTIALS_CONTRADICT_TO_HISTORY; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-60008: adding (string) blocks to index string.string with MAXSIZE (string) ORACLE 报错 故障修复 远程处理
- ORA-60012: adding (string) blocks to table string.string subpartition string with MAXSIZE (string) ORACLE 报错 故障修复 远程处理
- ORA-04035: unable to allocate string bytes of shared memory in shared object cache “string” of size “string” ORACLE 报错 故障修复 远程处理
- ORA-06960: Failed to access log file ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-011770; Symbol: ER_LDAP_AUTH_FAILED_TO_DEINITIALIZE_POOL_IN_RECONSTRUCT_STATE; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-10586: Test recovery had to corrupt 1 data block in order to proceed ORACLE 报错 故障修复 远程处理
- ORA-13284: failure to copy geometry object for conversion in place ORACLE 报错 故障修复 远程处理
- MySQL删除IN操作: 简易指南(mysql删除in)
- 方法掌握MySQL中IN方法的威力(mysql的in)
- 「MySQL SQL耗时优化技巧The clever way to optimize your SQL query performance」(mysqlsql耗时)
- Exploring the Power of JSON in MongoDB: A Comprehensive Guide to Data Management(jsonmongodb)
- 使用in操作符时MySQL是否能够充分利用索引MySQL In操作符优化技巧(mysql中in走索引吗)
- Oracle中IN与OR运算实现多条件查询的最佳选择(oracle中in与or)