Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose bare minimum of a Path library/module #3632

Closed
kaste opened this issue May 2, 2016 · 1 comment
Closed

Expose bare minimum of a Path library/module #3632

kaste opened this issue May 2, 2016 · 1 comment

Comments

@kaste
Copy link
Contributor

kaste commented May 2, 2016

Seeing #3626 and #3631 it is really time to factor a Polymer.Path module to get these path manipulations right once and for all. Usually you set minutes to hours trying to understand something like 970d576

What we need:

  • head(path)
    foo.bar => foo
  • isDeep(path)
    foo.bar => true
    foo => false
  • isAncestor(base, path)
    ('foo.bar', 'foo') => true
    ('foo.bar', 'bar') => false
  • isDescendant(base, path)
    ('foo.bar', 'foo.bar.baz') => true
    ('foo.bar', 'foo.bar') => false
  • translate(base, newBase, path)
    ('foo', 'baz', 'foo.bar') => 'baz.bar'
  • matches(base, wildcard, path)
    ('foo.bar', false, 'foo.bar') => true
    ('foo.bar', true, 'foo.bar.baz') => true
    ('foo.bar', false, 'foo.bar.baz') => false

Note that these functions are pure and can be memoized.

@TimvdLippe
Copy link
Contributor

Was fixed in #3633 but not properly closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants