Apple's MagSafe and Lightning cables are notorious for fraying under heavy use. If you want to repair your cable, rather than purchase a replacement, Sugru Moldable Glue could be the solution you've been seeking [updated].
Update: A representative from Sugru contacted AppleInsider to emphasize the company's official advice on using the product: "To avoid heat build-up from short circuits or damaged wires, do not repair cables where the metal is exposed or the cable is already working intermittently."
Sugru Moldable Glue is available from Amazon in white, to match Apple's cables, in a large pack of 8 for $22, or a smaller pack of 3 starting at $11.20. Either amount will provide more than enough to repair a number of damaged cables.
If you have a collection of different cable types and colors, Sugru also comes in a multi-color variety pack of 8, including both black and white, for $17.85.
We've been using Sugru Moldable Glue on what was a damaged MacBook Pro MagSafe 2 cable for a few weeks now, and are generally pleased with the result.
Taken out of the box, Sugru is a putty-like substance that can be shaped into any shape or size you need it to fit. Once exposed to the air, you have 30 minutes to shape it as needed before it begins to dry.
Sugru adheres better to remaining cable insulation if the exterior is cleaned off first. You can do that with Windex and a paper towel (though obviously unplug the cable first).
Once you've wrapped Sugru around the damaged portion of your MagSafe or Lightning cable, give it 24 hours to fully dry. Over a day, it turns into a durable, flexible silicone rubber that remains in place.
After drying on our MagSafe cable, the result is a white, bendable coating that keeps the wires enclosed within. We first caught wind of this product from the Young House Love podcast.
For a frayed Lightning cable, it might be cheaper or more practical to get an Apple-certified replacement. But for MagSafe cables for legacy MacBooks, which are priced considerably more than replacement Lightning cables, Sugru could offer significant savings, extending the life of your disintegrating MacBook charger.