jonschlinkert/get-value là dự án TypeScript với 307 sao trong nhóm Backend. Use property paths (`a.b.c`) get a nested value from an object.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Use property paths like 'a.b.c' to get a nested value from an object. Even works when keys have dots in them (no other dot-prop library we tested does this, or does it correctly).
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Slightly improves performance by passing an array of strings to use as object path segments (this is also useful when you need to dynamically build up the path segments):
Custom function to use for splitting the string into object path segments.
const obj = { 'a.b': { c: { d: 'e' } } };
// example of using a string to split the object path
const options = { split: path => path.split('/') };
console.log(getValue(obj, 'a.b/c/d', options)); //=> 'e'
// example of using a regex to split the object path
// (removing escaped dots is unnecessary, this is just an example)
const options = { split: path => path.split(/\\?\./) };
console.log(getValue(obj, 'a\\.b.c.d', options)); //=> 'e'
options.separator
Type: string|regex
Default: .
The separator to use for splitting the string (this is probably not needed when options.split is used).
Customize how the object path is created when iterating over path segments.
const obj = { 'a/b': { c: { d: 'e' } } };
const options = {
// when segs === ['a', 'b'] use a "/" to join, otherwise use a "."
join: segs => segs.join(segs[0] === 'a' ? '/' : '.')
};
console.log(getValue(obj, 'a.b.c.d', options));
//=> 'e'
options.joinChar
Type: string
Default: .
The character to use when re-joining the string to check for keys with dots in them (this is probably not needed when options.join is used). This can be a different value than the separator, since the separator can be a string or regex.
Adds support for Map-like objects, allowing objects with a get method that can be used to retrieve values by key.
Removed outdated travis config, and added GitHub Actions workflow for running tests.
v4.0.0
Refactored to TypeScript
Added support for handling deep property paths with arrays
Improved performance on large nested objects
Fixed edge case issues with keys containing special characters.
Updated benchmarks
Updated documentation to reflect new features and bug fixes.
v3.0.0
Improved support for escaping. It's no longer necessary to use backslashes to escape keys.
Adds options.default for defining a default value to return when no value is resolved.
Adds options.isValid to allow the user to check the object after each iteration.
Adds options.separator for customizing character to split on.
Adds options.split for customizing how the object path is split.
Adds options.join for customizing how the object path is joined when iterating over path segments.
Adds options.joinChar for customizing the join character.
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jonschlinkert/get-value là nguồn chính thức.
jonschlinkert/get-value có phải mã nguồn mở không?
Có — jonschlinkert/get-value phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/jonschlinkert/get-value.
jonschlinkert/get-value có trang demo không?
Dự án có trang chủ ở https://github.com/jonschlinkert. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
jonschlinkert/get-value còn đang phát triển không?
Commit gần nhất trên jonschlinkert/get-value là 2 tháng trước (theo timestamp GitHub). Repo có 23 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
jonschlinkert/get-value dùng license gì?
jonschlinkert/get-value phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc get-value có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về get-value.